1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef INCLUDED_FORMULA_FORMULA_HXX
21 #define INCLUDED_FORMULA_FORMULA_HXX
23 #include <sfx2/basedlgs.hxx>
25 #include <formula/formuladllapi.h>
26 #include <formula/omoduleclient.hxx>
27 #include <formula/IFunctionDescription.hxx>
31 //============================================================================
33 #define STRUCT_FOLDER 2
34 #define STRUCT_ERROR 3
36 enum FormulaDlgMode
{ FORMULA_FORMDLG_FORMULA
, FORMULA_FORMDLG_ARGS
, FORMULA_FORMDLG_EDIT
};
38 //============================================================================
40 class FormulaDlg_Impl
;
41 class IControlReferenceHandler
;
42 class IFunctionDescription
;
43 class IFunctionManager
;
48 //============================================================================
49 class FORMULA_DLLPUBLIC FormulaModalDialog
: public ModalDialog
, public formula::IFormulaEditorHelper
51 friend class FormulaDlg_Impl
;
53 FormulaModalDialog( Window
* pParent
54 , bool _bSupportFunctionResult
55 , bool _bSupportResult
56 , bool _bSupportMatrix
57 ,IFunctionManager
* _pFunctionMgr
58 ,IControlReferenceHandler
* _pDlg
= NULL
);
59 virtual ~FormulaModalDialog();
61 SAL_WNODEPRECATED_DECLARATIONS_PUSH
62 ::std::auto_ptr
<FormulaDlg_Impl
> m_pImpl
;
63 SAL_WNODEPRECATED_DECLARATIONS_POP
67 virtual long PreNotify( NotifyEvent
& rNEvt
);
68 ::std::pair
<RefButton
*,RefEdit
*> RefInputStartBefore( RefEdit
* pEdit
, RefButton
* pButton
= NULL
);
69 void RefInputStartAfter( RefEdit
* pEdit
, RefButton
* pButton
= NULL
);
70 void RefInputDoneAfter( sal_Bool bForced
= sal_False
);
71 void SetFocusWin(Window
*pWin
,const OString
& nUniqueId
);
73 void SetMeText(const OUString
& _sText
);
75 sal_Bool
CheckMatrix(OUString
& aFormula
/*IN/OUT*/);
76 void Update(const OUString
& _sExp
);
78 void StoreFormEditData(FormEditData
* pData
);
81 class FORMULA_DLLPUBLIC FormulaDlg
:
82 private OModuleClient
, public SfxModelessDialog
, public IFormulaEditorHelper
83 // order of base classes is important, as OModuleClient controls the
84 // lifecycle of the ResMgr passed into SfxModelessDialog (via
85 // formula::ModuleRes), and at least with DBG_UTIL calling TestRes in
86 // ~Resource, the ResMgr must outlive the Resource (from which
87 // SfxModelessDialog ultimately derives)
89 friend class FormulaDlg_Impl
;
91 FormulaDlg( SfxBindings
* pB
94 , bool _bSupportFunctionResult
95 , bool _bSupportResult
96 , bool _bSupportMatrix
97 , IFunctionManager
* _pFunctionMgr
98 , IControlReferenceHandler
* _pDlg
= NULL
);
99 virtual ~FormulaDlg();
101 SAL_WNODEPRECATED_DECLARATIONS_PUSH
102 ::std::auto_ptr
<FormulaDlg_Impl
> m_pImpl
;
103 SAL_WNODEPRECATED_DECLARATIONS_POP
105 DECL_LINK( UpdateFocusHdl
, void*);
111 virtual long PreNotify( NotifyEvent
& rNEvt
);
112 ::std::pair
<RefButton
*,RefEdit
*> RefInputStartBefore( RefEdit
* pEdit
, RefButton
* pButton
= NULL
);
113 void RefInputStartAfter( RefEdit
* pEdit
, RefButton
* pButton
= NULL
);
114 void RefInputDoneAfter( sal_Bool bForced
= sal_False
);
115 void SetFocusWin(Window
*pWin
,const OString
& nUniqueId
);
116 void HighlightFunctionParas(const OUString
& aFormula
);
118 void SetMeText(const OUString
& _sText
);
119 FormulaDlgMode
SetMeText(const OUString
& _sText
,xub_StrLen PrivStart
, xub_StrLen PrivEnd
, sal_Bool bMatrix
, sal_Bool _bSelect
, sal_Bool _bUpdate
);
121 sal_Bool
CheckMatrix(OUString
& aFormula
/*IN/OUT*/);
122 OUString
GetMeText() const;
123 void Update(const OUString
& _sExp
);
125 void DoEnter(sal_Bool _bOk
);
126 const IFunctionDescription
* getCurrentFunctionDescription() const;
127 sal_Bool
UpdateParaWin(Selection
& _rSelection
);
128 void UpdateParaWin(const Selection
& _rSelection
, const OUString
& _sRefStr
);
129 RefEdit
* GetActiveEdit();
130 void SetEdSelection();
132 void StoreFormEditData(FormEditData
* pData
);
134 const FormulaHelper
& GetFormulaHelper() const;
139 #endif // INCLUDED_FORMULA_FORMULA_HXX
141 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */