Avoid potential negative array index access to cached text.
[LibreOffice.git] / extensions / source / scanner / sanedlg.hxx
blobe9ba1540dab557c7515b13caf59f8b62f767914b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #pragma once
21 #include <vcl/customweld.hxx>
22 #include <vcl/weld.hxx>
24 #include "sane.hxx"
26 class ScanPreview;
28 class SaneDlg : public weld::GenericDialogController
30 private:
31 weld::Window* mpParent;
32 Sane& mrSane;
33 bool mbScanEnabled;
35 Link<Sane&,void> maOldLink;
37 int mnCurrentOption;
38 int mnCurrentElement;
39 std::unique_ptr<double[]> mpRange;
40 double mfMin, mfMax;
42 bool doScan;
44 std::unique_ptr<weld::Button> mxCancelButton;
45 std::unique_ptr<weld::Button> mxDeviceInfoButton;
46 std::unique_ptr<weld::Button> mxPreviewButton;
47 std::unique_ptr<weld::Button> mxScanButton;
48 std::unique_ptr<weld::Button> mxButtonOption;
50 std::unique_ptr<weld::Label> mxOptionTitle;
51 std::unique_ptr<weld::Label> mxOptionDescTxt;
52 std::unique_ptr<weld::Label> mxVectorTxt;
54 std::unique_ptr<weld::MetricSpinButton> mxLeftField;
55 std::unique_ptr<weld::MetricSpinButton> mxTopField;
56 std::unique_ptr<weld::MetricSpinButton> mxRightField;
57 std::unique_ptr<weld::MetricSpinButton> mxBottomField;
59 std::unique_ptr<weld::ComboBox> mxDeviceBox;
60 std::unique_ptr<weld::ComboBox> mxReslBox;
61 std::unique_ptr<weld::CheckButton> mxAdvancedBox;
63 std::unique_ptr<weld::SpinButton> mxVectorBox;
64 std::unique_ptr<weld::ComboBox> mxQuantumRangeBox;
65 std::unique_ptr<weld::ComboBox> mxStringRangeBox;
67 std::unique_ptr<weld::CheckButton> mxBoolCheckBox;
69 std::unique_ptr<weld::Entry> mxStringEdit;
70 std::unique_ptr<weld::Entry> mxNumericEdit;
72 std::unique_ptr<weld::TreeView> mxOptionBox;
74 std::unique_ptr<ScanPreview> mxPreview;
75 std::unique_ptr<weld::CustomWeld> mxPreviewWnd;
77 DECL_LINK( ClickBtnHdl, weld::Button&, void );
78 DECL_LINK( ToggleBtnHdl, weld::Toggleable&, void );
79 DECL_LINK( SelectHdl, weld::ComboBox&, void );
80 DECL_LINK( ModifyHdl, weld::Entry&, void );
81 DECL_LINK( MetricValueModifyHdl, weld::MetricSpinButton&, void );
82 DECL_LINK( ValueModifyHdl, weld::ComboBox&, void );
83 DECL_LINK( ReloadSaneOptionsHdl, Sane&, void );
84 DECL_LINK( OptionsBoxSelectHdl, weld::TreeView&, void );
86 void SaveState();
87 bool LoadState();
89 void InitDevices();
90 void InitFields();
91 void AcquirePreview();
92 void DisableOption();
93 void EstablishBoolOption();
94 void EstablishStringOption();
95 void EstablishStringRange();
96 void EstablishQuantumRange();
97 void EstablishNumericOption();
98 void EstablishButtonOption();
100 // helper
101 bool SetAdjustedNumericalValue( const char* pOption, double fValue, int nElement = 0 );
102 public:
103 SaneDlg(weld::Window*, Sane&, bool);
104 virtual ~SaneDlg() override;
106 virtual short run() override;
107 void UpdateScanArea( bool );
108 bool getDoScan() const { return doScan;}
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */