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 */ 10 11 #pragma once 12 13 #include <sal/config.h> 14 15 #include <optional> 16 17 #include <address.hxx> 18 #include "anyrefdg.hxx" 19 #include "viewdata.hxx" 20 21 class ScRandomNumberGeneratorDialog : public ScAnyRefDlgController 22 { 23 public: 24 ScRandomNumberGeneratorDialog( 25 SfxBindings* pB, SfxChildWindow* pCW, 26 weld::Window* pParent, ScViewData& rViewData ); 27 28 virtual ~ScRandomNumberGeneratorDialog() override; 29 30 virtual void SetReference( const ScRange& rRef, ScDocument& rDoc ) override; 31 virtual void SetActive() override; 32 virtual void Close() override; 33 34 private: 35 // Data 36 ScViewData& mrViewData; 37 const ScDocument& mrDoc; 38 39 ScRange maInputRange; 40 41 bool mbDialogLostFocus; 42 43 // Widgets 44 std::unique_ptr<weld::Label> mxInputRangeText; 45 std::unique_ptr<formula::RefEdit> mxInputRangeEdit; 46 std::unique_ptr<formula::RefButton> mxInputRangeButton; 47 std::unique_ptr<weld::ComboBox> mxDistributionCombo; 48 std::unique_ptr<weld::Label> mxParameter1Text; 49 std::unique_ptr<weld::SpinButton> mxParameter1Value; 50 std::unique_ptr<weld::Label> mxParameter2Text; 51 std::unique_ptr<weld::SpinButton> mxParameter2Value; 52 std::unique_ptr<weld::SpinButton> mxSeed; 53 std::unique_ptr<weld::CheckButton> mxEnableSeed; 54 std::unique_ptr<weld::SpinButton> mxDecimalPlaces; 55 std::unique_ptr<weld::CheckButton> mxEnableRounding; 56 std::unique_ptr<weld::Button> mxButtonApply; 57 std::unique_ptr<weld::Button> mxButtonOk; 58 std::unique_ptr<weld::Button> mxButtonClose; 59 60 void Init(); 61 void GetRangeFromSelection(); 62 63 template<class RNG> 64 65 void GenerateNumbers(RNG& randomGenerator, const char* pDistributionStringId, const std::optional<sal_Int8> aDecimalPlaces); 66 67 void SelectGeneratorAndGenerateNumbers(); 68 69 DECL_LINK( OkClicked, weld::Button&, void ); 70 DECL_LINK( CloseClicked, weld::Button&, void ); 71 DECL_LINK( ApplyClicked, weld::Button&, void ); 72 DECL_LINK( GetEditFocusHandler, formula::RefEdit&, void ); 73 DECL_LINK( GetButtonFocusHandler, formula::RefButton&, void ); 74 DECL_LINK( LoseEditFocusHandler, formula::RefEdit&, void ); 75 DECL_LINK( LoseButtonFocusHandler, formula::RefButton&, void ); 76 77 DECL_LINK( InputRangeModified, formula::RefEdit&, void ); 78 DECL_LINK( Parameter1ValueModified, weld::SpinButton&, void ); 79 DECL_LINK( Parameter2ValueModified, weld::SpinButton&, void ); 80 DECL_LINK( DistributionChanged, weld::ComboBox&, void ); 81 DECL_LINK( CheckChanged, weld::Toggleable&, void ); 82 83 }; 84 85 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 86