LCOV - code coverage report
Current view: top level - sc/source/ui/miscdlgs - optsolver.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 553 0.0 %
Date: 2012-08-25 Functions: 0 50 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 1258 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include "rangelst.hxx"
      30                 :            : #include "scitems.hxx"
      31                 :            : #include <sfx2/bindings.hxx>
      32                 :            : #include <sfx2/imagemgr.hxx>
      33                 :            : #include <svl/zforlist.hxx>
      34                 :            : #include <vcl/msgbox.hxx>
      35                 :            : #include <vcl/svapp.hxx>
      36                 :            : 
      37                 :            : #include "uiitems.hxx"
      38                 :            : #include "reffact.hxx"
      39                 :            : #include "docsh.hxx"
      40                 :            : #include "docfunc.hxx"
      41                 :            : #include "cell.hxx"
      42                 :            : #include "rangeutl.hxx"
      43                 :            : #include "scresid.hxx"
      44                 :            : #include "convuno.hxx"
      45                 :            : #include "unonames.hxx"
      46                 :            : #include "solveroptions.hxx"
      47                 :            : #include "solverutil.hxx"
      48                 :            : #include "optsolver.hrc"
      49                 :            : 
      50                 :            : #include "optsolver.hxx"
      51                 :            : 
      52                 :            : #include <com/sun/star/sheet/Solver.hpp>
      53                 :            : #include <com/sun/star/sheet/XSolverDescription.hpp>
      54                 :            : 
      55                 :            : using namespace com::sun::star;
      56                 :            : 
      57                 :            : //----------------------------------------------------------------------------
      58                 :            : 
      59                 :          0 : ScSolverProgressDialog::ScSolverProgressDialog( Window* pParent )
      60                 :            :     : ModelessDialog( pParent, ScResId( RID_SCDLG_SOLVER_PROGRESS ) ),
      61                 :            :     maFtProgress    ( this, ScResId( FT_PROGRESS ) ),
      62                 :            :     maFtTime        ( this, ScResId( FT_TIMELIMIT ) ),
      63                 :            :     maFlButtons     ( this, ScResId( FL_BUTTONS ) ),
      64 [ #  # ][ #  # ]:          0 :     maBtnOk         ( this, ScResId( BTN_OK ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      65                 :            : {
      66         [ #  # ]:          0 :     maBtnOk.Enable(false);
      67         [ #  # ]:          0 :     FreeResource();
      68                 :          0 : }
      69                 :            : 
      70 [ #  # ][ #  # ]:          0 : ScSolverProgressDialog::~ScSolverProgressDialog()
         [ #  # ][ #  # ]
      71                 :            : {
      72         [ #  # ]:          0 : }
      73                 :            : 
      74                 :          0 : void ScSolverProgressDialog::HideTimeLimit()
      75                 :            : {
      76                 :          0 :     maFtTime.Hide();
      77                 :          0 : }
      78                 :            : 
      79                 :          0 : void ScSolverProgressDialog::SetTimeLimit( sal_Int32 nSeconds )
      80                 :            : {
      81         [ #  # ]:          0 :     String aOld = maFtTime.GetText();
      82         [ #  # ]:          0 :     String aNew = aOld.GetToken(0,'#');
      83 [ #  # ][ #  # ]:          0 :     aNew += String::CreateFromInt32( nSeconds );
                 [ #  # ]
      84 [ #  # ][ #  # ]:          0 :     aNew += aOld.GetToken(1,'#');
                 [ #  # ]
      85 [ #  # ][ #  # ]:          0 :     maFtTime.SetText( aNew );
                 [ #  # ]
      86                 :          0 : }
      87                 :            : 
      88                 :            : //----------------------------------------------------------------------------
      89                 :            : 
      90                 :          0 : ScSolverNoSolutionDialog::ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText )
      91                 :            :     : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_NOSOLUTION ) ),
      92                 :            :     maFtNoSolution  ( this, ScResId( FT_NOSOLUTION ) ),
      93                 :            :     maFtErrorText   ( this, ScResId( FT_ERRORTEXT ) ),
      94                 :            :     maFlButtons     ( this, ScResId( FL_BUTTONS ) ),
      95 [ #  # ][ #  # ]:          0 :     maBtnOk         ( this, ScResId( BTN_OK ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
      96                 :            : {
      97         [ #  # ]:          0 :     maFtErrorText.SetText( rErrorText );
      98         [ #  # ]:          0 :     FreeResource();
      99                 :          0 : }
     100                 :            : 
     101 [ #  # ][ #  # ]:          0 : ScSolverNoSolutionDialog::~ScSolverNoSolutionDialog()
         [ #  # ][ #  # ]
     102                 :            : {
     103         [ #  # ]:          0 : }
     104                 :            : 
     105                 :            : //----------------------------------------------------------------------------
     106                 :            : 
     107                 :          0 : ScSolverSuccessDialog::ScSolverSuccessDialog( Window* pParent, const String& rSolution )
     108                 :            :     : ModalDialog( pParent, ScResId( RID_SCDLG_SOLVER_SUCCESS ) ),
     109                 :            :     maFtSuccess     ( this, ScResId( FT_SUCCESS ) ),
     110                 :            :     maFtResult      ( this, ScResId( FT_RESULT ) ),
     111                 :            :     maFtQuestion    ( this, ScResId( FT_QUESTION ) ),
     112                 :            :     maFlButtons     ( this, ScResId( FL_BUTTONS ) ),
     113                 :            :     maBtnOk         ( this, ScResId( BTN_OK ) ),
     114 [ #  # ][ #  # ]:          0 :     maBtnCancel     ( this, ScResId( BTN_CANCEL ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     115                 :            : {
     116         [ #  # ]:          0 :     String aMessage = maFtResult.GetText();
     117         [ #  # ]:          0 :     aMessage.Append( (sal_Char) ' ' );
     118         [ #  # ]:          0 :     aMessage.Append( rSolution );
     119         [ #  # ]:          0 :     maFtResult.SetText( aMessage );
     120 [ #  # ][ #  # ]:          0 :     FreeResource();
     121                 :          0 : }
     122                 :            : 
     123 [ #  # ][ #  # ]:          0 : ScSolverSuccessDialog::~ScSolverSuccessDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     124                 :            : {
     125         [ #  # ]:          0 : }
     126                 :            : 
     127                 :            : //----------------------------------------------------------------------------
     128                 :            : 
     129                 :          0 : ScCursorRefEdit::ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId ) :
     130 [ #  # ][ #  # ]:          0 :     formula::RefEdit( pParent, pParent, rResId )
                 [ #  # ]
     131                 :            : {
     132                 :          0 : }
     133                 :            : 
     134                 :          0 : void ScCursorRefEdit::SetCursorLinks( const Link& rUp, const Link& rDown )
     135                 :            : {
     136                 :          0 :     maCursorUpLink = rUp;
     137                 :          0 :     maCursorDownLink = rDown;
     138                 :          0 : }
     139                 :            : 
     140                 :          0 : void ScCursorRefEdit::KeyInput( const KeyEvent& rKEvt )
     141                 :            : {
     142                 :          0 :     KeyCode aCode = rKEvt.GetKeyCode();
     143                 :          0 :     bool bUp = (aCode.GetCode() == KEY_UP);
     144                 :          0 :     bool bDown = (aCode.GetCode() == KEY_DOWN);
     145 [ #  # ][ #  # ]:          0 :     if ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() && ( bUp || bDown ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     146                 :            :     {
     147         [ #  # ]:          0 :         if ( bUp )
     148         [ #  # ]:          0 :             maCursorUpLink.Call( this );
     149                 :            :         else
     150         [ #  # ]:          0 :             maCursorDownLink.Call( this );
     151                 :            :     }
     152                 :            :     else
     153         [ #  # ]:          0 :         formula::RefEdit::KeyInput( rKEvt );
     154                 :          0 : }
     155                 :            : 
     156                 :            : //----------------------------------------------------------------------------
     157                 :            : 
     158                 :          0 : ScOptSolverSave::ScOptSolverSave( const String& rObjective, sal_Bool bMax, sal_Bool bMin, sal_Bool bValue,
     159                 :            :                              const String& rTarget, const String& rVariable,
     160                 :            :                              const std::vector<ScOptConditionRow>& rConditions,
     161                 :            :                              const String& rEngine,
     162                 :            :                              const uno::Sequence<beans::PropertyValue>& rProperties ) :
     163                 :            :     maObjective( rObjective ),
     164                 :            :     mbMax( bMax ),
     165                 :            :     mbMin( bMin ),
     166                 :            :     mbValue( bValue ),
     167                 :            :     maTarget( rTarget ),
     168                 :            :     maVariable( rVariable ),
     169                 :            :     maConditions( rConditions ),
     170                 :            :     maEngine( rEngine ),
     171 [ #  # ][ #  # ]:          0 :     maProperties( rProperties )
         [ #  # ][ #  # ]
                 [ #  # ]
     172                 :            : {
     173                 :          0 : }
     174                 :            : 
     175                 :            : //============================================================================
     176                 :            : //  class ScOptSolverDlg
     177                 :            : //----------------------------------------------------------------------------
     178                 :            : 
     179                 :          0 : ScOptSolverDlg::ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
     180                 :            :                           ScDocShell* pDocSh, ScAddress aCursorPos )
     181                 :            : 
     182                 :            :     :   ScAnyRefDlg         ( pB, pCW, pParent, RID_SCDLG_OPTSOLVER ),
     183                 :            :         //
     184                 :            :         maFtObjectiveCell   ( this, ScResId( FT_OBJECTIVECELL ) ),
     185                 :            :         maEdObjectiveCell   ( this, this, ScResId( ED_OBJECTIVECELL ) ),
     186                 :            :         maRBObjectiveCell   ( this, ScResId( IB_OBJECTIVECELL ), &maEdObjectiveCell, this ),
     187                 :            :         maFtDirection       ( this, ScResId( FT_DIRECTION ) ),
     188                 :            :         maRbMax             ( this, ScResId( RB_MAX ) ),
     189                 :            :         maRbMin             ( this, ScResId( RB_MIN ) ),
     190                 :            :         maRbValue           ( this, ScResId( RB_VALUE ) ),
     191                 :            :         maEdTargetValue     ( this, this, ScResId( ED_TARGET ) ),
     192                 :            :         maRBTargetValue     ( this, ScResId( IB_TARGET ), &maEdTargetValue, this ),
     193                 :            :         maFtVariableCells   ( this, ScResId( FT_VARIABLECELLS ) ),
     194                 :            :         maEdVariableCells   ( this, this, ScResId( ED_VARIABLECELLS ) ),
     195                 :            :         maRBVariableCells   ( this, ScResId( IB_VARIABLECELLS ), &maEdVariableCells, this),
     196                 :            :         maFlConditions      ( this, ScResId( FL_CONDITIONS ) ),
     197                 :            :         maFtCellRef         ( this, ScResId( FT_CELLREF ) ),
     198                 :            :         maEdLeft1           ( this, ScResId( ED_LEFT1 ) ),
     199                 :            :         maRBLeft1           ( this, ScResId( IB_LEFT1 ), &maEdLeft1, this ),
     200                 :            :         maFtOperator        ( this, ScResId( FT_OPERATOR ) ),
     201                 :            :         maLbOp1             ( this, ScResId( LB_OP1 ) ),
     202                 :            :         maFtConstraint      ( this, ScResId( FT_CONSTRAINT ) ),
     203                 :            :         maEdRight1          ( this, ScResId( ED_RIGHT1 ) ),
     204                 :            :         maRBRight1          ( this, ScResId( IB_RIGHT1 ), &maEdRight1, this ),
     205                 :            :         maBtnDel1           ( this, ScResId( IB_DELETE1 ) ),
     206                 :            :         maEdLeft2           ( this, ScResId( ED_LEFT2 ) ),
     207                 :            :         maRBLeft2           ( this, ScResId( IB_LEFT2 ), &maEdLeft2, this ),
     208                 :            :         maLbOp2             ( this, ScResId( LB_OP2 ) ),
     209                 :            :         maEdRight2          ( this, ScResId( ED_RIGHT2 ) ),
     210                 :            :         maRBRight2          ( this, ScResId( IB_RIGHT2 ), &maEdRight2, this ),
     211                 :            :         maBtnDel2           ( this, ScResId( IB_DELETE2 ) ),
     212                 :            :         maEdLeft3           ( this, ScResId( ED_LEFT3 ) ),
     213                 :            :         maRBLeft3           ( this, ScResId( IB_LEFT3 ), &maEdLeft3, this ),
     214                 :            :         maLbOp3             ( this, ScResId( LB_OP3 ) ),
     215                 :            :         maEdRight3          ( this, ScResId( ED_RIGHT3 ) ),
     216                 :            :         maRBRight3          ( this, ScResId( IB_RIGHT3 ), &maEdRight3, this ),
     217                 :            :         maBtnDel3           ( this, ScResId( IB_DELETE3 ) ),
     218                 :            :         maEdLeft4           ( this, ScResId( ED_LEFT4 ) ),
     219                 :            :         maRBLeft4           ( this, ScResId( IB_LEFT4 ), &maEdLeft4, this ),
     220                 :            :         maLbOp4             ( this, ScResId( LB_OP4 ) ),
     221                 :            :         maEdRight4          ( this, ScResId( ED_RIGHT4 ) ),
     222                 :            :         maRBRight4          ( this, ScResId( IB_RIGHT4 ), &maEdRight4, this ),
     223                 :            :         maBtnDel4           ( this, ScResId( IB_DELETE4 ) ),
     224                 :            :         maScrollBar         ( this, ScResId( SB_SCROLL ) ),
     225                 :            :         maFlButtons         ( this, ScResId( FL_BUTTONS ) ),
     226                 :            :         maBtnOpt            ( this, ScResId( BTN_OPTIONS ) ),
     227                 :            :         maBtnHelp           ( this, ScResId( BTN_HELP ) ),
     228                 :            :         maBtnCancel         ( this, ScResId( BTN_CLOSE ) ),
     229                 :            :         maBtnSolve          ( this, ScResId( BTN_SOLVE ) ),
     230                 :            :         maInputError        ( ScResId( STR_INVALIDINPUT ) ),
     231                 :            :         maConditionError    ( ScResId( STR_INVALIDCONDITION ) ),
     232                 :            :         //
     233                 :            :         mpDocShell          ( pDocSh ),
     234                 :          0 :         mpDoc               ( pDocSh->GetDocument() ),
     235                 :          0 :         mnCurTab            ( aCursorPos.Tab() ),
     236                 :            :         mpEdActive          ( NULL ),
     237                 :            :         mbDlgLostFocus      ( false ),
     238 [ #  # ][ #  # ]:          0 :         nScrollPos          ( 0 )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     239                 :            : {
     240                 :          0 :     mpLeftEdit[0]    = &maEdLeft1;
     241                 :          0 :     mpLeftButton[0]  = &maRBLeft1;
     242                 :          0 :     mpRightEdit[0]   = &maEdRight1;
     243                 :          0 :     mpRightButton[0] = &maRBRight1;
     244                 :          0 :     mpOperator[0]    = &maLbOp1;
     245                 :          0 :     mpDelButton[0]   = &maBtnDel1;
     246                 :            : 
     247                 :          0 :     mpLeftEdit[1]    = &maEdLeft2;
     248                 :          0 :     mpLeftButton[1]  = &maRBLeft2;
     249                 :          0 :     mpRightEdit[1]   = &maEdRight2;
     250                 :          0 :     mpRightButton[1] = &maRBRight2;
     251                 :          0 :     mpOperator[1]    = &maLbOp2;
     252                 :          0 :     mpDelButton[1]   = &maBtnDel2;
     253                 :            : 
     254                 :          0 :     mpLeftEdit[2]    = &maEdLeft3;
     255                 :          0 :     mpLeftButton[2]  = &maRBLeft3;
     256                 :          0 :     mpRightEdit[2]   = &maEdRight3;
     257                 :          0 :     mpRightButton[2] = &maRBRight3;
     258                 :          0 :     mpOperator[2]    = &maLbOp3;
     259                 :          0 :     mpDelButton[2]   = &maBtnDel3;
     260                 :            : 
     261                 :          0 :     mpLeftEdit[3]    = &maEdLeft4;
     262                 :          0 :     mpLeftButton[3]  = &maRBLeft4;
     263                 :          0 :     mpRightEdit[3]   = &maEdRight4;
     264                 :          0 :     mpRightButton[3] = &maRBRight4;
     265                 :          0 :     mpOperator[3]    = &maLbOp4;
     266                 :          0 :     mpDelButton[3]   = &maBtnDel4;
     267                 :            : 
     268         [ #  # ]:          0 :     maRbMax.SetAccessibleRelationMemberOf(&maFtDirection);
     269         [ #  # ]:          0 :     maRbMin.SetAccessibleRelationMemberOf(&maFtDirection);
     270         [ #  # ]:          0 :     maRbValue.SetAccessibleRelationMemberOf(&maFtDirection);
     271 [ #  # ][ #  # ]:          0 :     maEdLeft2.SetAccessibleName(maFtCellRef.GetText());
                 [ #  # ]
     272 [ #  # ][ #  # ]:          0 :     maLbOp2.SetAccessibleName(maFtOperator.GetText());
                 [ #  # ]
     273 [ #  # ][ #  # ]:          0 :     maEdRight2.SetAccessibleName(maFtConstraint.GetText());
                 [ #  # ]
     274 [ #  # ][ #  # ]:          0 :     maEdLeft3.SetAccessibleName(maFtCellRef.GetText());
                 [ #  # ]
     275 [ #  # ][ #  # ]:          0 :     maLbOp3.SetAccessibleName(maFtOperator.GetText());
                 [ #  # ]
     276 [ #  # ][ #  # ]:          0 :     maEdRight3.SetAccessibleName(maFtConstraint.GetText());
                 [ #  # ]
     277 [ #  # ][ #  # ]:          0 :     maEdLeft4.SetAccessibleName(maFtCellRef.GetText());
                 [ #  # ]
     278 [ #  # ][ #  # ]:          0 :     maLbOp4.SetAccessibleName(maFtOperator.GetText());
                 [ #  # ]
     279 [ #  # ][ #  # ]:          0 :     maEdRight4.SetAccessibleName(maFtConstraint.GetText());
                 [ #  # ]
     280                 :            : 
     281         [ #  # ]:          0 :     Init( aCursorPos );
     282         [ #  # ]:          0 :     FreeResource();
     283                 :          0 : }
     284                 :            : 
     285                 :            : //----------------------------------------------------------------------------
     286                 :            : 
     287 [ #  # ][ #  # ]:          0 : ScOptSolverDlg::~ScOptSolverDlg()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     288                 :            : {
     289         [ #  # ]:          0 : }
     290                 :            : 
     291                 :            : //----------------------------------------------------------------------------
     292                 :            : 
     293                 :          0 : void ScOptSolverDlg::Init(const ScAddress& rCursorPos)
     294                 :            : {
     295                 :            :     // Get the "Delete Rows" commandimagelist images from sfx instead of
     296                 :            :     // adding a second copy to sc (see ScTbxInsertCtrl::StateChanged)
     297                 :            : 
     298         [ #  # ]:          0 :     rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" ));
     299                 :          0 :     aSlotURL += rtl::OUString::valueOf( sal_Int32( SID_DEL_ROWS ) );
     300         [ #  # ]:          0 :     uno::Reference<frame::XFrame> xFrame = GetBindings().GetActiveFrame();
     301         [ #  # ]:          0 :     Image aDelNm = ::GetImage( xFrame, aSlotURL, false );
     302                 :            : 
     303         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     304                 :            :     {
     305         [ #  # ]:          0 :         mpDelButton[nRow]->SetModeImage( aDelNm );
     306                 :            :     }
     307                 :            : 
     308         [ #  # ]:          0 :     maBtnOpt.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
     309         [ #  # ]:          0 :     maBtnCancel.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
     310         [ #  # ]:          0 :     maBtnSolve.SetClickHdl( LINK( this, ScOptSolverDlg, BtnHdl ) );
     311                 :            : 
     312         [ #  # ]:          0 :     Link aLink = LINK( this, ScOptSolverDlg, GetFocusHdl );
     313                 :          0 :     maEdObjectiveCell.SetGetFocusHdl( aLink );
     314                 :          0 :     maRBObjectiveCell.SetGetFocusHdl( aLink );
     315                 :          0 :     maEdTargetValue.SetGetFocusHdl( aLink );
     316                 :          0 :     maRBTargetValue.SetGetFocusHdl( aLink );
     317                 :          0 :     maEdVariableCells.SetGetFocusHdl( aLink );
     318                 :          0 :     maRBVariableCells.SetGetFocusHdl( aLink );
     319                 :          0 :     maRbValue.SetGetFocusHdl( aLink );
     320         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     321                 :            :     {
     322                 :          0 :         mpLeftEdit[nRow]->SetGetFocusHdl( aLink );
     323                 :          0 :         mpLeftButton[nRow]->SetGetFocusHdl( aLink );
     324                 :          0 :         mpRightEdit[nRow]->SetGetFocusHdl( aLink );
     325                 :          0 :         mpRightButton[nRow]->SetGetFocusHdl( aLink );
     326                 :          0 :         mpOperator[nRow]->SetGetFocusHdl( aLink );
     327                 :            :     }
     328                 :            : 
     329         [ #  # ]:          0 :     aLink = LINK( this, ScOptSolverDlg, LoseFocusHdl );
     330                 :          0 :     maEdObjectiveCell.SetLoseFocusHdl( aLink );
     331                 :          0 :     maRBObjectiveCell.SetLoseFocusHdl( aLink );
     332                 :          0 :     maEdTargetValue.  SetLoseFocusHdl( aLink );
     333                 :          0 :     maRBTargetValue.  SetLoseFocusHdl( aLink );
     334                 :          0 :     maEdVariableCells.SetLoseFocusHdl( aLink );
     335                 :          0 :     maRBVariableCells.SetLoseFocusHdl( aLink );
     336         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     337                 :            :     {
     338                 :          0 :         mpLeftEdit[nRow]->SetLoseFocusHdl( aLink );
     339                 :          0 :         mpLeftButton[nRow]->SetLoseFocusHdl( aLink );
     340                 :          0 :         mpRightEdit[nRow]->SetLoseFocusHdl( aLink );
     341                 :          0 :         mpRightButton[nRow]->SetLoseFocusHdl( aLink );
     342                 :            :     }
     343                 :            : 
     344         [ #  # ]:          0 :     Link aCursorUp = LINK( this, ScOptSolverDlg, CursorUpHdl );
     345         [ #  # ]:          0 :     Link aCursorDown = LINK( this, ScOptSolverDlg, CursorDownHdl );
     346         [ #  # ]:          0 :     Link aCondModify = LINK( this, ScOptSolverDlg, CondModifyHdl );
     347         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     348                 :            :     {
     349                 :          0 :         mpLeftEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
     350                 :          0 :         mpRightEdit[nRow]->SetCursorLinks( aCursorUp, aCursorDown );
     351         [ #  # ]:          0 :         mpLeftEdit[nRow]->SetModifyHdl( aCondModify );
     352         [ #  # ]:          0 :         mpRightEdit[nRow]->SetModifyHdl( aCondModify );
     353         [ #  # ]:          0 :         mpDelButton[nRow]->SetClickHdl( LINK( this, ScOptSolverDlg, DelBtnHdl ) );
     354         [ #  # ]:          0 :         mpOperator[nRow]->SetSelectHdl( LINK( this, ScOptSolverDlg, SelectHdl ) );
     355                 :            :     }
     356         [ #  # ]:          0 :     maEdTargetValue.SetModifyHdl( LINK( this, ScOptSolverDlg, TargetModifyHdl ) );
     357                 :            : 
     358         [ #  # ]:          0 :     maScrollBar.SetEndScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
     359         [ #  # ]:          0 :     maScrollBar.SetScrollHdl( LINK( this, ScOptSolverDlg, ScrollHdl ) );
     360                 :            : 
     361                 :          0 :     maScrollBar.SetPageSize( EDIT_ROW_COUNT );
     362         [ #  # ]:          0 :     maScrollBar.SetVisibleSize( EDIT_ROW_COUNT );
     363                 :          0 :     maScrollBar.SetLineSize( 1 );
     364                 :            :     // Range is set in ShowConditions
     365                 :            : 
     366                 :            :     // get available solver implementations
     367                 :            :     //! sort by descriptions?
     368         [ #  # ]:          0 :     ScSolverUtil::GetImplementations( maImplNames, maDescriptions );
     369                 :          0 :     sal_Int32 nImplCount = maImplNames.getLength();
     370                 :            : 
     371                 :          0 :     const ScOptSolverSave* pOldData = mpDocShell->GetSolverSaveData();
     372         [ #  # ]:          0 :     if ( pOldData )
     373                 :            :     {
     374         [ #  # ]:          0 :         maEdObjectiveCell.SetRefString( pOldData->GetObjective() );
     375         [ #  # ]:          0 :         maRbMax.Check( pOldData->GetMax() );
     376         [ #  # ]:          0 :         maRbMin.Check( pOldData->GetMin() );
     377         [ #  # ]:          0 :         maRbValue.Check( pOldData->GetValue() );
     378         [ #  # ]:          0 :         maEdTargetValue.SetRefString( pOldData->GetTarget() );
     379         [ #  # ]:          0 :         maEdVariableCells.SetRefString( pOldData->GetVariable() );
     380         [ #  # ]:          0 :         maConditions = pOldData->GetConditions();
     381         [ #  # ]:          0 :         maEngine = pOldData->GetEngine();
     382         [ #  # ]:          0 :         maProperties = pOldData->GetProperties();
     383                 :            :     }
     384                 :            :     else
     385                 :            :     {
     386         [ #  # ]:          0 :         maRbMax.Check();
     387                 :          0 :         rtl::OUString aCursorStr;
     388 [ #  # ][ #  # ]:          0 :         if ( !mpDoc->GetRangeAtBlock( ScRange(rCursorPos), &aCursorStr ) )
     389 [ #  # ][ #  # ]:          0 :             rCursorPos.Format( aCursorStr, SCA_ABS, NULL, mpDoc->GetAddressConvention() );
     390 [ #  # ][ #  # ]:          0 :         maEdObjectiveCell.SetRefString( aCursorStr );
                 [ #  # ]
     391         [ #  # ]:          0 :         if ( nImplCount > 0 )
     392 [ #  # ][ #  # ]:          0 :             maEngine = maImplNames[0];  // use first implementation
     393                 :            :     }
     394         [ #  # ]:          0 :     ShowConditions();
     395                 :            : 
     396         [ #  # ]:          0 :     maEdObjectiveCell.GrabFocus();
     397         [ #  # ]:          0 :     mpEdActive = &maEdObjectiveCell;
     398                 :          0 : }
     399                 :            : 
     400                 :            : //----------------------------------------------------------------------------
     401                 :            : 
     402                 :          0 : void ScOptSolverDlg::ReadConditions()
     403                 :            : {
     404         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     405                 :            :     {
     406         [ #  # ]:          0 :         ScOptConditionRow aRowEntry;
     407 [ #  # ][ #  # ]:          0 :         aRowEntry.aLeftStr = mpLeftEdit[nRow]->GetText();
                 [ #  # ]
     408 [ #  # ][ #  # ]:          0 :         aRowEntry.aRightStr = mpRightEdit[nRow]->GetText();
                 [ #  # ]
     409         [ #  # ]:          0 :         aRowEntry.nOperator = mpOperator[nRow]->GetSelectEntryPos();
     410                 :            : 
     411                 :          0 :         long nVecPos = nScrollPos + nRow;
     412 [ #  # ][ #  # ]:          0 :         if ( nVecPos >= (long)maConditions.size() && !aRowEntry.IsDefault() )
                 [ #  # ]
     413         [ #  # ]:          0 :             maConditions.resize( nVecPos + 1 );
     414                 :            : 
     415         [ #  # ]:          0 :         if ( nVecPos < (long)maConditions.size() )
     416         [ #  # ]:          0 :             maConditions[nVecPos] = aRowEntry;
     417                 :            : 
     418                 :            :         // remove default entries at the end
     419                 :          0 :         size_t nSize = maConditions.size();
     420 [ #  # ][ #  # ]:          0 :         while ( nSize > 0 && maConditions[ nSize-1 ].IsDefault() )
                 [ #  # ]
     421                 :          0 :             --nSize;
     422         [ #  # ]:          0 :         maConditions.resize( nSize );
     423         [ #  # ]:          0 :     }
     424                 :          0 : }
     425                 :            : 
     426                 :          0 : void ScOptSolverDlg::ShowConditions()
     427                 :            : {
     428         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     429                 :            :     {
     430         [ #  # ]:          0 :         ScOptConditionRow aRowEntry;
     431                 :            : 
     432                 :          0 :         long nVecPos = nScrollPos + nRow;
     433         [ #  # ]:          0 :         if ( nVecPos < (long)maConditions.size() )
     434         [ #  # ]:          0 :             aRowEntry = maConditions[nVecPos];
     435                 :            : 
     436         [ #  # ]:          0 :         mpLeftEdit[nRow]->SetRefString( aRowEntry.aLeftStr );
     437         [ #  # ]:          0 :         mpRightEdit[nRow]->SetRefString( aRowEntry.aRightStr );
     438         [ #  # ]:          0 :         mpOperator[nRow]->SelectEntryPos( aRowEntry.nOperator );
     439         [ #  # ]:          0 :     }
     440                 :            : 
     441                 :            :     // allow to scroll one page behind the visible or stored rows
     442                 :          0 :     long nVisible = nScrollPos + EDIT_ROW_COUNT;
     443         [ #  # ]:          0 :     long nMax = std::max( nVisible, (long) maConditions.size() );
     444         [ #  # ]:          0 :     maScrollBar.SetRange( Range( 0, nMax + EDIT_ROW_COUNT ) );
     445         [ #  # ]:          0 :     maScrollBar.SetThumbPos( nScrollPos );
     446                 :            : 
     447         [ #  # ]:          0 :     EnableButtons();
     448                 :          0 : }
     449                 :            : 
     450                 :          0 : void ScOptSolverDlg::EnableButtons()
     451                 :            : {
     452         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     453                 :            :     {
     454                 :          0 :         long nVecPos = nScrollPos + nRow;
     455                 :          0 :         mpDelButton[nRow]->Enable( nVecPos < (long)maConditions.size() );
     456                 :            :     }
     457                 :          0 : }
     458                 :            : 
     459                 :            : //----------------------------------------------------------------------------
     460                 :            : 
     461                 :          0 : sal_Bool ScOptSolverDlg::Close()
     462                 :            : {
     463                 :          0 :     return DoClose( ScOptSolverDlgWrapper::GetChildWindowId() );
     464                 :            : }
     465                 :            : 
     466                 :            : //----------------------------------------------------------------------------
     467                 :            : 
     468                 :          0 : void ScOptSolverDlg::SetActive()
     469                 :            : {
     470         [ #  # ]:          0 :     if ( mbDlgLostFocus )
     471                 :            :     {
     472                 :          0 :         mbDlgLostFocus = false;
     473         [ #  # ]:          0 :         if( mpEdActive )
     474                 :          0 :             mpEdActive->GrabFocus();
     475                 :            :     }
     476                 :            :     else
     477                 :            :     {
     478                 :          0 :         GrabFocus();
     479                 :            :     }
     480                 :          0 :     RefInputDone();
     481                 :          0 : }
     482                 :            : 
     483                 :            : //----------------------------------------------------------------------------
     484                 :            : 
     485                 :          0 : void ScOptSolverDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
     486                 :            : {
     487         [ #  # ]:          0 :     if( mpEdActive )
     488                 :            :     {
     489         [ #  # ]:          0 :         if ( rRef.aStart != rRef.aEnd )
     490         [ #  # ]:          0 :             RefInputStart(mpEdActive);
     491                 :            : 
     492                 :            :         // "target"/"value": single cell
     493 [ #  # ][ #  # ]:          0 :         bool bSingle = ( mpEdActive == &maEdObjectiveCell || mpEdActive == &maEdTargetValue );
     494                 :            : 
     495         [ #  # ]:          0 :         String aStr;
     496                 :          0 :         ScAddress aAdr = rRef.aStart;
     497                 :          0 :         ScRange aNewRef( rRef );
     498         [ #  # ]:          0 :         if ( bSingle )
     499                 :          0 :             aNewRef.aEnd = aAdr;
     500                 :            : 
     501                 :          0 :         rtl::OUString aName;
     502 [ #  # ][ #  # ]:          0 :         if ( pDocP->GetRangeAtBlock( aNewRef, &aName ) )            // named range: show name
     503         [ #  # ]:          0 :             aStr = aName;
     504                 :            :         else                                                        // format cell/range reference
     505                 :            :         {
     506         [ #  # ]:          0 :             sal_uInt16 nFmt = ( aAdr.Tab() == mnCurTab ) ? SCA_ABS : SCA_ABS_3D;
     507         [ #  # ]:          0 :             if ( bSingle )
     508 [ #  # ][ #  # ]:          0 :                 aAdr.Format( aStr, nFmt, pDocP, pDocP->GetAddressConvention() );
     509                 :            :             else
     510 [ #  # ][ #  # ]:          0 :                 rRef.Format( aStr, nFmt | SCR_ABS, pDocP, pDocP->GetAddressConvention() );
     511                 :            :         }
     512                 :            : 
     513                 :            :         // variable cells can be several ranges, so only the selection is replaced
     514         [ #  # ]:          0 :         if ( mpEdActive == &maEdVariableCells )
     515                 :            :         {
     516         [ #  # ]:          0 :             String aVal = mpEdActive->GetText();
     517         [ #  # ]:          0 :             Selection aSel = mpEdActive->GetSelection();
     518                 :          0 :             aSel.Justify();
     519         [ #  # ]:          0 :             aVal.Erase( (xub_StrLen)aSel.Min(), (xub_StrLen)aSel.Len() );
     520         [ #  # ]:          0 :             aVal.Insert( aStr, (xub_StrLen)aSel.Min() );
     521                 :          0 :             Selection aNewSel( aSel.Min(), aSel.Min()+aStr.Len() );
     522         [ #  # ]:          0 :             mpEdActive->SetRefString( aVal );
     523 [ #  # ][ #  # ]:          0 :             mpEdActive->SetSelection( aNewSel );
     524                 :            :         }
     525                 :            :         else
     526         [ #  # ]:          0 :             mpEdActive->SetRefString( aStr );
     527                 :            : 
     528         [ #  # ]:          0 :         ReadConditions();
     529         [ #  # ]:          0 :         EnableButtons();
     530                 :            : 
     531                 :            :         // select "Value of" if a ref is input into "target" edit
     532         [ #  # ]:          0 :         if ( mpEdActive == &maEdTargetValue )
     533 [ #  # ][ #  # ]:          0 :             maRbValue.Check();
     534                 :            :     }
     535                 :          0 : }
     536                 :            : 
     537                 :            : //----------------------------------------------------------------------------
     538                 :            : 
     539                 :          0 : sal_Bool ScOptSolverDlg::IsRefInputMode() const
     540                 :            : {
     541                 :          0 :     return mpEdActive != NULL;
     542                 :            : }
     543                 :            : 
     544                 :            : //----------------------------------------------------------------------------
     545                 :            : // Handler:
     546                 :            : 
     547                 :          0 : IMPL_LINK( ScOptSolverDlg, BtnHdl, PushButton*, pBtn )
     548                 :            : {
     549 [ #  # ][ #  # ]:          0 :     if ( pBtn == &maBtnSolve || pBtn == &maBtnCancel )
     550                 :            :     {
     551                 :          0 :         bool bSolve = ( pBtn == &maBtnSolve );
     552                 :            : 
     553                 :          0 :         SetDispatcherLock( false );
     554                 :          0 :         SwitchToDocument();
     555                 :            : 
     556                 :          0 :         bool bClose = true;
     557         [ #  # ]:          0 :         if ( bSolve )
     558                 :          0 :             bClose = CallSolver();
     559                 :            : 
     560         [ #  # ]:          0 :         if ( bClose )
     561                 :            :         {
     562                 :            :             // Close: write dialog settings to DocShell for subsequent calls
     563         [ #  # ]:          0 :             ReadConditions();
     564                 :            :             ScOptSolverSave aSave(
     565                 :          0 :                 maEdObjectiveCell.GetText(), maRbMax.IsChecked(), maRbMin.IsChecked(), maRbValue.IsChecked(),
     566         [ #  # ]:          0 :                 maEdTargetValue.GetText(), maEdVariableCells.GetText(), maConditions, maEngine, maProperties );
           [ #  #  #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     567         [ #  # ]:          0 :             mpDocShell->SetSolverSaveData( aSave );
     568 [ #  # ][ #  # ]:          0 :             Close();
     569                 :            :         }
     570                 :            :         else
     571                 :            :         {
     572                 :            :             // no solution -> dialog is kept open
     573                 :          0 :             SetDispatcherLock( sal_True );
     574                 :          0 :         }
     575                 :            :     }
     576         [ #  # ]:          0 :     else if ( pBtn == &maBtnOpt )
     577                 :            :     {
     578                 :            :         //! move options dialog to UI lib?
     579                 :            :         ScSolverOptionsDialog* pOptDlg =
     580         [ #  # ]:          0 :             new ScSolverOptionsDialog( this, maImplNames, maDescriptions, maEngine, maProperties );
     581         [ #  # ]:          0 :         if ( pOptDlg->Execute() == RET_OK )
     582                 :            :         {
     583                 :          0 :             maEngine = pOptDlg->GetEngine();
     584                 :          0 :             maProperties = pOptDlg->GetProperties();
     585                 :            :         }
     586         [ #  # ]:          0 :         delete pOptDlg;
     587                 :            :     }
     588                 :            : 
     589                 :          0 :     return 0;
     590                 :            : }
     591                 :            : 
     592                 :            : //----------------------------------------------------------------------------
     593                 :            : 
     594                 :          0 : IMPL_LINK( ScOptSolverDlg, GetFocusHdl, Control*, pCtrl )
     595                 :            : {
     596                 :          0 :     Edit* pEdit = NULL;
     597                 :          0 :     mpEdActive = NULL;
     598                 :            : 
     599 [ #  # ][ #  # ]:          0 :     if( pCtrl == &maEdObjectiveCell || pCtrl == &maRBObjectiveCell )
     600                 :          0 :         pEdit = mpEdActive = &maEdObjectiveCell;
     601 [ #  # ][ #  # ]:          0 :     else if( pCtrl == &maEdTargetValue || pCtrl == &maRBTargetValue )
     602                 :          0 :         pEdit = mpEdActive = &maEdTargetValue;
     603 [ #  # ][ #  # ]:          0 :     else if( pCtrl == &maEdVariableCells || pCtrl == &maRBVariableCells )
     604                 :          0 :         pEdit = mpEdActive = &maEdVariableCells;
     605         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     606                 :            :     {
     607 [ #  # ][ #  # ]:          0 :         if( pCtrl == mpLeftEdit[nRow] || pCtrl == mpLeftButton[nRow] )
     608                 :          0 :             pEdit = mpEdActive = mpLeftEdit[nRow];
     609 [ #  # ][ #  # ]:          0 :         else if( pCtrl == mpRightEdit[nRow] || pCtrl == mpRightButton[nRow] )
     610                 :          0 :             pEdit = mpEdActive = mpRightEdit[nRow];
     611         [ #  # ]:          0 :         else if( pCtrl == mpOperator[nRow] )    // focus on "operator" list box
     612                 :          0 :             mpEdActive = mpRightEdit[nRow];     // use right edit for ref input, but don't change selection
     613                 :            :     }
     614         [ #  # ]:          0 :     if( pCtrl == &maRbValue )                   // focus on "Value of" radio button
     615                 :          0 :         mpEdActive = &maEdTargetValue;          // use value edit for ref input, but don't change selection
     616                 :            : 
     617         [ #  # ]:          0 :     if( pEdit )
     618         [ #  # ]:          0 :         pEdit->SetSelection( Selection( 0, SELECTION_MAX ) );
     619                 :            : 
     620                 :          0 :     return 0;
     621                 :            : }
     622                 :            : 
     623                 :            : //----------------------------------------------------------------------------
     624                 :            : 
     625                 :          0 : IMPL_LINK_NOARG(ScOptSolverDlg, LoseFocusHdl)
     626                 :            : {
     627                 :          0 :     mbDlgLostFocus = !IsActive();
     628                 :          0 :     return 0;
     629                 :            : }
     630                 :            : 
     631                 :            : //----------------------------------------------------------------------------
     632                 :            : 
     633                 :          0 : IMPL_LINK( ScOptSolverDlg, DelBtnHdl, PushButton*, pBtn )
     634                 :            : {
     635         [ #  # ]:          0 :     for ( sal_uInt16 nRow = 0; nRow < EDIT_ROW_COUNT; ++nRow )
     636         [ #  # ]:          0 :         if( pBtn == mpDelButton[nRow] )
     637                 :            :         {
     638                 :          0 :             sal_Bool bHadFocus = pBtn->HasFocus();
     639                 :            : 
     640                 :          0 :             ReadConditions();
     641                 :          0 :             long nVecPos = nScrollPos + nRow;
     642         [ #  # ]:          0 :             if ( nVecPos < (long)maConditions.size() )
     643                 :            :             {
     644 [ #  # ][ #  # ]:          0 :                 maConditions.erase( maConditions.begin() + nVecPos );
     645                 :          0 :                 ShowConditions();
     646                 :            : 
     647 [ #  # ][ #  # ]:          0 :                 if ( bHadFocus && !pBtn->IsEnabled() )
                 [ #  # ]
     648                 :            :                 {
     649                 :            :                     // If the button is disabled, focus would normally move to the next control,
     650                 :            :                     // (left edit of the next row). Move it to left edit of this row instead.
     651                 :            : 
     652                 :          0 :                     mpEdActive = mpLeftEdit[nRow];
     653                 :          0 :                     mpEdActive->GrabFocus();
     654                 :            :                 }
     655                 :            :             }
     656                 :            :         }
     657                 :            : 
     658                 :          0 :     return 0;
     659                 :            : }
     660                 :            : 
     661                 :            : //----------------------------------------------------------------------------
     662                 :            : 
     663                 :          0 : IMPL_LINK_NOARG(ScOptSolverDlg, TargetModifyHdl)
     664                 :            : {
     665                 :            :     // modify handler for the target edit:
     666                 :            :     //  select "Value of" if something is input into the edit
     667         [ #  # ]:          0 :     if ( maEdTargetValue.GetText().Len() )
     668                 :          0 :         maRbValue.Check();
     669                 :          0 :     return 0;
     670                 :            : }
     671                 :            : 
     672                 :          0 : IMPL_LINK_NOARG(ScOptSolverDlg, CondModifyHdl)
     673                 :            : {
     674                 :            :     // modify handler for the condition edits, just to enable/disable "delete" buttons
     675                 :          0 :     ReadConditions();
     676                 :          0 :     EnableButtons();
     677                 :          0 :     return 0;
     678                 :            : }
     679                 :            : 
     680                 :          0 : IMPL_LINK_NOARG(ScOptSolverDlg, SelectHdl)
     681                 :            : {
     682                 :            :     // select handler for operator list boxes, just to enable/disable "delete" buttons
     683                 :          0 :     ReadConditions();
     684                 :          0 :     EnableButtons();
     685                 :          0 :     return 0;
     686                 :            : }
     687                 :            : 
     688                 :          0 : IMPL_LINK_NOARG(ScOptSolverDlg, ScrollHdl)
     689                 :            : {
     690                 :          0 :     ReadConditions();
     691                 :          0 :     nScrollPos = maScrollBar.GetThumbPos();
     692                 :          0 :     ShowConditions();
     693         [ #  # ]:          0 :     if( mpEdActive )
     694         [ #  # ]:          0 :         mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
     695                 :          0 :     return 0;
     696                 :            : }
     697                 :            : 
     698                 :          0 : IMPL_LINK( ScOptSolverDlg, CursorUpHdl, ScCursorRefEdit*, pEdit )
     699                 :            : {
     700 [ #  # ][ #  # ]:          0 :     if ( pEdit == mpLeftEdit[0] || pEdit == mpRightEdit[0] )
     701                 :            :     {
     702         [ #  # ]:          0 :         if ( nScrollPos > 0 )
     703                 :            :         {
     704                 :          0 :             ReadConditions();
     705                 :          0 :             --nScrollPos;
     706                 :          0 :             ShowConditions();
     707         [ #  # ]:          0 :             if( mpEdActive )
     708         [ #  # ]:          0 :                 mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
     709                 :            :         }
     710                 :            :     }
     711                 :            :     else
     712                 :            :     {
     713                 :          0 :         formula::RefEdit* pFocus = NULL;
     714         [ #  # ]:          0 :         for ( sal_uInt16 nRow = 1; nRow < EDIT_ROW_COUNT; ++nRow )      // second row or below: move focus
     715                 :            :         {
     716         [ #  # ]:          0 :             if ( pEdit == mpLeftEdit[nRow] )
     717                 :          0 :                 pFocus = mpLeftEdit[nRow-1];
     718         [ #  # ]:          0 :             else if ( pEdit == mpRightEdit[nRow] )
     719                 :          0 :                 pFocus = mpRightEdit[nRow-1];
     720                 :            :         }
     721         [ #  # ]:          0 :         if (pFocus)
     722                 :            :         {
     723                 :          0 :             mpEdActive = pFocus;
     724                 :          0 :             pFocus->GrabFocus();
     725                 :            :         }
     726                 :            :     }
     727                 :            : 
     728                 :          0 :     return 0;
     729                 :            : }
     730                 :            : 
     731                 :          0 : IMPL_LINK( ScOptSolverDlg, CursorDownHdl, ScCursorRefEdit*, pEdit )
     732                 :            : {
     733 [ #  # ][ #  # ]:          0 :     if ( pEdit == mpLeftEdit[EDIT_ROW_COUNT-1] || pEdit == mpRightEdit[EDIT_ROW_COUNT-1] )
     734                 :            :     {
     735                 :            :         //! limit scroll position?
     736                 :          0 :         ReadConditions();
     737                 :          0 :         ++nScrollPos;
     738                 :          0 :         ShowConditions();
     739         [ #  # ]:          0 :         if( mpEdActive )
     740         [ #  # ]:          0 :             mpEdActive->SetSelection( Selection( 0, SELECTION_MAX ) );
     741                 :            :     }
     742                 :            :     else
     743                 :            :     {
     744                 :          0 :         formula::RefEdit* pFocus = NULL;
     745         [ #  # ]:          0 :         for ( sal_uInt16 nRow = 0; nRow+1 < EDIT_ROW_COUNT; ++nRow )      // before last row: move focus
     746                 :            :         {
     747         [ #  # ]:          0 :             if ( pEdit == mpLeftEdit[nRow] )
     748                 :          0 :                 pFocus = mpLeftEdit[nRow+1];
     749         [ #  # ]:          0 :             else if ( pEdit == mpRightEdit[nRow] )
     750                 :          0 :                 pFocus = mpRightEdit[nRow+1];
     751                 :            :         }
     752         [ #  # ]:          0 :         if (pFocus)
     753                 :            :         {
     754                 :          0 :             mpEdActive = pFocus;
     755                 :          0 :             pFocus->GrabFocus();
     756                 :            :         }
     757                 :            :     }
     758                 :            : 
     759                 :          0 :     return 0;
     760                 :            : }
     761                 :            : 
     762                 :            : //----------------------------------------------------------------------------
     763                 :            : 
     764                 :          0 : void ScOptSolverDlg::ShowError( bool bCondition, formula::RefEdit* pFocus )
     765                 :            : {
     766 [ #  # ][ #  # ]:          0 :     String aMessage = bCondition ? maConditionError : maInputError;
     767 [ #  # ][ #  # ]:          0 :     ErrorBox( this, WinBits( WB_OK | WB_DEF_OK ), aMessage ).Execute();
                 [ #  # ]
     768         [ #  # ]:          0 :     if (pFocus)
     769                 :            :     {
     770                 :          0 :         mpEdActive = pFocus;
     771         [ #  # ]:          0 :         pFocus->GrabFocus();
     772         [ #  # ]:          0 :     }
     773                 :          0 : }
     774                 :            : 
     775                 :            : //----------------------------------------------------------------------------
     776                 :            : 
     777                 :          0 : bool ScOptSolverDlg::ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange )
     778                 :            : {
     779                 :          0 :     ScRangeUtil aRangeUtil;
     780         [ #  # ]:          0 :     ScAddress::Details aDetails(mpDoc->GetAddressConvention(), 0, 0);
     781         [ #  # ]:          0 :     sal_uInt16 nFlags = rRange.ParseAny( rInput, mpDoc, aDetails );
     782         [ #  # ]:          0 :     if ( nFlags & SCA_VALID )
     783                 :            :     {
     784         [ #  # ]:          0 :         if ( (nFlags & SCA_TAB_3D) == 0 )
     785                 :          0 :             rRange.aStart.SetTab( mnCurTab );
     786         [ #  # ]:          0 :         if ( (nFlags & SCA_TAB2_3D) == 0 )
     787                 :          0 :             rRange.aEnd.SetTab( rRange.aStart.Tab() );
     788 [ #  # ][ #  # ]:          0 :         return ( bAllowRange || rRange.aStart == rRange.aEnd );
     789                 :            :     }
     790 [ #  # ][ #  # ]:          0 :     else if ( aRangeUtil.MakeRangeFromName( rInput, mpDoc, mnCurTab, rRange, RUTL_NAMES, aDetails ) )
     791 [ #  # ][ #  # ]:          0 :         return ( bAllowRange || rRange.aStart == rRange.aEnd );
     792                 :            : 
     793                 :          0 :     return false;   // not recognized
     794                 :            : }
     795                 :            : 
     796                 :          0 : bool ScOptSolverDlg::FindTimeout( sal_Int32& rTimeout )
     797                 :            : {
     798                 :          0 :     bool bFound = false;
     799                 :            : 
     800         [ #  # ]:          0 :     if ( !maProperties.getLength() )
     801 [ #  # ][ #  # ]:          0 :         maProperties = ScSolverUtil::GetDefaults( maEngine );   // get property defaults from component
                 [ #  # ]
     802                 :            : 
     803                 :          0 :     sal_Int32 nPropCount = maProperties.getLength();
     804 [ #  # ][ #  # ]:          0 :     for (sal_Int32 nProp=0; nProp<nPropCount && !bFound; ++nProp)
                 [ #  # ]
     805                 :            :     {
     806                 :          0 :         const beans::PropertyValue& rValue = maProperties[nProp];
     807         [ #  # ]:          0 :         if ( rValue.Name == SC_UNONAME_TIMEOUT )
     808                 :          0 :             bFound = ( rValue.Value >>= rTimeout );
     809                 :            :     }
     810                 :          0 :     return bFound;
     811                 :            : }
     812                 :            : 
     813                 :          0 : bool ScOptSolverDlg::CallSolver()       // return true -> close dialog after calling
     814                 :            : {
     815                 :            :     // show progress dialog
     816                 :            : 
     817         [ #  # ]:          0 :     ScSolverProgressDialog aProgress( this );
     818                 :          0 :     sal_Int32 nTimeout = 0;
     819 [ #  # ][ #  # ]:          0 :     if ( FindTimeout( nTimeout ) )
     820         [ #  # ]:          0 :         aProgress.SetTimeLimit( nTimeout );
     821                 :            :     else
     822         [ #  # ]:          0 :         aProgress.HideTimeLimit();
     823         [ #  # ]:          0 :     aProgress.Show();
     824         [ #  # ]:          0 :     aProgress.Update();
     825         [ #  # ]:          0 :     aProgress.Sync();
     826                 :            :     // try to make sure the progress dialog is painted before continuing
     827         [ #  # ]:          0 :     Application::Reschedule(true);
     828                 :            : 
     829                 :            :     // collect solver parameters
     830                 :            : 
     831         [ #  # ]:          0 :     ReadConditions();
     832                 :            : 
     833 [ #  # ][ #  # ]:          0 :     uno::Reference<sheet::XSpreadsheetDocument> xDocument( mpDocShell->GetModel(), uno::UNO_QUERY );
     834                 :            : 
     835                 :          0 :     ScRange aObjRange;
     836 [ #  # ][ #  # ]:          0 :     if ( !ParseRef( aObjRange, maEdObjectiveCell.GetText(), false ) )
         [ #  # ][ #  # ]
     837                 :            :     {
     838         [ #  # ]:          0 :         ShowError( false, &maEdObjectiveCell );
     839                 :          0 :         return false;
     840                 :            :     }
     841                 :          0 :     table::CellAddress aObjective( aObjRange.aStart.Tab(), aObjRange.aStart.Col(), aObjRange.aStart.Row() );
     842                 :            : 
     843                 :            :     // "changing cells" can be several ranges
     844         [ #  # ]:          0 :     ScRangeList aVarRanges;
     845 [ #  # ][ #  # ]:          0 :     if ( !ParseWithNames( aVarRanges, maEdVariableCells.GetText(), mpDoc ) )
         [ #  # ][ #  # ]
     846                 :            :     {
     847         [ #  # ]:          0 :         ShowError( false, &maEdVariableCells );
     848                 :          0 :         return false;
     849                 :            :     }
     850         [ #  # ]:          0 :     uno::Sequence<table::CellAddress> aVariables;
     851                 :          0 :     sal_Int32 nVarPos = 0;
     852                 :            : 
     853 [ #  # ][ #  # ]:          0 :     for ( size_t nRangePos=0, nRange = aVarRanges.size(); nRangePos < nRange; ++nRangePos )
     854                 :            :     {
     855         [ #  # ]:          0 :         ScRange aRange(*aVarRanges[ nRangePos ] );
     856         [ #  # ]:          0 :         aRange.Justify();
     857                 :          0 :         SCTAB nTab = aRange.aStart.Tab();
     858                 :            : 
     859                 :            :         // resolve into single cells
     860                 :            : 
     861                 :          0 :         sal_Int32 nAdd = ( aRange.aEnd.Col() - aRange.aStart.Col() + 1 ) *
     862                 :          0 :                          ( aRange.aEnd.Row() - aRange.aStart.Row() + 1 );
     863         [ #  # ]:          0 :         aVariables.realloc( nVarPos + nAdd );
     864                 :            : 
     865         [ #  # ]:          0 :         for (SCROW nRow = aRange.aStart.Row(); nRow <= aRange.aEnd.Row(); ++nRow)
     866         [ #  # ]:          0 :             for (SCCOL nCol = aRange.aStart.Col(); nCol <= aRange.aEnd.Col(); ++nCol)
     867         [ #  # ]:          0 :                 aVariables[nVarPos++] = table::CellAddress( nTab, nCol, nRow );
     868                 :            :     }
     869                 :            : 
     870         [ #  # ]:          0 :     uno::Sequence<sheet::SolverConstraint> aConstraints;
     871                 :          0 :     sal_Int32 nConstrPos = 0;
     872 [ #  # ][ #  # ]:          0 :     for ( std::vector<ScOptConditionRow>::const_iterator aConstrIter = maConditions.begin();
                 [ #  # ]
     873                 :          0 :           aConstrIter != maConditions.end(); ++aConstrIter )
     874                 :            :     {
     875         [ #  # ]:          0 :         if ( aConstrIter->aLeftStr.Len() )
     876                 :            :         {
     877                 :          0 :             sheet::SolverConstraint aConstraint;
     878                 :            :             // order of list box entries must match enum values
     879                 :          0 :             aConstraint.Operator = static_cast<sheet::SolverConstraintOperator>(aConstrIter->nOperator);
     880                 :            : 
     881                 :          0 :             ScRange aLeftRange;
     882 [ #  # ][ #  # ]:          0 :             if ( !ParseRef( aLeftRange, aConstrIter->aLeftStr, true ) )
     883                 :            :             {
     884         [ #  # ]:          0 :                 ShowError( true, NULL );
     885                 :          0 :                 return false;
     886                 :            :             }
     887                 :            : 
     888                 :          0 :             bool bIsRange = false;
     889                 :          0 :             ScRange aRightRange;
     890 [ #  # ][ #  # ]:          0 :             if ( ParseRef( aRightRange, aConstrIter->aRightStr, true ) )
     891                 :            :             {
     892         [ #  # ]:          0 :                 if ( aRightRange.aStart == aRightRange.aEnd )
     893                 :          0 :                     aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
     894         [ #  # ]:          0 :                                                               aRightRange.aStart.Col(), aRightRange.aStart.Row() );
     895   [ #  #  #  # ]:          0 :                 else if ( aRightRange.aEnd.Col()-aRightRange.aStart.Col() == aLeftRange.aEnd.Col()-aLeftRange.aStart.Col() &&
                 [ #  # ]
     896                 :          0 :                           aRightRange.aEnd.Row()-aRightRange.aStart.Row() == aLeftRange.aEnd.Row()-aLeftRange.aStart.Row() )
     897                 :          0 :                     bIsRange = true;    // same size as "left" range, resolve into single cells
     898                 :            :                 else
     899                 :            :                 {
     900         [ #  # ]:          0 :                     ShowError( true, NULL );
     901                 :          0 :                     return false;
     902                 :            :                 }
     903                 :            :             }
     904                 :            :             else
     905                 :            :             {
     906                 :          0 :                 sal_uInt32 nFormat = 0;     //! explicit language?
     907                 :          0 :                 double fValue = 0.0;
     908 [ #  # ][ #  # ]:          0 :                 if ( mpDoc->GetFormatTable()->IsNumberFormat( aConstrIter->aRightStr, nFormat, fValue ) )
                 [ #  # ]
     909         [ #  # ]:          0 :                     aConstraint.Right <<= fValue;
     910 [ #  # ][ #  # ]:          0 :                 else if ( aConstraint.Operator != sheet::SolverConstraintOperator_INTEGER &&
     911                 :            :                           aConstraint.Operator != sheet::SolverConstraintOperator_BINARY )
     912                 :            :                 {
     913         [ #  # ]:          0 :                     ShowError( true, NULL );
     914                 :          0 :                     return false;
     915                 :            :                 }
     916                 :            :             }
     917                 :            : 
     918                 :            :             // resolve into single cells
     919                 :            : 
     920                 :          0 :             sal_Int32 nAdd = ( aLeftRange.aEnd.Col() - aLeftRange.aStart.Col() + 1 ) *
     921                 :          0 :                              ( aLeftRange.aEnd.Row() - aLeftRange.aStart.Row() + 1 );
     922         [ #  # ]:          0 :             aConstraints.realloc( nConstrPos + nAdd );
     923                 :            : 
     924         [ #  # ]:          0 :             for (SCROW nRow = aLeftRange.aStart.Row(); nRow <= aLeftRange.aEnd.Row(); ++nRow)
     925         [ #  # ]:          0 :                 for (SCCOL nCol = aLeftRange.aStart.Col(); nCol <= aLeftRange.aEnd.Col(); ++nCol)
     926                 :            :                 {
     927                 :          0 :                     aConstraint.Left = table::CellAddress( aLeftRange.aStart.Tab(), nCol, nRow );
     928         [ #  # ]:          0 :                     if ( bIsRange )
     929                 :          0 :                         aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
     930                 :          0 :                             aRightRange.aStart.Col() + ( nCol - aLeftRange.aStart.Col() ),
     931         [ #  # ]:          0 :                             aRightRange.aStart.Row() + ( nRow - aLeftRange.aStart.Row() ) );
     932                 :            : 
     933         [ #  # ]:          0 :                     aConstraints[nConstrPos++] = aConstraint;
     934         [ #  # ]:          0 :                 }
     935                 :            :         }
     936                 :            :     }
     937                 :            : 
     938                 :          0 :     sal_Bool bMaximize = maRbMax.IsChecked();
     939         [ #  # ]:          0 :     if ( maRbValue.IsChecked() )
     940                 :            :     {
     941                 :            :         // handle "value of" with an additional constraint (and then minimize)
     942                 :            : 
     943                 :          0 :         sheet::SolverConstraint aConstraint;
     944                 :          0 :         aConstraint.Left     = aObjective;
     945                 :          0 :         aConstraint.Operator = sheet::SolverConstraintOperator_EQUAL;
     946                 :            : 
     947         [ #  # ]:          0 :         String aValStr = maEdTargetValue.GetText();
     948                 :          0 :         ScRange aRightRange;
     949 [ #  # ][ #  # ]:          0 :         if ( ParseRef( aRightRange, aValStr, false ) )
     950                 :          0 :             aConstraint.Right <<= table::CellAddress( aRightRange.aStart.Tab(),
     951         [ #  # ]:          0 :                                                       aRightRange.aStart.Col(), aRightRange.aStart.Row() );
     952                 :            :         else
     953                 :            :         {
     954                 :          0 :             sal_uInt32 nFormat = 0;     //! explicit language?
     955                 :          0 :             double fValue = 0.0;
     956 [ #  # ][ #  # ]:          0 :             if ( mpDoc->GetFormatTable()->IsNumberFormat( aValStr, nFormat, fValue ) )
                 [ #  # ]
     957         [ #  # ]:          0 :                 aConstraint.Right <<= fValue;
     958                 :            :             else
     959                 :            :             {
     960         [ #  # ]:          0 :                 ShowError( false, &maEdTargetValue );
     961                 :          0 :                 return false;
     962                 :            :             }
     963                 :            :         }
     964                 :            : 
     965         [ #  # ]:          0 :         aConstraints.realloc( nConstrPos + 1 );
     966 [ #  # ][ #  # ]:          0 :         aConstraints[nConstrPos++] = aConstraint;
         [ #  # ][ #  # ]
     967                 :            :     }
     968                 :            : 
     969                 :            :     // copy old document values
     970                 :            : 
     971                 :          0 :     sal_Int32 nVarCount = aVariables.getLength();
     972         [ #  # ]:          0 :     uno::Sequence<double> aOldValues;
     973         [ #  # ]:          0 :     aOldValues.realloc( nVarCount );
     974         [ #  # ]:          0 :     for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
     975                 :            :     {
     976                 :          0 :         ScAddress aCellPos;
     977         [ #  # ]:          0 :         ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
     978 [ #  # ][ #  # ]:          0 :         aOldValues[nVarPos] = mpDoc->GetValue( aCellPos );
     979                 :            :     }
     980                 :            : 
     981                 :            :     // create and initialize solver
     982                 :            : 
     983 [ #  # ][ #  # ]:          0 :     uno::Reference<sheet::XSolver> xSolver = ScSolverUtil::GetSolver( maEngine );
                 [ #  # ]
     984                 :            :     OSL_ENSURE( xSolver.is(), "can't get solver component" );
     985         [ #  # ]:          0 :     if ( !xSolver.is() )
     986                 :          0 :         return false;
     987                 :            : 
     988 [ #  # ][ #  # ]:          0 :     xSolver->setDocument( xDocument );
     989 [ #  # ][ #  # ]:          0 :     xSolver->setObjective( aObjective );
     990 [ #  # ][ #  # ]:          0 :     xSolver->setVariables( aVariables );
     991 [ #  # ][ #  # ]:          0 :     xSolver->setConstraints( aConstraints );
     992 [ #  # ][ #  # ]:          0 :     xSolver->setMaximize( bMaximize );
     993                 :            : 
     994                 :            :     // set options
     995         [ #  # ]:          0 :     uno::Reference<beans::XPropertySet> xOptProp(xSolver, uno::UNO_QUERY);
     996         [ #  # ]:          0 :     if ( xOptProp.is() )
     997                 :            :     {
     998                 :          0 :         sal_Int32 nPropCount = maProperties.getLength();
     999         [ #  # ]:          0 :         for (sal_Int32 nProp=0; nProp<nPropCount; ++nProp)
    1000                 :            :         {
    1001         [ #  # ]:          0 :             const beans::PropertyValue& rValue = maProperties[nProp];
    1002                 :            :             try
    1003                 :            :             {
    1004 [ #  # ][ #  # ]:          0 :                 xOptProp->setPropertyValue( rValue.Name, rValue.Value );
    1005                 :            :             }
    1006         [ #  # ]:          0 :             catch ( uno::Exception & )
    1007                 :            :             {
    1008                 :            :                 OSL_FAIL("Exception in solver option property");
    1009                 :            :             }
    1010                 :            :         }
    1011                 :            :     }
    1012                 :            : 
    1013 [ #  # ][ #  # ]:          0 :     xSolver->solve();
    1014 [ #  # ][ #  # ]:          0 :     sal_Bool bSuccess = xSolver->getSuccess();
    1015                 :            : 
    1016         [ #  # ]:          0 :     aProgress.Hide();
    1017                 :          0 :     bool bClose = false;
    1018                 :          0 :     bool bRestore = true;   // restore old values unless a solution is accepted
    1019         [ #  # ]:          0 :     if ( bSuccess )
    1020                 :            :     {
    1021                 :            :         // put solution into document so it is visible when asking
    1022 [ #  # ][ #  # ]:          0 :         uno::Sequence<double> aSolution = xSolver->getSolution();
    1023         [ #  # ]:          0 :         if ( aSolution.getLength() == nVarCount )
    1024                 :            :         {
    1025         [ #  # ]:          0 :             mpDocShell->LockPaint();
    1026                 :          0 :             ScDocFunc &rFunc = mpDocShell->GetDocFunc();
    1027         [ #  # ]:          0 :             for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
    1028                 :            :             {
    1029                 :          0 :                 ScAddress aCellPos;
    1030         [ #  # ]:          0 :                 ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
    1031 [ #  # ][ #  # ]:          0 :                 rFunc.PutCell( aCellPos, new ScValueCell( aSolution[nVarPos] ), sal_True );
         [ #  # ][ #  # ]
    1032                 :            :             }
    1033         [ #  # ]:          0 :             mpDocShell->UnlockPaint();
    1034                 :            :         }
    1035                 :            :         //! else error?
    1036                 :            : 
    1037                 :            :         // take formatted result from document (result value from component is ignored)
    1038         [ #  # ]:          0 :         String aResultStr;
    1039         [ #  # ]:          0 :         mpDoc->GetString( (SCCOL)aObjective.Column, (SCROW)aObjective.Row, (SCTAB)aObjective.Sheet, aResultStr );
    1040         [ #  # ]:          0 :         ScSolverSuccessDialog aDialog( this, aResultStr );
    1041 [ #  # ][ #  # ]:          0 :         if ( aDialog.Execute() == RET_OK )
    1042                 :            :         {
    1043                 :            :             // keep results and close dialog
    1044                 :          0 :             bRestore = false;
    1045                 :          0 :             bClose = true;
    1046 [ #  # ][ #  # ]:          0 :         }
                 [ #  # ]
    1047                 :            :     }
    1048                 :            :     else
    1049                 :            :     {
    1050                 :          0 :         rtl::OUString aError;
    1051         [ #  # ]:          0 :         uno::Reference<sheet::XSolverDescription> xDesc( xSolver, uno::UNO_QUERY );
    1052         [ #  # ]:          0 :         if ( xDesc.is() )
    1053 [ #  # ][ #  # ]:          0 :             aError = xDesc->getStatusDescription();         // error description from component
    1054 [ #  # ][ #  # ]:          0 :         ScSolverNoSolutionDialog aDialog( this, aError );
                 [ #  # ]
    1055 [ #  # ][ #  # ]:          0 :         aDialog.Execute();
    1056                 :            :     }
    1057                 :            : 
    1058         [ #  # ]:          0 :     if ( bRestore )         // restore old values
    1059                 :            :     {
    1060         [ #  # ]:          0 :         mpDocShell->LockPaint();
    1061                 :          0 :         ScDocFunc &rFunc = mpDocShell->GetDocFunc();
    1062         [ #  # ]:          0 :         for (nVarPos=0; nVarPos<nVarCount; ++nVarPos)
    1063                 :            :         {
    1064                 :          0 :             ScAddress aCellPos;
    1065         [ #  # ]:          0 :             ScUnoConversion::FillScAddress( aCellPos, aVariables[nVarPos] );
    1066 [ #  # ][ #  # ]:          0 :             rFunc.PutCell( aCellPos, new ScValueCell( aOldValues[nVarPos] ), sal_True );
         [ #  # ][ #  # ]
    1067                 :            :         }
    1068         [ #  # ]:          0 :         mpDocShell->UnlockPaint();
    1069                 :            :     }
    1070                 :            : 
    1071 [ #  # ][ #  # ]:          0 :     return bClose;
         [ #  # ][ #  # ]
                 [ #  # ]
    1072                 :            : }
    1073                 :            : 
    1074                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10