/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #ifndef INCLUDED_SC_SOURCE_UI_INC_OPTSOLVER_HXX #define INCLUDED_SC_SOURCE_UI_INC_OPTSOLVER_HXX #include "global.hxx" #include "address.hxx" #include "anyrefdg.hxx" #include #include #include #include #include namespace com { namespace sun { namespace star { namespace beans { struct PropertyValue; } } } } class ScCursorRefEdit : public formula::RefEdit { Link maCursorUpLink; Link maCursorDownLink; public: ScCursorRefEdit( vcl::Window* pParent, vcl::Window *pLabel ); void SetCursorLinks( const Link& rUp, const Link& rDown ); protected: virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE; }; /// The dialog's content for a row, not yet parsed struct ScOptConditionRow { OUString aLeftStr; sal_uInt16 nOperator; OUString aRightStr; ScOptConditionRow() : nOperator(0) {} bool IsDefault() const { return aLeftStr.isEmpty() && aRightStr.isEmpty() && nOperator == 0; } }; /// All settings from the dialog, saved with the DocShell for the next call class ScOptSolverSave { OUString maObjective; bool mbMax; bool mbMin; bool mbValue; OUString maTarget; OUString maVariable; std::vector maConditions; OUString maEngine; com::sun::star::uno::Sequence maProperties; public: ScOptSolverSave( const OUString& rObjective, bool bMax, bool bMin, bool bValue, const OUString& rTarget, const OUString& rVariable, const std::vector& rConditions, const OUString& rEngine, const com::sun::star::uno::Sequence& rProperties ); const OUString& GetObjective() const { return maObjective; } bool GetMax() const { return mbMax; } bool GetMin() const { return mbMin; } bool GetValue() const { return mbValue; } const OUString& GetTarget() const { return maTarget; } const OUString& GetVariable() const { return maVariable; } const std::vector& GetConditions() const { return maConditions; } const OUString& GetEngine() const { return maEngine; } const com::sun::star::uno::Sequence& GetProperties() const { return maProperties; } }; class ScOptSolverDlg : public ScAnyRefDlg { public: ScOptSolverDlg( SfxBindings* pB, SfxChildWindow* pCW, vcl::Window* pParent, ScDocShell* pDocSh, ScAddress aCursorPos ); virtual ~ScOptSolverDlg(); virtual void dispose() SAL_OVERRIDE; virtual void SetReference( const ScRange& rRef, ScDocument* pDoc ) SAL_OVERRIDE; virtual bool IsRefInputMode() const SAL_OVERRIDE; virtual void SetActive() SAL_OVERRIDE; virtual bool Close() SAL_OVERRIDE; private: VclPtr m_pFtObjectiveCell; VclPtr m_pEdObjectiveCell; VclPtr m_pRBObjectiveCell; VclPtr m_pRbMax; VclPtr m_pRbMin; VclPtr m_pRbValue; VclPtr m_pEdTargetValue; VclPtr m_pRBTargetValue; VclPtr m_pFtVariableCells; VclPtr m_pEdVariableCells; VclPtr m_pRBVariableCells; VclPtr m_pFtCellRef; // labels are together with controls for the first row VclPtr m_pEdLeft1; VclPtr m_pRBLeft1; VclPtr m_pFtOperator; VclPtr m_pLbOp1; VclPtr m_pFtConstraint; VclPtr m_pEdRight1; VclPtr m_pRBRight1; VclPtr m_pBtnDel1; VclPtr m_pEdLeft2; VclPtr m_pRBLeft2; VclPtr m_pLbOp2; VclPtr m_pEdRight2; VclPtr m_pRBRight2; VclPtr m_pBtnDel2; VclPtr m_pEdLeft3; VclPtr m_pRBLeft3; VclPtr m_pLbOp3; VclPtr m_pEdRight3; VclPtr m_pRBRight3; VclPtr m_pBtnDel3; VclPtr m_pEdLeft4; VclPtr m_pRBLeft4; VclPtr m_pLbOp4; VclPtr m_pEdRight4; VclPtr m_pRBRight4; VclPtr m_pBtnDel4; VclPtr m_pScrollBar; VclPtr m_pBtnOpt; VclPtr m_pBtnCancel; VclPtr m_pBtnSolve; OUString maInputError; OUString maConditionError; ScDocShell* mpDocShell; ScDocument& mrDoc; const SCTAB mnCurTab; VclPtr mpEdActive; bool mbDlgLostFocus; static const sal_uInt16 EDIT_ROW_COUNT = 4; VclPtr mpLeftEdit[EDIT_ROW_COUNT]; VclPtr mpLeftButton[EDIT_ROW_COUNT]; VclPtr mpRightEdit[EDIT_ROW_COUNT]; VclPtr mpRightButton[EDIT_ROW_COUNT]; VclPtr mpOperator[EDIT_ROW_COUNT]; VclPtr mpDelButton[EDIT_ROW_COUNT]; std::vector maConditions; long nScrollPos; com::sun::star::uno::Sequence maImplNames; com::sun::star::uno::Sequence maDescriptions; OUString maEngine; com::sun::star::uno::Sequence maProperties; void Init(const ScAddress& rCursorPos); bool CallSolver(); void ReadConditions(); void ShowConditions(); void EnableButtons(); bool ParseRef( ScRange& rRange, const OUString& rInput, bool bAllowRange ); bool FindTimeout( sal_Int32& rTimeout ); void ShowError( bool bCondition, formula::RefEdit* pFocus ); DECL_LINK( BtnHdl, PushButton* ); DECL_LINK( DelBtnHdl, PushButton* ); DECL_LINK( GetFocusHdl, Control* ); DECL_LINK( LoseFocusHdl, void* ); DECL_LINK(ScrollHdl, void *); DECL_LINK( CursorUpHdl, ScCursorRefEdit* ); DECL_LINK( CursorDownHdl, ScCursorRefEdit* ); DECL_LINK( CondModifyHdl, void* ); DECL_LINK( TargetModifyHdl, void* ); DECL_LINK( SelectHdl, void* ); }; class ScSolverProgressDialog : public ModelessDialog { VclPtr m_pFtTime; public: ScSolverProgressDialog( vcl::Window* pParent ); virtual ~ScSolverProgressDialog(); virtual void dispose() SAL_OVERRIDE; void HideTimeLimit(); void SetTimeLimit( sal_Int32 nSeconds ); }; class ScSolverNoSolutionDialog : public ModalDialog { VclPtr m_pFtErrorText; public: ScSolverNoSolutionDialog(vcl::Window* pParent, const OUString& rErrorText); virtual ~ScSolverNoSolutionDialog(); virtual void dispose() SAL_OVERRIDE; }; class ScSolverSuccessDialog : public ModalDialog { VclPtr m_pFtResult; VclPtr m_pBtnOk; VclPtr m_pBtnCancel; DECL_LINK(ClickHdl, PushButton*); public: ScSolverSuccessDialog( vcl::Window* pParent, const OUString& rSolution ); virtual ~ScSolverSuccessDialog(); virtual void dispose() SAL_OVERRIDE; }; #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */