Avoid potential negative array index access to cached text.
[LibreOffice.git] / formula / source / ui / dlg / parawin.hxx
blobb2fe7ece621e93ff0ba18f3c5e805ec5b96b18c5
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 .
20 #pragma once
22 #include <formula/funcutl.hxx>
23 #include <vcl/weld.hxx>
24 #include "ControlHelper.hxx"
25 #include <vector>
27 namespace formula
30 #define NOT_FOUND 0xffff
32 class IFunctionDescription;
33 class IControlReferenceHandler;
35 class ParaWin
37 private:
38 Link<ParaWin&,void> aFxLink;
39 Link<ParaWin&,void> aArgModifiedLink;
41 ::std::vector<sal_uInt16> aVisibleArgMapping;
42 const IFunctionDescription* pFuncDesc;
43 IControlReferenceHandler* pMyParent;
44 sal_uInt16 nArgs; // unsuppressed arguments, may be >= VAR_ARGS to indicate repeating parameters
45 sal_uInt16 nMaxArgs; // max arguments, limited to supported number of arguments
46 vcl::Font aFntBold;
47 vcl::Font aFntLight;
49 OUString m_sOptional;
50 OUString m_sRequired;
52 sal_uInt16 nEdFocus;
53 sal_uInt16 nActiveLine;
55 ArgInput aArgInput[4];
56 OUString aDefaultString;
57 ::std::vector<OUString> aParaArray;
59 std::unique_ptr<weld::Builder> m_xBuilder;
60 std::unique_ptr<weld::Container> m_xContainer;
62 std::unique_ptr<weld::ScrolledWindow> m_xSlider;
63 std::unique_ptr<weld::Widget> m_xParamGrid;
64 std::unique_ptr<weld::Widget> m_xGrid;
66 std::unique_ptr<weld::Label> m_xFtEditDesc;
67 std::unique_ptr<weld::Label> m_xFtArgName;
68 std::unique_ptr<weld::Label> m_xFtArgDesc;
70 std::unique_ptr<weld::Button> m_xBtnFx1;
71 std::unique_ptr<weld::Button> m_xBtnFx2;
72 std::unique_ptr<weld::Button> m_xBtnFx3;
73 std::unique_ptr<weld::Button> m_xBtnFx4;
75 std::unique_ptr<weld::Label> m_xFtArg1;
76 std::unique_ptr<weld::Label> m_xFtArg2;
77 std::unique_ptr<weld::Label> m_xFtArg3;
78 std::unique_ptr<weld::Label> m_xFtArg4;
80 std::unique_ptr<ArgEdit> m_xEdArg1;
81 std::unique_ptr<ArgEdit> m_xEdArg2;
82 std::unique_ptr<ArgEdit> m_xEdArg3;
83 std::unique_ptr<ArgEdit> m_xEdArg4;
85 std::unique_ptr<RefButton> m_xRefBtn1;
86 std::unique_ptr<RefButton> m_xRefBtn2;
87 std::unique_ptr<RefButton> m_xRefBtn3;
88 std::unique_ptr<RefButton> m_xRefBtn4;
90 DECL_LINK( ScrollHdl, weld::ScrolledWindow&, void);
91 DECL_LINK( ModifyHdl, ArgInput&, void );
92 DECL_LINK( GetEdFocusHdl, ArgInput&, void );
93 DECL_LINK( GetFxFocusHdl, ArgInput&, void );
94 DECL_LINK( GetFxHdl, ArgInput&, void );
96 void ArgumentModified();
98 void InitArgInput(sal_uInt16 nPos, weld::Label& rFtArg, weld::Button& rBtnFx,
99 ArgEdit& rEdArg, RefButton& rRefBtn);
101 void SetArgumentDesc(const OUString& aText);
102 void SetArgumentText(const OUString& aText);
105 void SetArgName (sal_uInt16 no,const OUString &aArg);
106 void SetArgNameFont (sal_uInt16 no,const vcl::Font&);
108 void UpdateArgDesc( sal_uInt16 nArg );
109 void UpdateArgInput( sal_uInt16 nOffset, sal_uInt16 i );
111 public:
112 ParaWin(weld::Container* pParent, IControlReferenceHandler* _pDlg);
113 ~ParaWin();
115 void SetFunctionDesc(const IFunctionDescription* pFDesc);
116 void SetArgumentOffset(sal_uInt16 nOffset);
117 void SetEditDesc(const OUString& aText);
118 void UpdateParas();
119 void ClearAll();
121 sal_uInt16 GetActiveLine() const { return nActiveLine;}
122 void SetActiveLine(sal_uInt16 no);
123 RefEdit* GetActiveEdit();
124 OUString GetActiveArgName() const;
126 OUString GetArgument(sal_uInt16 no);
127 void SetArgument(sal_uInt16 no, std::u16string_view aString);
128 void SetArgumentFonts(const vcl::Font& aBoldFont,const vcl::Font& aLightFont);
130 void SetEdFocus(); // visible edit lines
131 sal_uInt16 GetSliderPos() const;
132 void SetSliderPos(sal_uInt16 nSliderPos);
134 void SetArgModifiedHdl( const Link<ParaWin&,void>& rLink ) { aArgModifiedLink = rLink; }
135 void SetFxHdl( const Link<ParaWin&,void>& rLink ) { aFxLink = rLink; }
137 void SliderMoved();
139 void Show() { m_xContainer->show(); }
143 } // formula
145 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */