xref: /trunk/main/formula/inc/formula/formula.hxx (revision 5116778e)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef FORMULA_FORMULA_HXX
25 #define FORMULA_FORMULA_HXX
26 
27 #include <sfx2/basedlgs.hxx>
28 // #include "formula/funcutl.hxx"
29 #include <memory>
30 #include "formula/formuladllapi.h"
31 
32 namespace formula
33 {
34 //============================================================================
35 #define STRUCT_END    1
36 #define STRUCT_FOLDER 2
37 #define STRUCT_ERROR  3
38 
39 #define STRUCT_ERR_C1 1
40 #define STRUCT_ERR_C2 2
41 
42 enum FormulaDlgMode { FORMULA_FORMDLG_FORMULA, FORMULA_FORMDLG_ARGS, FORMULA_FORMDLG_EDIT };
43 
44 //============================================================================
45 
46 class IFormulaEditorHelper;
47 class FormulaDlg_Impl;
48 class IControlReferenceHandler;
49 class IFunctionDescription;
50 class IFunctionManager;
51 class FormulaHelper;
52 class RefEdit;
53 class RefButton;
54 //============================================================================
55 class FORMULA_DLLPUBLIC FormulaModalDialog :   public ModalDialog
56 {
57     friend class FormulaDlg_Impl;
58 public:
59 					FormulaModalDialog( Window* pParent
60                                             , bool _bSupportFunctionResult
61                                             , bool _bSupportResult
62                                             , bool _bSupportMatrix
63                                             ,IFormulaEditorHelper* _pHelper
64                                             ,IFunctionManager* _pFunctionMgr
65                                             ,IControlReferenceHandler* _pDlg = NULL );
66 					virtual ~FormulaModalDialog();
67 private:
68     ::std::auto_ptr<FormulaDlg_Impl> m_pImpl;
69 
70 protected:
71     void            disableOk();
72 
73 protected:
74 
75 	virtual long	PreNotify( NotifyEvent& rNEvt );
76 	::std::pair<RefButton*,RefEdit*> RefInputStartBefore( RefEdit* pEdit, RefButton* pButton = NULL );
77     void	        RefInputStartAfter( RefEdit* pEdit, RefButton* pButton = NULL );
78 	void	        RefInputDoneAfter( sal_Bool bForced = sal_False );
79 	rtl::OString    FindFocusWin(Window *pWin);
80 	void			SetFocusWin(Window *pWin,const rtl::OString& nUniqueId);
81 	void			HighlightFunctionParas(const String& aFormula);
82 
83     void            SetMeText(const String& _sText);
84     FormulaDlgMode SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,sal_Bool bMatrix,sal_Bool _bSelect,sal_Bool _bUpdate);
85     void            Update();
86     sal_Bool            CheckMatrix(String& aFormula /*IN/OUT*/);
87     String          GetMeText() const;
88     void            Update(const String& _sExp);
89     void            CheckMatrix();
90     void            DoEnter(sal_Bool _bOk);
91     sal_Bool            isUserMatrix() const;
92     const IFunctionDescription*	getCurrentFunctionDescription() const;
93     sal_Bool            UpdateParaWin(Selection& _rSelection);
94     void            UpdateParaWin(const Selection& _rSelection,const String& _sRefStr);
95     RefEdit*	    GetActiveEdit();
96     void            SetEdSelection();
97 
98     const FormulaHelper& GetFormulaHelper() const;
99 };
100 
101 class FORMULA_DLLPUBLIC FormulaDlg :   public SfxModelessDialog
102 {
103     friend class FormulaDlg_Impl;
104 public:
105 					FormulaDlg( SfxBindings* pB
106                                     , SfxChildWindow* pCW
107 									, Window* pParent
108                                     , bool _bSupportFunctionResult
109                                     , bool _bSupportResult
110                                     , bool _bSupportMatrix
111                                     , IFormulaEditorHelper* _pHelper
112                                     , IFunctionManager* _pFunctionMgr
113                                     , IControlReferenceHandler* _pDlg = NULL );
114 					virtual ~FormulaDlg();
115 private:
116     ::std::auto_ptr<FormulaDlg_Impl> m_pImpl;
117 
118     DECL_LINK( UpdateFocusHdl, Timer*);
119 protected:
120     void            disableOk();
121 
122 protected:
123 
124 	virtual long	PreNotify( NotifyEvent& rNEvt );
125 	::std::pair<RefButton*,RefEdit*> RefInputStartBefore( RefEdit* pEdit, RefButton* pButton = NULL );
126     void	        RefInputStartAfter( RefEdit* pEdit, RefButton* pButton = NULL );
127 	void	        RefInputDoneAfter( sal_Bool bForced = sal_False );
128 	rtl::OString    FindFocusWin(Window *pWin);
129 	void			SetFocusWin(Window *pWin,const rtl::OString& nUniqueId);
130 	void			HighlightFunctionParas(const String& aFormula);
131 
132     void            SetMeText(const String& _sText);
133     FormulaDlgMode SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,sal_Bool bMatrix,sal_Bool _bSelect,sal_Bool _bUpdate);
134     void            Update();
135     sal_Bool            CheckMatrix(String& aFormula /*IN/OUT*/);
136     String          GetMeText() const;
137     void            Update(const String& _sExp);
138     void            CheckMatrix();
139     void            DoEnter(sal_Bool _bOk);
140     sal_Bool            isUserMatrix() const;
141     const IFunctionDescription*	getCurrentFunctionDescription() const;
142     sal_Bool            UpdateParaWin(Selection& _rSelection);
143     void            UpdateParaWin(const Selection& _rSelection,const String& _sRefStr);
144     RefEdit*	    GetActiveEdit();
145     void            SetEdSelection();
146 
147     const FormulaHelper& GetFormulaHelper() const;
148 };
149 
150 } // formula
151 
152 #endif // FORMULA_FORMULA_HXX
153 
154