LCOV - code coverage report
Current view: top level - libreoffice/sc/source/ui/inc - optsolver.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2012-12-27 Functions: 0 18 0.0 %
Legend: Lines: hit not hit

          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             : #ifndef SC_OPTSOLVER_HXX
      21             : #define SC_OPTSOLVER_HXX
      22             : 
      23             : #include "global.hxx"
      24             : #include "address.hxx"
      25             : #include "anyrefdg.hxx"
      26             : #include <vcl/fixed.hxx>
      27             : #include <vcl/group.hxx>
      28             : #include <vcl/lstbox.hxx>
      29             : #include <com/sun/star/uno/Sequence.hxx>
      30             : 
      31             : #include <vector>
      32             : 
      33             : namespace com { namespace sun { namespace star {
      34             :     namespace beans { struct PropertyValue; }
      35             : } } }
      36             : 
      37             : //============================================================================
      38             : 
      39           0 : class ScCursorRefEdit : public formula::RefEdit
      40             : {
      41             :     Link    maCursorUpLink;
      42             :     Link    maCursorDownLink;
      43             : 
      44             : public:
      45             :             ScCursorRefEdit( ScAnyRefDlg* pParent, const ResId& rResId );
      46             :     void    SetCursorLinks( const Link& rUp, const Link& rDown );
      47             : 
      48             : protected:
      49             :     virtual void    KeyInput( const KeyEvent& rKEvt );
      50             : };
      51             : 
      52             : 
      53             : /// The dialog's content for a row, not yet parsed
      54           0 : struct ScOptConditionRow
      55             : {
      56             :     String  aLeftStr;
      57             :     sal_uInt16  nOperator;
      58             :     String  aRightStr;
      59             : 
      60           0 :     ScOptConditionRow() : nOperator(0) {}
      61           0 :     bool IsDefault() const { return aLeftStr.Len() == 0 && aRightStr.Len() == 0 && nOperator == 0; }
      62             : };
      63             : 
      64             : /// All settings from the dialog, saved with the DocShell for the next call
      65           0 : class ScOptSolverSave
      66             : {
      67             :     String  maObjective;
      68             :     sal_Bool    mbMax;
      69             :     sal_Bool    mbMin;
      70             :     sal_Bool    mbValue;
      71             :     String  maTarget;
      72             :     String  maVariable;
      73             :     std::vector<ScOptConditionRow> maConditions;
      74             :     String  maEngine;
      75             :     com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maProperties;
      76             : 
      77             : public:
      78             :             ScOptSolverSave( const String& rObjective, sal_Bool bMax, sal_Bool bMin, sal_Bool bValue,
      79             :                              const String& rTarget, const String& rVariable,
      80             :                              const std::vector<ScOptConditionRow>& rConditions,
      81             :                              const String& rEngine,
      82             :                              const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rProperties );
      83             : 
      84           0 :     const String&   GetObjective() const    { return maObjective; }
      85           0 :     sal_Bool            GetMax() const          { return mbMax; }
      86           0 :     sal_Bool            GetMin() const          { return mbMin; }
      87           0 :     sal_Bool            GetValue() const        { return mbValue; }
      88           0 :     const String&   GetTarget() const       { return maTarget; }
      89           0 :     const String&   GetVariable() const     { return maVariable; }
      90           0 :     const std::vector<ScOptConditionRow>& GetConditions() const { return maConditions; }
      91           0 :     const String&   GetEngine() const       { return maEngine; }
      92           0 :     const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& GetProperties() const
      93           0 :                                             { return maProperties; }
      94             : };
      95             : 
      96             : class ScOptSolverDlg : public ScAnyRefDlg
      97             : {
      98             : public:
      99             :                     ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
     100             :                                  ScDocShell* pDocSh, ScAddress aCursorPos );
     101             :                     ~ScOptSolverDlg();
     102             : 
     103             :     virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc );
     104             :     virtual sal_Bool    IsRefInputMode() const;
     105             :     virtual void    SetActive();
     106             :     virtual sal_Bool    Close();
     107             : 
     108             : private:
     109             :     FixedText       maFtObjectiveCell;
     110             :     formula::RefEdit       maEdObjectiveCell;
     111             :     formula::RefButton     maRBObjectiveCell;
     112             : 
     113             :     FixedText       maFtDirection;
     114             :     RadioButton     maRbMax;
     115             :     RadioButton     maRbMin;
     116             :     RadioButton     maRbValue;
     117             :     formula::RefEdit       maEdTargetValue;
     118             :     formula::RefButton     maRBTargetValue;
     119             : 
     120             :     FixedText       maFtVariableCells;
     121             :     formula::RefEdit       maEdVariableCells;
     122             :     formula::RefButton     maRBVariableCells;
     123             : 
     124             :     FixedLine       maFlConditions;
     125             : 
     126             :     FixedText       maFtCellRef;        // labels are together with controls for the first row
     127             :     ScCursorRefEdit maEdLeft1;
     128             :     formula::RefButton     maRBLeft1;
     129             :     FixedText       maFtOperator;
     130             :     ListBox         maLbOp1;
     131             :     FixedText       maFtConstraint;
     132             :     ScCursorRefEdit maEdRight1;
     133             :     formula::RefButton     maRBRight1;
     134             :     ImageButton     maBtnDel1;
     135             : 
     136             :     ScCursorRefEdit maEdLeft2;
     137             :     formula::RefButton     maRBLeft2;
     138             :     ListBox         maLbOp2;
     139             :     ScCursorRefEdit maEdRight2;
     140             :     formula::RefButton     maRBRight2;
     141             :     ImageButton     maBtnDel2;
     142             : 
     143             :     ScCursorRefEdit maEdLeft3;
     144             :     formula::RefButton     maRBLeft3;
     145             :     ListBox         maLbOp3;
     146             :     ScCursorRefEdit maEdRight3;
     147             :     formula::RefButton     maRBRight3;
     148             :     ImageButton     maBtnDel3;
     149             : 
     150             :     ScCursorRefEdit maEdLeft4;
     151             :     formula::RefButton     maRBLeft4;
     152             :     ListBox         maLbOp4;
     153             :     ScCursorRefEdit maEdRight4;
     154             :     formula::RefButton     maRBRight4;
     155             :     ImageButton     maBtnDel4;
     156             : 
     157             :     ScrollBar       maScrollBar;
     158             : 
     159             :     FixedLine       maFlButtons;
     160             : 
     161             :     PushButton      maBtnOpt;
     162             :     HelpButton      maBtnHelp;
     163             :     CancelButton    maBtnCancel;
     164             :     PushButton      maBtnSolve;
     165             : 
     166             :     String          maInputError;
     167             :     String          maConditionError;
     168             : 
     169             :     ScDocShell*     mpDocShell;
     170             :     ScDocument*     mpDoc;
     171             :     const SCTAB     mnCurTab;
     172             :     formula::RefEdit*      mpEdActive;
     173             :     bool            mbDlgLostFocus;
     174             : 
     175             :     static const sal_uInt16 EDIT_ROW_COUNT = 4;
     176             :     ScCursorRefEdit* mpLeftEdit[EDIT_ROW_COUNT];
     177             :     formula::RefButton*     mpLeftButton[EDIT_ROW_COUNT];
     178             :     ScCursorRefEdit* mpRightEdit[EDIT_ROW_COUNT];
     179             :     formula::RefButton*     mpRightButton[EDIT_ROW_COUNT];
     180             :     ListBox*         mpOperator[EDIT_ROW_COUNT];
     181             :     ImageButton*     mpDelButton[EDIT_ROW_COUNT];
     182             : 
     183             :     std::vector<ScOptConditionRow> maConditions;
     184             :     long            nScrollPos;
     185             : 
     186             :     com::sun::star::uno::Sequence<rtl::OUString> maImplNames;
     187             :     com::sun::star::uno::Sequence<rtl::OUString> maDescriptions;
     188             :     String          maEngine;
     189             :     com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maProperties;
     190             : 
     191             :     void    Init(const ScAddress& rCursorPos);
     192             :     bool    CallSolver();
     193             :     void    ReadConditions();
     194             :     void    ShowConditions();
     195             :     void    EnableButtons();
     196             :     bool    ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange );
     197             :     bool    FindTimeout( sal_Int32& rTimeout );
     198             :     void    ShowError( bool bCondition, formula::RefEdit* pFocus );
     199             : 
     200             :     DECL_LINK( BtnHdl, PushButton* );
     201             :     DECL_LINK( DelBtnHdl, PushButton* );
     202             :     DECL_LINK( GetFocusHdl, Control* );
     203             :     DECL_LINK( LoseFocusHdl, void* );
     204             :     DECL_LINK(ScrollHdl, void *);
     205             :     DECL_LINK( CursorUpHdl, ScCursorRefEdit* );
     206             :     DECL_LINK( CursorDownHdl, ScCursorRefEdit* );
     207             :     DECL_LINK( CondModifyHdl, void* );
     208             :     DECL_LINK( TargetModifyHdl, void* );
     209             :     DECL_LINK( SelectHdl, void* );
     210             : };
     211             : 
     212             : 
     213             : class ScSolverProgressDialog : public ModelessDialog
     214             : {
     215             :     FixedText       maFtProgress;
     216             :     FixedText       maFtTime;
     217             :     FixedLine       maFlButtons;
     218             :     OKButton        maBtnOk;
     219             : 
     220             : public:
     221             :     ScSolverProgressDialog( Window* pParent );
     222             :     ~ScSolverProgressDialog();
     223             : 
     224             :     void    HideTimeLimit();
     225             :     void    SetTimeLimit( sal_Int32 nSeconds );
     226             : };
     227             : 
     228             : class ScSolverNoSolutionDialog : public ModalDialog
     229             : {
     230             :     FixedText       maFtNoSolution;
     231             :     FixedText       maFtErrorText;
     232             :     FixedLine       maFlButtons;
     233             :     OKButton        maBtnOk;
     234             : 
     235             : public:
     236             :     ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText );
     237             :     ~ScSolverNoSolutionDialog();
     238             : };
     239             : 
     240             : class ScSolverSuccessDialog : public ModalDialog
     241             : {
     242             :     FixedText       maFtSuccess;
     243             :     FixedText       maFtResult;
     244             :     FixedText       maFtQuestion;
     245             :     FixedLine       maFlButtons;
     246             :     OKButton        maBtnOk;
     247             :     CancelButton    maBtnCancel;
     248             : 
     249             : public:
     250             :     ScSolverSuccessDialog( Window* pParent, const String& rSolution );
     251             :     ~ScSolverSuccessDialog();
     252             : };
     253             : 
     254             : 
     255             : #endif
     256             : 
     257             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10