LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sc/source/ui/inc - optsolver.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 15 0.0 %
Date: 2013-07-09 Functions: 0 19 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( Window* pParent, Window *pLabel );
      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*       m_pFtObjectiveCell;
     110             :     formula::RefEdit*    m_pEdObjectiveCell;
     111             :     formula::RefButton*  m_pRBObjectiveCell;
     112             : 
     113             :     RadioButton*     m_pRbMax;
     114             :     RadioButton*     m_pRbMin;
     115             :     RadioButton*     m_pRbValue;
     116             :     formula::RefEdit*   m_pEdTargetValue;
     117             :     formula::RefButton* m_pRBTargetValue;
     118             : 
     119             :     FixedText*       m_pFtVariableCells;
     120             :     formula::RefEdit*   m_pEdVariableCells;
     121             :     formula::RefButton* m_pRBVariableCells;
     122             : 
     123             :     FixedText*       m_pFtCellRef; // labels are together with controls for the first row
     124             :     ScCursorRefEdit* m_pEdLeft1;
     125             :     formula::RefButton* m_pRBLeft1;
     126             :     FixedText*       m_pFtOperator;
     127             :     ListBox*         m_pLbOp1;
     128             :     FixedText*       m_pFtConstraint;
     129             :     ScCursorRefEdit* m_pEdRight1;
     130             :     formula::RefButton* m_pRBRight1;
     131             :     PushButton*      m_pBtnDel1;
     132             : 
     133             :     ScCursorRefEdit* m_pEdLeft2;
     134             :     formula::RefButton* m_pRBLeft2;
     135             :     ListBox*         m_pLbOp2;
     136             :     ScCursorRefEdit* m_pEdRight2;
     137             :     formula::RefButton* m_pRBRight2;
     138             :     PushButton*      m_pBtnDel2;
     139             : 
     140             :     ScCursorRefEdit* m_pEdLeft3;
     141             :     formula::RefButton* m_pRBLeft3;
     142             :     ListBox*         m_pLbOp3;
     143             :     ScCursorRefEdit* m_pEdRight3;
     144             :     formula::RefButton* m_pRBRight3;
     145             :     PushButton*      m_pBtnDel3;
     146             : 
     147             :     ScCursorRefEdit* m_pEdLeft4;
     148             :     formula::RefButton* m_pRBLeft4;
     149             :     ListBox*         m_pLbOp4;
     150             :     ScCursorRefEdit* m_pEdRight4;
     151             :     formula::RefButton* m_pRBRight4;
     152             :     PushButton*      m_pBtnDel4;
     153             : 
     154             :     ScrollBar*       m_pScrollBar;
     155             : 
     156             :     PushButton*      m_pBtnOpt;
     157             :     PushButton*      m_pBtnCancel;
     158             :     PushButton*      m_pBtnSolve;
     159             : 
     160             :     String          maInputError;
     161             :     String          maConditionError;
     162             : 
     163             :     ScDocShell*     mpDocShell;
     164             :     ScDocument*     mpDoc;
     165             :     const SCTAB     mnCurTab;
     166             :     formula::RefEdit*      mpEdActive;
     167             :     bool            mbDlgLostFocus;
     168             : 
     169             :     static const sal_uInt16 EDIT_ROW_COUNT = 4;
     170             :     ScCursorRefEdit* mpLeftEdit[EDIT_ROW_COUNT];
     171             :     formula::RefButton*     mpLeftButton[EDIT_ROW_COUNT];
     172             :     ScCursorRefEdit* mpRightEdit[EDIT_ROW_COUNT];
     173             :     formula::RefButton*     mpRightButton[EDIT_ROW_COUNT];
     174             :     ListBox*         mpOperator[EDIT_ROW_COUNT];
     175             :     PushButton*      mpDelButton[EDIT_ROW_COUNT];
     176             : 
     177             :     std::vector<ScOptConditionRow> maConditions;
     178             :     long            nScrollPos;
     179             : 
     180             :     com::sun::star::uno::Sequence<OUString> maImplNames;
     181             :     com::sun::star::uno::Sequence<OUString> maDescriptions;
     182             :     String          maEngine;
     183             :     com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> maProperties;
     184             : 
     185             :     void    Init(const ScAddress& rCursorPos);
     186             :     bool    CallSolver();
     187             :     void    ReadConditions();
     188             :     void    ShowConditions();
     189             :     void    EnableButtons();
     190             :     bool    ParseRef( ScRange& rRange, const String& rInput, bool bAllowRange );
     191             :     bool    FindTimeout( sal_Int32& rTimeout );
     192             :     void    ShowError( bool bCondition, formula::RefEdit* pFocus );
     193             : 
     194             :     DECL_LINK( BtnHdl, PushButton* );
     195             :     DECL_LINK( DelBtnHdl, PushButton* );
     196             :     DECL_LINK( GetFocusHdl, Control* );
     197             :     DECL_LINK( LoseFocusHdl, void* );
     198             :     DECL_LINK(ScrollHdl, void *);
     199             :     DECL_LINK( CursorUpHdl, ScCursorRefEdit* );
     200             :     DECL_LINK( CursorDownHdl, ScCursorRefEdit* );
     201             :     DECL_LINK( CondModifyHdl, void* );
     202             :     DECL_LINK( TargetModifyHdl, void* );
     203             :     DECL_LINK( SelectHdl, void* );
     204             : };
     205             : 
     206             : 
     207             : class ScSolverProgressDialog : public ModelessDialog
     208             : {
     209             :     FixedText       maFtProgress;
     210             :     FixedText       maFtTime;
     211             :     FixedLine       maFlButtons;
     212             :     OKButton        maBtnOk;
     213             : 
     214             : public:
     215             :     ScSolverProgressDialog( Window* pParent );
     216             :     ~ScSolverProgressDialog();
     217             : 
     218             :     void    HideTimeLimit();
     219             :     void    SetTimeLimit( sal_Int32 nSeconds );
     220             : };
     221             : 
     222             : class ScSolverNoSolutionDialog : public ModalDialog
     223             : {
     224             :     FixedText       maFtNoSolution;
     225             :     FixedText       maFtErrorText;
     226             :     FixedLine       maFlButtons;
     227             :     OKButton        maBtnOk;
     228             : 
     229             : public:
     230             :     ScSolverNoSolutionDialog( Window* pParent, const String& rErrorText );
     231             :     ~ScSolverNoSolutionDialog();
     232             : };
     233             : 
     234             : class ScSolverSuccessDialog : public ModalDialog
     235             : {
     236             :     FixedText       maFtSuccess;
     237             :     FixedText       maFtResult;
     238             :     FixedText       maFtQuestion;
     239             :     FixedLine       maFlButtons;
     240             :     OKButton        maBtnOk;
     241             :     CancelButton    maBtnCancel;
     242             : 
     243             : public:
     244             :     ScSolverSuccessDialog( Window* pParent, const String& rSolution );
     245             :     ~ScSolverSuccessDialog();
     246             : };
     247             : 
     248             : 
     249             : #endif
     250             : 
     251             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10