summaryrefslogtreecommitdiff
path: root/formula/source/ui
diff options
context:
space:
mode:
Diffstat (limited to 'formula/source/ui')
-rw-r--r--formula/source/ui/dlg/ControlHelper.hxx193
-rw-r--r--formula/source/ui/dlg/FormulaHelper.cxx406
-rw-r--r--formula/source/ui/dlg/formdlgs.hrc80
-rw-r--r--formula/source/ui/dlg/formdlgs.src536
-rw-r--r--formula/source/ui/dlg/formula.cxx2236
-rw-r--r--formula/source/ui/dlg/funcpage.cxx265
-rw-r--r--formula/source/ui/dlg/funcpage.hxx123
-rw-r--r--formula/source/ui/dlg/funcutl.cxx1106
-rw-r--r--formula/source/ui/dlg/makefile.mk66
-rw-r--r--formula/source/ui/dlg/parawin.cxx600
-rw-r--r--formula/source/ui/dlg/parawin.hrc54
-rw-r--r--formula/source/ui/dlg/parawin.hxx174
-rw-r--r--formula/source/ui/dlg/parawin.src189
-rw-r--r--formula/source/ui/dlg/structpg.cxx227
-rw-r--r--formula/source/ui/dlg/structpg.hxx123
-rw-r--r--formula/source/ui/inc/ForResId.hrc74
-rw-r--r--formula/source/ui/inc/ModuleHelper.hxx99
-rw-r--r--formula/source/ui/resource/ModuleHelper.cxx142
-rw-r--r--formula/source/ui/resource/makefile.mk49
19 files changed, 6742 insertions, 0 deletions
diff --git a/formula/source/ui/dlg/ControlHelper.hxx b/formula/source/ui/dlg/ControlHelper.hxx
new file mode 100644
index 000000000000..28523a24eb92
--- /dev/null
+++ b/formula/source/ui/dlg/ControlHelper.hxx
@@ -0,0 +1,193 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#ifndef FORMULA_CONTROL_HELPER_HXX_INCLUDED
+#define FORMULA_CONTROL_HELPER_HXX_INCLUDED
+
+#include "formula/funcutl.hxx"
+#include <svtools/svmedit.hxx>
+namespace formula
+{
+
+//============================================================================
+// class ValWnd
+class ValWnd : public Window
+{
+public:
+ ValWnd( Window* pParent, const ResId& rId );
+
+ void SetValue( const String& rStrVal );
+
+protected:
+ virtual void Paint( const Rectangle& rRect );
+
+private:
+ String aStrValue;
+ Rectangle aRectOut;
+};
+
+//============================================================================
+// class EditBox
+class EditBox : public Control
+{
+private:
+
+ MultiLineEdit* pMEdit;
+ Link aSelChangedLink;
+ Selection aOldSel;
+ BOOL bMouseFlag;
+ DECL_LINK( ChangedHdl, EditBox* );
+
+protected:
+
+ virtual long PreNotify( NotifyEvent& rNEvt );
+ virtual void SelectionChanged();
+ virtual void Resize();
+ virtual void GetFocus();
+
+
+public:
+ EditBox( Window* pParent,
+ WinBits nWinStyle = WB_LEFT | WB_BORDER );
+ EditBox( Window* pParent, const ResId& rResId );
+
+ virtual ~EditBox();
+
+ MultiLineEdit* GetEdit() {return pMEdit;}
+
+ void SetSelChangedHdl( const Link& rLink ) { aSelChangedLink = rLink; }
+ const Link& GetSelChangedHdl() const { return aSelChangedLink; }
+
+ void UpdateOldSel();
+};
+
+//============================================================================
+// class ArgEdit
+
+class ArgEdit : public RefEdit
+{
+public:
+ ArgEdit( Window* pParent, const ResId& rResId );
+
+ void Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit,
+ ScrollBar& rArgSlider, USHORT nArgCount );
+
+protected:
+ virtual void KeyInput( const KeyEvent& rKEvt );
+
+private:
+ ArgEdit* pEdPrev;
+ ArgEdit* pEdNext;
+ ScrollBar* pSlider;
+ USHORT nArgs;
+};
+
+
+//============================================================================
+// class ArgInput
+
+class ArgInput
+{
+private:
+
+ Link aFxClickLink;
+ Link aRefClickLink;
+ Link aFxFocusLink;
+ Link aRefFocusLink;
+ Link aEdFocusLink;
+ Link aEdModifyLink;
+
+ FixedText* pFtArg;
+ ImageButton* pBtnFx;
+ ArgEdit* pEdArg;
+ RefButton* pRefBtn;
+
+ DECL_LINK( FxBtnClickHdl, ImageButton* );
+ DECL_LINK( RefBtnClickHdl,RefButton* );
+ DECL_LINK( FxBtnFocusHdl, ImageButton* );
+ DECL_LINK( RefBtnFocusHdl,RefButton* );
+ DECL_LINK( EdFocusHdl, ArgEdit* );
+ DECL_LINK( EdModifyHdl,ArgEdit* );
+
+protected:
+
+ virtual void FxClick();
+ virtual void RefClick();
+ virtual void FxFocus();
+ virtual void RefFocus();
+ virtual void EdFocus();
+ virtual void EdModify();
+
+public:
+
+ ArgInput();
+
+ void InitArgInput ( FixedText* pftArg,
+ ImageButton* pbtnFx,
+ ArgEdit* pedArg,
+ RefButton* prefBtn);
+
+ void SetArgName(const String &aArg);
+ String GetArgName();
+ void SetArgNameFont(const Font&);
+
+ void SetArgVal(const String &aVal);
+ String GetArgVal();
+
+ void SetArgSelection (const Selection& rSel );
+ void ReplaceSelOfArg (const String& rStr );
+
+ Selection GetArgSelection();
+
+
+ ArgEdit* GetArgEdPtr() {return pEdArg;}
+
+
+ void SetFxClickHdl( const Link& rLink ) { aFxClickLink = rLink; }
+ const Link& GetFxClickHdl() const { return aFxClickLink; }
+
+ void SetRefClickHdl( const Link& rLink ) { aRefClickLink = rLink; }
+ const Link& GetRefClickHdl() const { return aRefClickLink; }
+
+ void SetFxFocusHdl( const Link& rLink ) { aFxFocusLink = rLink; }
+ const Link& GetFxFocusHdl() const { return aFxFocusLink; }
+
+ void SetRefFocusHdl( const Link& rLink ) { aRefFocusLink = rLink; }
+ const Link& GetRefFocusHdl() const { return aRefFocusLink; }
+
+ void SetEdFocusHdl( const Link& rLink ) { aEdFocusLink = rLink; }
+ const Link& GetEdFocusHdl() const { return aEdFocusLink; }
+
+ void SetEdModifyHdl( const Link& rLink ) { aEdModifyLink = rLink; }
+ const Link& GetEdModifyHdl() const { return aEdModifyLink; }
+
+ void Hide();
+ void Show();
+
+};
+
+}
+#endif // FORMULA_FORMULA_HELPER_HXX_INCLUDED
diff --git a/formula/source/ui/dlg/FormulaHelper.cxx b/formula/source/ui/dlg/FormulaHelper.cxx
new file mode 100644
index 000000000000..3adbd95d9fd1
--- /dev/null
+++ b/formula/source/ui/dlg/FormulaHelper.cxx
@@ -0,0 +1,406 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "precompiled_formula.hxx"
+
+#include "formula/formulahelper.hxx"
+#include <unotools/charclass.hxx>
+#include <unotools/syslocale.hxx>
+
+namespace formula
+{
+
+ namespace
+ {
+ //============================================================================
+ class OEmptyFunctionDescription : public IFunctionDescription
+ {
+ public:
+ OEmptyFunctionDescription(){}
+ virtual ~OEmptyFunctionDescription(){}
+
+ virtual ::rtl::OUString getFunctionName() const { return ::rtl::OUString(); }
+ virtual const IFunctionCategory* getCategory() const { return NULL; }
+ virtual ::rtl::OUString getDescription() const { return ::rtl::OUString(); }
+ virtual xub_StrLen getSuppressedArgumentCount() const { return 0; }
+ virtual ::rtl::OUString getFormula(const ::std::vector< ::rtl::OUString >& ) const { return ::rtl::OUString(); }
+ virtual void fillVisibleArgumentMapping(::std::vector<USHORT>& ) const {}
+ virtual void initArgumentInfo() const {}
+ virtual ::rtl::OUString getSignature() const { return ::rtl::OUString(); }
+ virtual long getHelpId() const { return 0; }
+ virtual sal_uInt32 getParameterCount() const { return 0; }
+ virtual ::rtl::OUString getParameterName(sal_uInt32 ) const { return ::rtl::OUString(); }
+ virtual ::rtl::OUString getParameterDescription(sal_uInt32 ) const { return ::rtl::OUString(); }
+ virtual bool isParameterOptional(sal_uInt32 ) const { return sal_False; }
+ };
+ }
+//===================================================================
+// class FormulaHelper - statische Methoden
+//===================================================================
+
+#define FUNC_NOTFOUND 0xffff
+
+FormulaHelper::FormulaHelper(const IFunctionManager* _pFunctionManager)
+ :m_pSysLocale(new SvtSysLocale)
+ ,m_pFunctionManager(_pFunctionManager)
+ ,open(_pFunctionManager->getSingleToken(IFunctionManager::eOk))
+ ,close(_pFunctionManager->getSingleToken(IFunctionManager::eClose))
+ ,sep(_pFunctionManager->getSingleToken(IFunctionManager::eSep))
+ ,arrayOpen(_pFunctionManager->getSingleToken(IFunctionManager::eArrayOpen))
+ ,arrayClose(_pFunctionManager->getSingleToken(IFunctionManager::eArrayClose))
+{
+ m_pCharClass = m_pSysLocale->GetCharClassPtr();
+}
+BOOL FormulaHelper::GetNextFunc( const String& rFormula,
+ BOOL bBack,
+ xub_StrLen& rFStart, // Ein- und Ausgabe
+ xub_StrLen* pFEnd, // = NULL
+ const IFunctionDescription** ppFDesc, // = NULL
+ ::std::vector< ::rtl::OUString>* pArgs ) const // = NULL
+{
+ BOOL bFound = FALSE;
+ xub_StrLen nOldStart = rFStart;
+ String aFname;
+
+ rFStart = GetFunctionStart( rFormula, rFStart, bBack, ppFDesc ? &aFname : NULL );
+ bFound = ( rFStart != FUNC_NOTFOUND );
+
+ if ( bFound )
+ {
+ if ( pFEnd )
+ *pFEnd = GetFunctionEnd( rFormula, rFStart );
+
+ if ( ppFDesc )
+ {
+ *ppFDesc = NULL;
+ const ::rtl::OUString sTemp( aFname );
+ const sal_uInt32 nCategoryCount = m_pFunctionManager->getCount();
+ for(sal_uInt32 j= 0; j < nCategoryCount && !*ppFDesc; ++j)
+ {
+ const IFunctionCategory* pCategory = m_pFunctionManager->getCategory(j);
+ const sal_uInt32 nCount = pCategory->getCount();
+ for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ {
+ const IFunctionDescription* pCurrent = pCategory->getFunction(i);
+ if ( pCurrent->getFunctionName().equalsIgnoreAsciiCase(sTemp) )
+ {
+ *ppFDesc = pCurrent;
+ break;
+ }
+ } // for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ }
+ if ( *ppFDesc && pArgs )
+ {
+ GetArgStrings( *pArgs,rFormula, rFStart, static_cast<USHORT>((*ppFDesc)->getParameterCount() ));
+ }
+ else
+ {
+ static OEmptyFunctionDescription s_aFunctionDescription;
+ *ppFDesc = &s_aFunctionDescription;
+ }
+ }
+ }
+ else
+ rFStart = nOldStart;
+
+ return bFound;
+}
+
+//------------------------------------------------------------------------
+
+void FormulaHelper::FillArgStrings( const String& rFormula,
+ xub_StrLen nFuncPos,
+ USHORT nArgs,
+ ::std::vector< ::rtl::OUString >& _rArgs ) const
+{
+ xub_StrLen nStart = 0;
+ xub_StrLen nEnd = 0;
+ USHORT i;
+ BOOL bLast = FALSE;
+
+ for ( i=0; i<nArgs && !bLast; i++ )
+ {
+ nStart = GetArgStart( rFormula, nFuncPos, i );
+
+ if ( i+1<nArgs ) // letztes Argument?
+ {
+ nEnd = GetArgStart( rFormula, nFuncPos, i+1 );
+
+ if ( nEnd != nStart )
+ _rArgs.push_back(rFormula.Copy( nStart, nEnd-1-nStart ));
+ else
+ _rArgs.push_back(String()), bLast = TRUE;
+ }
+ else
+ {
+ nEnd = GetFunctionEnd( rFormula, nFuncPos )-1;
+ if ( nStart < nEnd )
+ _rArgs.push_back( rFormula.Copy( nStart, nEnd-nStart ) );
+ else
+ _rArgs.push_back(String());
+ }
+ }
+
+ if ( bLast )
+ for ( ; i<nArgs; i++ )
+ _rArgs.push_back(String());
+}
+
+//------------------------------------------------------------------------
+
+void FormulaHelper::GetArgStrings( ::std::vector< ::rtl::OUString >& _rArgs
+ ,const String& rFormula,
+ xub_StrLen nFuncPos,
+ USHORT nArgs ) const
+{
+ if (nArgs)
+ {
+ FillArgStrings( rFormula, nFuncPos, nArgs, _rArgs );
+ }
+}
+
+//------------------------------------------------------------------------
+
+inline BOOL IsFormulaText( const CharClass* _pCharClass,const String& rStr, xub_StrLen nPos )
+{
+ if( _pCharClass->isLetterNumeric( rStr, nPos ) )
+ return TRUE;
+ else
+ { // In internationalized versions function names may contain a dot
+ // and in every version also an underscore... ;-)
+ sal_Unicode c = rStr.GetChar(nPos);
+ return c == '.' || c == '_';
+ }
+
+}
+
+xub_StrLen FormulaHelper::GetFunctionStart( const String& rFormula,
+ xub_StrLen nStart,
+ BOOL bBack,
+ String* pFuncName ) const
+{
+ xub_StrLen nStrLen = rFormula.Len();
+
+ if ( nStrLen < nStart )
+ return nStart;
+
+ xub_StrLen nFStart = FUNC_NOTFOUND;
+ xub_StrLen nParPos = nStart;
+
+ BOOL bRepeat, bFound;
+ do
+ {
+ bFound = FALSE;
+ bRepeat = FALSE;
+
+ if ( bBack )
+ {
+ while ( !bFound && (nParPos > 0) )
+ {
+ if ( rFormula.GetChar(nParPos) == '"' )
+ {
+ nParPos--;
+ while ( (nParPos > 0) && rFormula.GetChar(nParPos) != '"' )
+ nParPos--;
+ if (nParPos > 0)
+ nParPos--;
+ }
+ else if ( (bFound = ( rFormula.GetChar(nParPos) == '(' ) ) == FALSE )
+ nParPos--;
+ }
+ }
+ else
+ {
+ while ( !bFound && (nParPos < nStrLen) )
+ {
+ if ( rFormula.GetChar(nParPos) == '"' )
+ {
+ nParPos++;
+ while ( (nParPos < nStrLen) && rFormula.GetChar(nParPos) != '"' )
+ nParPos++;
+ nParPos++;
+ }
+ else if ( (bFound = ( rFormula.GetChar(nParPos) == '(' ) ) == FALSE )
+ nParPos++;
+ }
+ }
+
+ if ( bFound && (nParPos > 0) )
+ {
+ nFStart = nParPos-1;
+
+ while ( (nFStart > 0) && IsFormulaText(m_pCharClass, rFormula, nFStart ))
+ nFStart--;
+ }
+
+ nFStart++;
+
+ if ( bFound )
+ {
+ if ( IsFormulaText( m_pCharClass,rFormula, nFStart ) )
+ {
+ // Funktion gefunden
+ if ( pFuncName )
+ *pFuncName = rFormula.Copy( nFStart, nParPos-nFStart );
+ }
+ else // Klammern ohne Funktion -> weitersuchen
+ {
+ bRepeat = TRUE;
+ if ( !bBack )
+ nParPos++;
+ else if (nParPos > 0)
+ nParPos--;
+ else
+ bRepeat = FALSE;
+ }
+ }
+ else // keine Klammern gefunden
+ {
+ nFStart = FUNC_NOTFOUND;
+ if ( pFuncName )
+ pFuncName->Erase();
+ }
+ }
+ while(bRepeat);
+
+ return nFStart;
+}
+
+//------------------------------------------------------------------------
+
+xub_StrLen FormulaHelper::GetFunctionEnd( const String& rStr, xub_StrLen nStart ) const
+{
+ xub_StrLen nStrLen = rStr.Len();
+
+ if ( nStrLen < nStart )
+ return nStart;
+
+ short nParCount = 0;
+ bool bInArray = false;
+ BOOL bFound = FALSE;
+
+ while ( !bFound && (nStart < nStrLen) )
+ {
+ sal_Unicode c = rStr.GetChar(nStart);
+
+ if ( c == '"' )
+ {
+ nStart++;
+ while ( (nStart < nStrLen) && rStr.GetChar(nStart) != '"' )
+ nStart++;
+ }
+ else if ( c == open )
+ nParCount++;
+ else if ( c == close )
+ {
+ nParCount--;
+ if ( nParCount == 0 )
+ bFound = TRUE;
+ else if ( nParCount < 0 )
+ {
+ bFound = TRUE;
+ nStart--; // einen zu weit gelesen
+ }
+ }
+ else if ( c == arrayOpen )
+ {
+ bInArray = true;
+ }
+ else if ( c == arrayClose )
+ {
+ bInArray = false;
+ }
+ else if ( c == sep )
+ {
+ if ( !bInArray && nParCount == 0 )
+ {
+ bFound = TRUE;
+ nStart--; // einen zu weit gelesen
+ }
+ }
+ nStart++; // hinter gefundene Position stellen
+ }
+
+ return nStart;
+}
+
+//------------------------------------------------------------------
+
+xub_StrLen FormulaHelper::GetArgStart( const String& rStr, xub_StrLen nStart, USHORT nArg ) const
+{
+ xub_StrLen nStrLen = rStr.Len();
+
+ if ( nStrLen < nStart )
+ return nStart;
+
+ short nParCount = 0;
+ bool bInArray = false;
+ BOOL bFound = FALSE;
+
+ while ( !bFound && (nStart < nStrLen) )
+ {
+ sal_Unicode c = rStr.GetChar(nStart);
+
+ if ( c == '"' )
+ {
+ nStart++;
+ while ( (nStart < nStrLen) && rStr.GetChar(nStart) != '"' )
+ nStart++;
+ }
+ else if ( c == open )
+ {
+ bFound = ( nArg == 0 );
+ nParCount++;
+ }
+ else if ( c == close )
+ {
+ nParCount--;
+ bFound = ( nParCount == 0 );
+ }
+ else if ( c == arrayOpen )
+ {
+ bInArray = true;
+ }
+ else if ( c == arrayClose )
+ {
+ bInArray = false;
+ }
+ else if ( c == sep )
+ {
+ if ( !bInArray && nParCount == 1 )
+ {
+ nArg--;
+ bFound = ( nArg == 0 );
+ }
+ }
+ nStart++;
+ }
+
+ return nStart;
+}
+// =============================================================================
+} // formula
+// =============================================================================
diff --git a/formula/source/ui/dlg/formdlgs.hrc b/formula/source/ui/dlg/formdlgs.hrc
new file mode 100644
index 000000000000..9e6378a53d2c
--- /dev/null
+++ b/formula/source/ui/dlg/formdlgs.hrc
@@ -0,0 +1,80 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+
+#define FT_RESULT 1
+#define WND_RESULT 2
+#define FT_EDITNAME 3
+#define STR_TITLE1 4
+#define STR_TITLE2 5
+#define BTN_HELP 6
+#define BTN_CANCEL 7
+#define BTN_BACKWARD 8
+#define BTN_FORWARD 9
+#define BTN_END 10
+#define BTN_MATRIX 11
+#define FT_FUNCNAME 12
+#define FT_FUNCDESC 13
+#define FT_HEADLINE 14
+#define GB_EDIT 15
+#define FT_FORMULA 16
+#define ED_FORMULA 17
+#define TC_FUNCTION 18
+#define ED_REF 19
+#define RB_REF 20
+#define FT_FORMULA_RESULT 21
+#define WND_FORMULA_RESULT 22
+#define STR_END 23
+// Fuer Tabpage
+#define TP_FUNCTION 1
+#define TP_STRUCT 2
+
+// Funktions-Tabpage
+#define FT_FUNCTION 1
+#define FT_CATEGORY 2
+#define LB_CATEGORY 3
+#define LB_FUNCTION 4
+
+// Struktur-Tabpage
+#define FT_STRUCT 1
+#define TLB_STRUCT 2
+
+// Bitmaps
+#define BMP_STR_CLOSE 1
+#define BMP_STR_OPEN 2
+#define BMP_STR_END 3
+#define BMP_STR_ERROR 4
+#define BMP_STR_CLOSE_H 11
+#define BMP_STR_OPEN_H 12
+#define BMP_STR_END_H 13
+#define BMP_STR_ERROR_H 14
+
+// Texte
+#define STR_STRUCT_ERR1 1
+#define STR_STRUCT_ERR2 2
+
+
diff --git a/formula/source/ui/dlg/formdlgs.src b/formula/source/ui/dlg/formdlgs.src
new file mode 100644
index 000000000000..c85aa561ced8
--- /dev/null
+++ b/formula/source/ui/dlg/formdlgs.src
@@ -0,0 +1,536 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "formdlgs.hrc"
+#include "ForResId.hrc"
+#include "helpids.hrc"
+
+
+#define STD_MASKCOLOR Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; }
+ //---------------------------------------------------------------------------
+TabPage RID_FORMULATAB_FUNCTION
+{
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 96 , 180 ) ;
+ HelpId = HID_FORMULATAB_FUNCTION ;
+ // Titel wird dynamisch gesetzt (s.u.)
+ // 1. Seite
+ ListBox LB_CATEGORY
+ {
+ HelpId = HID_FORMULA_LB_CATEGORY;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 86 , 112 ) ;
+ DropDown = TRUE ;
+ StringList [ en-US ] =
+ {
+ < "Last Used" ; Default ; > ;
+ < "All" ; Default ; > ;
+ };
+ // < "Database" ; Default ; > ;
+ // < "Date&Time" ; Default ; > ;
+ // < "Financial" ; Default ; > ;
+ // < "Information" ; Default ; > ;
+ // < "Logical" ; Default ; > ;
+ // < "Mathematical" ; Default ; > ;
+ // < "Array" ; Default ; > ;
+ // < "Statistical" ; Default ; > ;
+ // < "Spreadsheet" ; Default ; > ;
+ // < "Text" ; Default ; > ;
+ // < "Add-in" ; Default ; > ;
+ //};
+ };
+ ListBox LB_FUNCTION
+ {
+ HelpId = HID_FORMULA_LB_FUNCTION;
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 43 ) ;
+ Size = MAP_APPFONT ( 86 , 133 ) ;
+ Sort = TRUE;
+ };
+ FixedText FT_CATEGORY
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 84 , 8 ) ;
+ Text [ en-US ] = "~Category" ;
+ };
+ FixedText FT_FUNCTION
+ {
+ Pos = MAP_APPFONT ( 6 , 32 ) ;
+ Size = MAP_APPFONT ( 72 , 8 ) ;
+ Text [ en-US ] = "~Function" ;
+ };
+};
+TabPage RID_FORMULATAB_STRUCT
+{
+ Hide = TRUE ;
+ Size = MAP_APPFONT ( 96 , 180 ) ;
+ HelpId = HID_FORMULATAB_STRUCT ;
+ // Titel wird dynamisch gesetzt (s.u.)
+ // 1. Seite
+ Control TLB_STRUCT
+ {
+ Border = TRUE ;
+ TabStop = TRUE ;
+ Pos = MAP_APPFONT ( 6 , 14 ) ;
+ Size = MAP_APPFONT ( 86 , 162 ) ;
+ HelpId = HID_FORMULA_FAP_STRUCT ;
+ };
+ FixedText FT_STRUCT
+ {
+ Pos = MAP_APPFONT ( 6 , 3 ) ;
+ Size = MAP_APPFONT ( 86 , 8 ) ;
+ Text [ en-US ] = "~Structure" ;
+ };
+ Image BMP_STR_CLOSE
+ {
+ ImageBitmap = Bitmap { File = "fapclose.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_CLOSE_H
+ {
+ ImageBitmap = Bitmap { File = "fapclose_h.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_OPEN
+ {
+ ImageBitmap = Bitmap { File = "fapopen.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_OPEN_H
+ {
+ ImageBitmap = Bitmap { File = "fapopen_h.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_END
+ {
+ ImageBitmap = Bitmap { File = "fapok.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_END_H
+ {
+ ImageBitmap = Bitmap { File = "fapok_h.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_ERROR
+ {
+ ImageBitmap = Bitmap { File = "faperror.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ Image BMP_STR_ERROR_H
+ {
+ ImageBitmap = Bitmap { File = "faperror_h.bmp"; };
+ MaskColor = STD_MASKCOLOR;
+ };
+ String STR_STRUCT_ERR1
+ {
+ Text [ en-US ] = "=?" ;
+ };
+ String STR_STRUCT_ERR2
+ {
+ Text [ en-US ] = "Error" ;
+ };
+};
+ModalDialog RID_FORMULADLG_FORMULA_MODAL
+{
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 321 , 228 ) ;
+ HelpId = HID_FORMULADLG_FORMULA ;
+ Moveable = TRUE ;
+ TabControl TC_FUNCTION
+ {
+ Pos = MAP_APPFONT ( 6 , 5 ) ;
+ Size = MAP_APPFONT ( 102 , 199 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_FUNCTION ;
+ Text [ en-US ] = "Functions" ;
+ };
+ PageItem
+ {
+ Identifier = TP_STRUCT ;
+ Text [ en-US ] = "Structure" ;
+ };
+ };
+ };
+ FixedText FT_HEADLINE
+ {
+ Pos = MAP_APPFONT ( 115 , 24 ) ;
+ Size = MAP_APPFONT ( 194 , 8 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedText FT_FUNCNAME
+ {
+ Pos = MAP_APPFONT ( 115 , 38 ) ;
+ Size = MAP_APPFONT ( 194 , 24 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedText FT_FUNCDESC
+ {
+ Pos = MAP_APPFONT ( 115 , 68 ) ;
+ Size = MAP_APPFONT ( 194 , 64 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedText FT_EDITNAME
+ {
+ Pos = MAP_APPFONT ( 113 , 6 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ };
+ GroupBox GB_EDIT
+ {
+ Pos = MAP_APPFONT ( 112 , 18 ) ;
+ Size = MAP_APPFONT ( 203 , 128 ) ;
+ };
+ FixedText FT_FORMULA
+ {
+ Pos = MAP_APPFONT ( 112 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "For~mula" ;
+ };
+ Control ED_FORMULA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 112 , 161 ) ;
+ Size = MAP_APPFONT ( 203 , 43 ) ;
+ HelpId = HID_FORMULA_FAP_FORMULA ;
+ };
+ FixedText FT_RESULT
+ {
+ Pos = MAP_APPFONT ( 198 , 6 ) ;
+ Size = MAP_APPFONT ( 55 , 10 ) ;
+ Right = TRUE ;
+ Text [ en-US ] = "Function result" ;
+ };
+ Window WND_RESULT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 255 , 4 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ };
+ FixedText FT_FORMULA_RESULT
+ {
+ Pos = MAP_APPFONT ( 217 , 149 ) ;
+ Size = MAP_APPFONT ( 35 , 10 ) ;
+ Text [ en-US ] = "Result" ;
+ Right = TRUE ;
+ };
+ Window WND_FORMULA_RESULT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 255 , 147 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ };
+ CheckBox BTN_MATRIX
+ {
+ Pos = MAP_APPFONT ( 6 , 208 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Array" ;
+ };
+ Edit ED_REF
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 76 , 205 ) ;
+ Size = MAP_APPFONT ( 66 , 12 ) ;
+ };
+ ImageButton RB_REF
+ {
+ Pos = MAP_APPFONT ( 144 , 205 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Maximize" ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 72 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 121 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_BACKWARD
+ {
+ Pos = MAP_APPFONT ( 171 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "<< ~Back" ;
+ };
+ PushButton BTN_FORWARD
+ {
+ Pos = MAP_APPFONT ( 219 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Next >>" ;
+ };
+ OKButton BTN_END
+ {
+ Pos = MAP_APPFONT ( 270 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ String STR_TITLE1
+ {
+ Text [ en-US ] = "Function Wizard" ;
+ };
+ String STR_TITLE2
+ {
+ Text [ en-US ] = "Function Wizard -" ;
+ };
+ String STR_END
+ {
+ Text [ en-US ] = "~End" ;
+ };
+
+};
+ModelessDialog RID_FORMULADLG_FORMULA
+{
+ // OutputSize = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Size = MAP_APPFONT ( 321 , 228 ) ;
+ HelpId = HID_FORMULADLG_FORMULA ;
+ Moveable = TRUE ;
+ TabControl TC_FUNCTION
+ {
+ Pos = MAP_APPFONT ( 6 , 5 ) ;
+ Size = MAP_APPFONT ( 102 , 199 ) ;
+ PageList =
+ {
+ PageItem
+ {
+ Identifier = TP_FUNCTION ;
+ Text [ en-US ] = "Functions" ;
+ };
+ PageItem
+ {
+ Identifier = TP_STRUCT ;
+ Text [ en-US ] = "Structure" ;
+ };
+ };
+ };
+ FixedText FT_HEADLINE
+ {
+ Pos = MAP_APPFONT ( 115 , 24 ) ;
+ Size = MAP_APPFONT ( 194 , 8 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedText FT_FUNCNAME
+ {
+ Pos = MAP_APPFONT ( 115 , 38 ) ;
+ Size = MAP_APPFONT ( 194 , 24 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedText FT_FUNCDESC
+ {
+ Pos = MAP_APPFONT ( 115 , 68 ) ;
+ Size = MAP_APPFONT ( 194 , 64 ) ;
+ WordBreak = TRUE ;
+ };
+ FixedText FT_EDITNAME
+ {
+ Pos = MAP_APPFONT ( 113 , 6 ) ;
+ Size = MAP_APPFONT ( 83 , 10 ) ;
+ };
+ GroupBox GB_EDIT
+ {
+ Pos = MAP_APPFONT ( 112 , 18 ) ;
+ Size = MAP_APPFONT ( 203 , 128 ) ;
+ };
+ FixedText FT_FORMULA
+ {
+ Pos = MAP_APPFONT ( 112 , 151 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "For~mula" ;
+ };
+ Control ED_FORMULA
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 112 , 161 ) ;
+ Size = MAP_APPFONT ( 203 , 43 ) ;
+ HelpId = HID_FORMULA_FAP_FORMULA ;
+ };
+ FixedText FT_RESULT
+ {
+ Pos = MAP_APPFONT ( 198 , 6 ) ;
+ Size = MAP_APPFONT ( 55 , 10 ) ;
+ Right = TRUE ;
+ Text [ en-US ] = "Function result" ;
+ };
+ Window WND_RESULT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 255 , 4 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ };
+ FixedText FT_FORMULA_RESULT
+ {
+ Pos = MAP_APPFONT ( 217 , 149 ) ;
+ Size = MAP_APPFONT ( 35 , 10 ) ;
+ Text [ en-US ] = "Result" ;
+ Right = TRUE ;
+ };
+ Window WND_FORMULA_RESULT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 255 , 147 ) ;
+ Size = MAP_APPFONT ( 60 , 12 ) ;
+ };
+ CheckBox BTN_MATRIX
+ {
+ Pos = MAP_APPFONT ( 6 , 208 ) ;
+ Size = MAP_APPFONT ( 50 , 10 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "Array" ;
+ };
+ Edit ED_REF
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 76 , 205 ) ;
+ Size = MAP_APPFONT ( 66 , 12 ) ;
+ };
+ ImageButton RB_REF
+ {
+ Pos = MAP_APPFONT ( 144 , 205 ) ;
+ Size = MAP_APPFONT ( 13 , 15 ) ;
+ TabStop = FALSE ;
+ QuickHelpText [ en-US ] = "Maximize" ;
+ };
+ HelpButton BTN_HELP
+ {
+ Pos = MAP_APPFONT ( 72 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ CancelButton BTN_CANCEL
+ {
+ Pos = MAP_APPFONT ( 121 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ };
+ PushButton BTN_BACKWARD
+ {
+ Pos = MAP_APPFONT ( 171 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "<< ~Back" ;
+ };
+ PushButton BTN_FORWARD
+ {
+ Pos = MAP_APPFONT ( 219 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ Text [ en-US ] = "~Next >>" ;
+ };
+ OKButton BTN_END
+ {
+ Pos = MAP_APPFONT ( 270 , 208 ) ;
+ Size = MAP_APPFONT ( 45 , 14 ) ;
+ TabStop = TRUE ;
+ DefButton = TRUE ;
+ };
+ String STR_TITLE1
+ {
+ Text [ en-US ] = "Function Wizard" ;
+ };
+ String STR_TITLE2
+ {
+ Text [ en-US ] = "Function Wizard -" ;
+ };
+ String STR_END
+ {
+ Text [ en-US ] = "~End" ;
+ };
+};
+
+
+Image RID_BMP_REFBTN1
+{
+ ImageBitmap = Bitmap
+ {
+ File = "refinp1.bmp";
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+Image RID_BMP_REFBTN1_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "refinp1_h.bmp";
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+Image RID_BMP_REFBTN2
+{
+ ImageBitmap = Bitmap
+ {
+ File = "refinp2.bmp";
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+Image RID_BMP_REFBTN2_H
+{
+ ImageBitmap = Bitmap
+ {
+ File = "refinp2_h.bmp";
+ };
+ MaskColor = STD_MASKCOLOR;
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/formula/source/ui/dlg/formula.cxx b/formula/source/ui/dlg/formula.cxx
new file mode 100644
index 000000000000..f1a97171fa11
--- /dev/null
+++ b/formula/source/ui/dlg/formula.cxx
@@ -0,0 +1,2236 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_formula.hxx"
+
+//----------------------------------------------------------------------------
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mnemonic.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <vcl/wall.hxx>
+
+#include <svtools/stdctrl.hxx>
+#include <svtools/svmedit.hxx>
+#include <svtools/svtreebx.hxx>
+#include <svl/stritem.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/eitem.hxx>
+
+#include <unotools/charclass.hxx>
+#include <tools/urlobj.hxx>
+#include <tools/diagnose_ex.h>
+
+#include "formdlgs.hrc"
+#include "funcpage.hxx"
+#include "formula/formula.hxx"
+#include "formula/IFunctionDescription.hxx"
+#include "formula/FormulaCompiler.hxx"
+#include "formula/token.hxx"
+#include "formula/tokenarray.hxx"
+#include "formula/formdata.hxx"
+#include "formula/formulahelper.hxx"
+#include "structpg.hxx"
+#include "parawin.hxx"
+#include "ModuleHelper.hxx"
+#include "ForResId.hrc"
+#include <com/sun/star/sheet/FormulaToken.hpp>
+#include <com/sun/star/sheet/FormulaLanguage.hpp>
+#include <com/sun/star/sheet/FormulaMapGroup.hpp>
+#include <com/sun/star/sheet/FormulaMapGroupSpecialOffset.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <boost/bind.hpp>
+#include <comphelper/processfactory.hxx>
+#include <map>
+
+#define TOKEN_OPEN 0
+#define TOKEN_CLOSE 1
+#define TOKEN_SEP 2
+namespace formula
+{
+ using namespace ::com::sun::star;
+
+ class OFormulaToken : public IFormulaToken
+ {
+ sal_Int32 m_nParaCount;
+ bool m_bIsFunction;
+
+ public:
+ OFormulaToken(bool _bFunction,sal_Int32 _nParaCount) : m_nParaCount(_nParaCount),m_bIsFunction(_bFunction){}
+
+ virtual bool isFunction() const { return m_bIsFunction; }
+ virtual sal_uInt32 getArgumentCount() const { return m_nParaCount; }
+ };
+
+
+ class FormulaDlg_Impl
+ {
+ public:
+ ::std::pair<RefButton*,RefEdit*>
+ RefInputStartBefore( RefEdit* pEdit, RefButton* pButton );
+ void RefInputStartAfter( RefEdit* pEdit, RefButton* pButton );
+ void RefInputDoneAfter( BOOL bForced );
+ BOOL CalcValue( const String& rStrExp, String& rStrResult );
+ BOOL CalcStruct( const String& rStrExp);
+ void UpdateValues();
+ void DeleteArgs();
+ xub_StrLen GetFunctionPos(xub_StrLen nPos);
+ void ClearAllParas();
+
+ void MakeTree(IStructHelper* _pTree,SvLBoxEntry* pParent,FormulaToken* _pToken,long Count);
+ void fillTree(IStructHelper* _pTree);
+ void UpdateTokenArray( const String& rStrExp);
+ String RepairFormula(const String& aFormula);
+ void FillDialog(BOOL nFlag=TRUE);
+ void EditNextFunc( BOOL bForward, xub_StrLen nFStart=NOT_FOUND );
+ void EditThisFunc(xub_StrLen nFStart);
+ void EditFuncParas(xub_StrLen nEditPos);
+
+
+ void UpdateArgInput( USHORT nOffset, USHORT nInput );
+ void Update();
+ void Update(const String& _sExp);
+
+
+ void SaveArg( USHORT nEd );
+ void UpdateSelection();
+ void DoEnter( BOOL bOk );
+ void UpdateFunctionDesc();
+ void ResizeArgArr( const IFunctionDescription* pNewFunc );
+ void FillListboxes();
+ void FillControls(BOOL &rbNext, BOOL &rbPrev);
+
+ FormulaDlgMode SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,BOOL bMatrix,BOOL _bSelect,BOOL _bUpdate);
+ void SetMeText(const String& _sText);
+ BOOL CheckMatrix(String& aFormula /*IN/OUT*/);
+
+ void SetEdSelection();
+
+ BOOL UpdateParaWin(Selection& _rSelection);
+ void UpdateParaWin(const Selection& _rSelection,const String& _sRefStr);
+
+ void SetData(xub_StrLen nFStart,xub_StrLen nNextFStart,xub_StrLen nNextFEnd,xub_StrLen& PrivStart,xub_StrLen& PrivEnd);
+ void PreNotify( NotifyEvent& rNEvt );
+
+ RefEdit* GetCurrRefEdit();
+ ULONG FindFocusWin(Window *pWin);
+
+ const FormulaHelper& GetFormulaHelper() const;
+ uno::Reference< sheet::XFormulaOpCodeMapper > GetFormulaOpCodeMapper() const;
+
+ DECL_LINK( ModifyHdl, ParaWin* );
+ DECL_LINK( FxHdl, ParaWin* );
+
+ DECL_LINK( MatrixHdl, CheckBox *);
+ DECL_LINK( FormulaHdl, MultiLineEdit* );
+ DECL_LINK( FormulaCursorHdl, EditBox*);
+ DECL_LINK( BtnHdl, PushButton* );
+ DECL_LINK( GetEdFocusHdl, ArgInput* );
+ DECL_LINK( GetFxFocusHdl, ArgInput* );
+ DECL_LINK( DblClkHdl, FuncPage* );
+ DECL_LINK( FuncSelHdl, FuncPage*);
+ DECL_LINK( StructSelHdl, StructPage * );
+ public:
+ OModuleClient m_aModuleClient;
+ mutable uno::Reference< sheet::XFormulaOpCodeMapper> m_xOpCodeMapper;
+ uno::Sequence< sheet::FormulaToken > m_aTokenList;
+ ::std::auto_ptr<FormulaTokenArray> m_pTokenArray;
+ mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aSpecialOpCodes;
+ mutable const sheet::FormulaOpCodeMapEntry* m_pSpecialOpCodesEnd;
+ mutable uno::Sequence< sheet::FormulaToken > m_aSeparatorsOpCodes;
+ mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aFunctionOpCodes;
+ mutable const sheet::FormulaOpCodeMapEntry* m_pFunctionOpCodesEnd;
+ mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aUnaryOpCodes;
+ mutable const sheet::FormulaOpCodeMapEntry* m_pUnaryOpCodesEnd;
+ mutable uno::Sequence< sheet::FormulaOpCodeMapEntry > m_aBinaryOpCodes;
+ mutable const sheet::FormulaOpCodeMapEntry* m_pBinaryOpCodesEnd;
+ ::std::vector< ::boost::shared_ptr<OFormulaToken> > m_aTokens;
+ ::std::map<FormulaToken*,sheet::FormulaToken> m_aTokenMap;
+ IFormulaEditorHelper* m_pHelper;
+ Dialog* m_pParent;
+ IControlReferenceHandler* m_pDlg;
+ TabControl aTabCtrl;
+ GroupBox aGEdit; //! MUST be placed before pParaWin for initializing
+ ParaWin* pParaWin;
+ FixedText aFtHeadLine;
+ FixedInfo aFtFuncName;
+ FixedInfo aFtFuncDesc;
+
+ FixedText aFtEditName;
+ //FixedInfo aFtEditDesc;
+
+ FixedText aFtResult;
+ ValWnd aWndResult;
+
+ FixedText aFtFormula;
+ EditBox aMEFormula;
+
+ CheckBox aBtnMatrix;
+ HelpButton aBtnHelp;
+ CancelButton aBtnCancel;
+
+ PushButton aBtnBackward;
+ PushButton aBtnForward;
+ OKButton aBtnEnd;
+
+ RefEdit aEdRef;
+ RefButton aRefBtn;
+
+ FixedText aFtFormResult;
+ ValWnd aWndFormResult;
+
+ RefEdit* pTheRefEdit;
+ RefButton* pTheRefButton;
+ FuncPage* pFuncPage;
+ StructPage* pStructPage;
+ String aOldFormula;
+ BOOL bStructUpdate;
+ MultiLineEdit* pMEdit;
+ BOOL bUserMatrixFlag;
+ Timer aTimer;
+
+ const String aTitle1;
+ const String aTitle2;
+ const String aTxtEnd;
+ const String aTxtOk; // hinter aBtnEnd
+ FormulaHelper
+ m_aFormulaHelper;
+
+ SmartId m_aSmartEditHelpId;
+
+ ULONG nOldHelp;
+ ULONG nOldUnique;
+ ULONG nActivWinId;
+ BOOL bIsShutDown;
+
+
+
+ Font aFntBold;
+ Font aFntLight;
+ USHORT nEdFocus;
+ // Selection theCurSel;
+ BOOL bEditFlag;
+ const IFunctionDescription* pFuncDesc;
+ xub_StrLen nArgs;
+ ::std::vector< ::rtl::OUString > m_aArguments;
+ Selection aFuncSel;
+
+ FormulaDlg_Impl(Dialog* pParent
+ , bool _bSupportFunctionResult
+ , bool _bSupportResult
+ , bool _bSupportMatrix
+ ,IFormulaEditorHelper* _pHelper
+ ,const IFunctionManager* _pFunctionMgr
+ ,IControlReferenceHandler* _pDlg);
+ ~FormulaDlg_Impl();
+
+ };
+FormulaDlg_Impl::FormulaDlg_Impl(Dialog* pParent
+ , bool _bSupportFunctionResult
+ , bool _bSupportResult
+ , bool _bSupportMatrix
+ ,IFormulaEditorHelper* _pHelper
+ ,const IFunctionManager* _pFunctionMgr
+ ,IControlReferenceHandler* _pDlg)
+ :
+ m_pHelper (_pHelper),
+ m_pParent (pParent),
+ m_pDlg (_pDlg),
+ aTabCtrl ( pParent, ModuleRes( TC_FUNCTION ) ),
+ aGEdit ( pParent, ModuleRes( GB_EDIT ) ),
+ aFtHeadLine ( pParent, ModuleRes( FT_HEADLINE ) ),
+ aFtFuncName ( pParent, ModuleRes( FT_FUNCNAME ) ),
+ aFtFuncDesc ( pParent, ModuleRes( FT_FUNCDESC ) ),
+ //
+ aFtEditName ( pParent, ModuleRes( FT_EDITNAME ) ),
+ aFtResult ( pParent, ModuleRes( FT_RESULT ) ),
+ aWndResult ( pParent, ModuleRes( WND_RESULT ) ),
+
+ aFtFormula ( pParent, ModuleRes( FT_FORMULA ) ),
+ aMEFormula ( pParent, ModuleRes( ED_FORMULA ) ),
+ //
+ aBtnMatrix ( pParent, ModuleRes( BTN_MATRIX ) ),
+ aBtnHelp ( pParent, ModuleRes( BTN_HELP ) ),
+ aBtnCancel ( pParent, ModuleRes( BTN_CANCEL ) ),
+ aBtnBackward ( pParent, ModuleRes( BTN_BACKWARD ) ),
+ aBtnForward ( pParent, ModuleRes( BTN_FORWARD ) ),
+ aBtnEnd ( pParent, ModuleRes( BTN_END ) ),
+ aEdRef ( pParent, _pDlg, ModuleRes( ED_REF) ),
+ aRefBtn ( pParent, ModuleRes( RB_REF),&aEdRef,_pDlg ),
+ aFtFormResult ( pParent, ModuleRes( FT_FORMULA_RESULT)),
+ aWndFormResult ( pParent, ModuleRes( WND_FORMULA_RESULT)),
+ //
+ pTheRefEdit (NULL),
+ pMEdit (NULL),
+ bUserMatrixFlag (FALSE),
+ //
+ aTitle1 ( ModuleRes( STR_TITLE1 ) ), // lokale Resource
+ aTitle2 ( ModuleRes( STR_TITLE2 ) ), // lokale Resource
+ aTxtEnd ( ModuleRes( STR_END ) ), // lokale Resource
+ aTxtOk ( aBtnEnd.GetText() ),
+ m_aFormulaHelper(_pFunctionMgr),
+ //
+ nActivWinId (0),
+ bIsShutDown (FALSE),
+ nEdFocus (0),
+ pFuncDesc (NULL),
+ nArgs (0)
+{
+ pParaWin = new ParaWin( pParent,_pDlg, aGEdit.GetPosPixel());
+ aGEdit.Hide();
+ pParaWin->Hide();
+ aFtEditName.Hide();
+ aEdRef.Hide();
+ aRefBtn.Hide();
+
+ pMEdit = aMEFormula.GetEdit();
+ m_aSmartEditHelpId = pMEdit->GetSmartHelpId();
+ pMEdit->SetSmartUniqueId(m_aSmartEditHelpId);
+
+ bEditFlag=FALSE;
+ bStructUpdate=TRUE;
+ Point aPos=aGEdit.GetPosPixel();
+ pParaWin->SetPosPixel(aPos);
+ pParaWin->SetArgModifiedHdl(LINK( this, FormulaDlg_Impl, ModifyHdl ) );
+ pParaWin->SetFxHdl(LINK( this, FormulaDlg_Impl, FxHdl ) );
+
+ pFuncPage= new FuncPage( &aTabCtrl,_pFunctionMgr);
+ pStructPage= new StructPage( &aTabCtrl);
+ pFuncPage->Hide();
+ pStructPage->Hide();
+ aTabCtrl.SetTabPage( TP_FUNCTION, pFuncPage);
+ aTabCtrl.SetTabPage( TP_STRUCT, pStructPage);
+
+ nOldHelp = pParent->GetHelpId(); // HelpId aus Resource immer fuer "Seite 1"
+ nOldUnique = pParent->GetUniqueId();
+
+ aFtResult.Show( _bSupportResult );
+ aWndResult.Show( _bSupportResult );
+
+ aFtFormResult.Show( _bSupportFunctionResult );
+ aWndFormResult.Show( _bSupportFunctionResult );
+
+ if ( _bSupportMatrix )
+ aBtnMatrix.SetClickHdl(LINK( this, FormulaDlg_Impl, MatrixHdl ) );
+ else
+ aBtnMatrix.Hide();
+
+ aBtnCancel .SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) );
+ aBtnEnd .SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) );
+ aBtnForward .SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) );
+ aBtnBackward.SetClickHdl( LINK( this, FormulaDlg_Impl, BtnHdl ) );
+
+ pFuncPage->SetDoubleClickHdl( LINK( this, FormulaDlg_Impl, DblClkHdl ) );
+ pFuncPage->SetSelectHdl( LINK( this, FormulaDlg_Impl, FuncSelHdl) );
+ pStructPage->SetSelectionHdl( LINK( this, FormulaDlg_Impl, StructSelHdl ) );
+ pMEdit->SetModifyHdl( LINK( this, FormulaDlg_Impl, FormulaHdl ) );
+ aMEFormula.SetSelChangedHdl( LINK( this, FormulaDlg_Impl, FormulaCursorHdl ) );
+
+ aFntLight = aFtFormula.GetFont();
+ aFntLight.SetTransparent( TRUE );
+ aFntBold = aFntLight;
+ aFntBold.SetWeight( WEIGHT_BOLD );
+
+ pParaWin->SetArgumentFonts(aFntBold,aFntLight);
+
+ // function description for choosing a function is no longer in a different color
+
+ aFtHeadLine.SetFont(aFntBold);
+ aFtFuncName.SetFont(aFntLight);
+ aFtFuncDesc.SetFont(aFntLight);
+}
+FormulaDlg_Impl::~FormulaDlg_Impl()
+{
+ if(aTimer.IsActive())
+ {
+ aTimer.SetTimeoutHdl(Link());
+ aTimer.Stop();
+ } // if(aTimer.IsActive())
+ bIsShutDown=TRUE;// Setzen, damit PreNotify keinen GetFocus speichert.
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (pData) // wird nicht ueber Close zerstoert;
+ {
+ pData->SetFStart((xub_StrLen)pMEdit->GetSelection().Min());
+ pData->SetSelection(pMEdit->GetSelection());
+
+ if(aTabCtrl.GetCurPageId()==TP_FUNCTION)
+ pData->SetMode( (USHORT) FORMULA_FORMDLG_FORMULA );
+ else
+ pData->SetMode( (USHORT) FORMULA_FORMDLG_EDIT );
+ pData->SetUndoStr(pMEdit->GetText());
+ pData->SetMatrixFlag(aBtnMatrix.IsChecked());
+ }
+
+ aTabCtrl.RemovePage(TP_FUNCTION);
+ aTabCtrl.RemovePage(TP_STRUCT);
+
+ delete pStructPage;
+ delete pFuncPage;
+ delete pParaWin;
+ DeleteArgs();
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg_Impl::PreNotify( NotifyEvent& rNEvt )
+{
+ USHORT nSwitch=rNEvt.GetType();
+ if(nSwitch==EVENT_GETFOCUS && !bIsShutDown)
+ {
+ Window* pWin=rNEvt.GetWindow();
+ if(pWin!=NULL)
+ {
+ nActivWinId = pWin->GetUniqueId();
+ if(nActivWinId==0)
+ {
+ Window* pParent=pWin->GetParent();
+ while(pParent!=NULL)
+ {
+ nActivWinId=pParent->GetUniqueId();
+
+ if(nActivWinId!=0) break;
+
+ pParent=pParent->GetParent();
+ }
+ }
+ if(nActivWinId!=0)
+ {
+
+ FormEditData* pData = m_pHelper->getFormEditData();
+
+ if (pData && !aTimer.IsActive()) // wird nicht ueber Close zerstoert;
+ {
+ pData->SetUniqueId(nActivWinId);
+ }
+ }
+ }
+ }
+}
+uno::Reference< sheet::XFormulaOpCodeMapper > FormulaDlg_Impl::GetFormulaOpCodeMapper() const
+{
+ if ( !m_xOpCodeMapper.is() )
+ {
+ m_xOpCodeMapper = m_pHelper->getFormulaOpCodeMapper();
+ m_aFunctionOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::FUNCTIONS);
+ m_pFunctionOpCodesEnd = m_aFunctionOpCodes.getConstArray() + m_aFunctionOpCodes.getLength();
+
+ m_aUnaryOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::UNARY_OPERATORS);
+ m_pUnaryOpCodesEnd = m_aUnaryOpCodes.getConstArray() + m_aUnaryOpCodes.getLength();
+
+ m_aBinaryOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::BINARY_OPERATORS);
+ m_pBinaryOpCodesEnd = m_aBinaryOpCodes.getConstArray() + m_aBinaryOpCodes.getLength();
+
+ uno::Sequence< ::rtl::OUString > aArgs(3);
+ aArgs[TOKEN_OPEN] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("("));
+ aArgs[TOKEN_CLOSE] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(")"));
+ aArgs[TOKEN_SEP] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+ m_aSeparatorsOpCodes = m_xOpCodeMapper->getMappings(aArgs,sheet::FormulaLanguage::ODFF);
+
+ m_aSpecialOpCodes = m_xOpCodeMapper->getAvailableMappings(sheet::FormulaLanguage::ODFF,sheet::FormulaMapGroup::SPECIAL);
+ m_pSpecialOpCodesEnd = m_aSpecialOpCodes.getConstArray() + m_aSpecialOpCodes.getLength();
+ } // if ( !m_xOpCodeMapper.is() )
+ return m_xOpCodeMapper;
+}
+
+void FormulaDlg_Impl::DeleteArgs()
+{
+ ::std::vector< ::rtl::OUString>().swap(m_aArguments);
+ nArgs = 0;
+}
+namespace
+{
+ // comparing two property instances
+ struct OpCodeCompare : public ::std::binary_function< sheet::FormulaOpCodeMapEntry, sal_Int32 , bool >
+ {
+ bool operator() (const sheet::FormulaOpCodeMapEntry& x, sal_Int32 y) const
+ {
+ return x.Token.OpCode == y;
+ }
+ };
+}
+// -----------------------------------------------------------------------------
+xub_StrLen FormulaDlg_Impl::GetFunctionPos(xub_StrLen nPos)
+{
+ const sal_Unicode sep = m_pHelper->getFunctionManager()->getSingleToken(IFunctionManager::eSep);
+
+ xub_StrLen nTokPos=1;
+ xub_StrLen nOldTokPos=1;
+ xub_StrLen nFuncPos=STRING_NOTFOUND; //@ Testweise
+ xub_StrLen nPrevFuncPos=1;
+ short nBracketCount=0;
+ BOOL bFlag=FALSE;
+ String aFormString = pMEdit->GetText();
+ m_aFormulaHelper.GetCharClass()->toUpper( aFormString );
+
+ if ( m_aTokenList.getLength() )
+ {
+ const uno::Reference< sheet::XFormulaParser > xParser(m_pHelper->getFormulaParser());
+ const table::CellAddress aRefPos(m_pHelper->getReferencePosition());
+
+ const sheet::FormulaToken* pIter = m_aTokenList.getConstArray();
+ const sheet::FormulaToken* pEnd = pIter + m_aTokenList.getLength();
+ //if ( pIter != pEnd && aFormString.GetChar(0) == '=' )
+ // ++pIter;
+ try
+ {
+ while ( pIter != pEnd )
+ {
+ const sal_Int32 eOp = pIter->OpCode;
+ uno::Sequence<sheet::FormulaToken> aArgs(1);
+ aArgs[0] = *pIter;
+ const String aString = xParser->printFormula(aArgs, aRefPos);
+ const sheet::FormulaToken* pNextToken = pIter + 1;
+
+ if(!bUserMatrixFlag && FormulaCompiler::IsMatrixFunction((OpCode)eOp) )
+ {
+ aBtnMatrix.Check();
+ }
+
+ if ( eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::PUSH].Token.OpCode || eOp == m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::SPACES].Token.OpCode )
+ {
+ const xub_StrLen n1=aFormString.Search(sep, nTokPos);
+ const xub_StrLen n2=aFormString.Search(')',nTokPos);
+ xub_StrLen nXXX=nTokPos;
+ if(n1<n2)
+ {
+ nTokPos=n1;
+ }
+ else
+ {
+ nTokPos=n2;
+ }
+ if ( pNextToken != pEnd )
+ {
+ aArgs[0] = *pNextToken;
+ const String a2String = xParser->printFormula(aArgs, aRefPos);
+ const xub_StrLen n3 = aFormString.Search(a2String,nXXX);
+ if ( n3 < nTokPos )
+ nTokPos = n3;
+ }
+ }
+ else
+ {
+ nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() );
+ }
+
+ if ( eOp == m_aSeparatorsOpCodes[TOKEN_OPEN].OpCode )
+ {
+ nBracketCount++;
+ bFlag=TRUE;
+ }
+ else if ( eOp == m_aSeparatorsOpCodes[TOKEN_CLOSE].OpCode )
+ {
+ nBracketCount--;
+ bFlag=FALSE;
+ nFuncPos=nPrevFuncPos;
+ }
+ bool bIsFunction = ::std::find_if(m_aFunctionOpCodes.getConstArray(),m_pFunctionOpCodesEnd,::std::bind2nd(OpCodeCompare(),boost::cref(eOp))) != m_pFunctionOpCodesEnd;
+
+ if ( bIsFunction && m_aSpecialOpCodes[sheet::FormulaMapGroupSpecialOffset::SPACES].Token.OpCode != eOp )
+ {
+ nPrevFuncPos = nFuncPos;
+ nFuncPos = nOldTokPos;
+ }
+
+ if ( nOldTokPos <= nPos && nPos < nTokPos )
+ {
+ if ( !bIsFunction )
+ {
+ if ( nBracketCount < 1 )
+ {
+ nFuncPos= pMEdit->GetText().Len();
+ }
+ else if ( !bFlag )
+ {
+ nFuncPos=nPrevFuncPos;
+ }
+ }
+ break;
+ }
+
+ pIter = pNextToken;
+ nOldTokPos = nTokPos;
+ } // while ( pIter != pEnd )
+ }
+ catch(const uno::Exception& )
+ {
+ DBG_ERROR("Exception caught!");
+ }
+ }
+
+ return nFuncPos;
+}
+// -----------------------------------------------------------------------------
+BOOL FormulaDlg_Impl::CalcValue( const String& rStrExp, String& rStrResult )
+{
+ BOOL bResult = TRUE;
+
+ if ( rStrExp.Len() > 0 )
+ {
+ // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen:
+
+ if ( !Application::AnyInput( INPUT_KEYBOARD ) )
+ {
+ bResult = m_pHelper->calculateValue(rStrExp,rStrResult);
+ }
+ else
+ bResult = FALSE;
+ }
+
+ return bResult;
+}
+
+void FormulaDlg_Impl::UpdateValues()
+{
+ String aStrResult;
+
+ if ( CalcValue( pFuncDesc->getFormula( m_aArguments ), aStrResult ) )
+ aWndResult.SetValue( aStrResult );
+
+ aStrResult.Erase();
+ if ( CalcValue(m_pHelper->getCurrentFormula(), aStrResult ) )
+ aWndFormResult.SetValue( aStrResult );
+ else
+ {
+ aStrResult.Erase();
+ aWndFormResult.SetValue( aStrResult );
+ }
+ CalcStruct(pMEdit->GetText());
+}
+
+BOOL FormulaDlg_Impl::CalcStruct( const String& rStrExp)
+{
+ BOOL bResult = TRUE;
+ xub_StrLen nLength=rStrExp.Len();
+
+ if ( rStrExp.Len() > 0 && aOldFormula!=rStrExp && bStructUpdate)
+ {
+ // nur, wenn keine Tastatureingabe mehr anliegt, den Wert berechnen:
+
+ if ( !Application::AnyInput( INPUT_KEYBOARD ) )
+ {
+ pStructPage->ClearStruct();
+
+ String aString=rStrExp;
+ if(rStrExp.GetChar(nLength-1)=='(')
+ {
+ aString.Erase((xub_StrLen)(nLength-1));
+ }
+
+ aString.EraseAllChars('\n');
+ String aStrResult;
+
+ if ( CalcValue(aString, aStrResult ) )
+ aWndFormResult.SetValue( aStrResult );
+
+ UpdateTokenArray(aString);
+ fillTree(pStructPage);
+
+ aOldFormula=rStrExp;
+ if(rStrExp.GetChar(nLength-1)=='(')
+ UpdateTokenArray(rStrExp);
+ }
+ else
+ bResult = FALSE;
+ }
+ return bResult;
+}
+
+// -----------------------------------------------------------------------------
+void FormulaDlg_Impl::MakeTree(IStructHelper* _pTree,SvLBoxEntry* pParent,FormulaToken* _pToken,long Count)
+{
+ if( _pToken != NULL && Count > 0 )
+ {
+ long nParas = _pToken->GetParamCount();
+ OpCode eOp = _pToken->GetOpCode();
+
+ // #i101512# for output, the original token is needed
+ FormulaToken* pOrigToken = (_pToken->GetType() == svFAP) ? _pToken->GetFAPOrigToken() : _pToken;
+ uno::Sequence<sheet::FormulaToken> aArgs(1);
+ aArgs[0] = m_aTokenMap.find(pOrigToken)->second;
+ try
+ {
+ const table::CellAddress aRefPos(m_pHelper->getReferencePosition());
+ const String aResult = m_pHelper->getFormulaParser()->printFormula(aArgs, aRefPos);
+
+ if ( nParas > 0 )
+ {
+ SvLBoxEntry* pEntry;
+
+ String aTest=_pTree->GetEntryText(pParent);
+
+ if(aTest==aResult &&
+ (eOp==ocAdd || eOp==ocMul ||
+ eOp==ocAmpersand))
+ {
+ pEntry=pParent;
+ }
+ else
+ {
+ if(eOp==ocBad)
+ {
+ pEntry=_pTree->InsertEntry(aResult,pParent,STRUCT_ERROR,0,_pToken);
+ }
+ else
+ {
+ pEntry=_pTree->InsertEntry(aResult,pParent,STRUCT_FOLDER,0,_pToken);
+ }
+ }
+
+ MakeTree(_pTree,pEntry,m_pTokenArray->PrevRPN(),nParas);
+ --Count;
+ m_pTokenArray->NextRPN();
+ MakeTree(_pTree,pParent,m_pTokenArray->PrevRPN(),Count);
+ }
+ else
+ {
+ if(eOp==ocBad)
+ {
+ _pTree->InsertEntry(aResult,pParent,STRUCT_ERROR,0,_pToken);
+ }
+ else
+ {
+ _pTree->InsertEntry(aResult,pParent,STRUCT_END,0,_pToken);
+ }
+ --Count;
+ MakeTree(_pTree,pParent,m_pTokenArray->PrevRPN(),Count);
+ }
+ }
+ catch(uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ }
+}
+
+void FormulaDlg_Impl::fillTree(IStructHelper* _pTree)
+{
+ GetFormulaOpCodeMapper();
+ FormulaToken* pToken = m_pTokenArray->LastRPN();
+
+ if( pToken != NULL)
+ {
+ MakeTree(_pTree,NULL,pToken,1);
+ }
+}
+void FormulaDlg_Impl::UpdateTokenArray( const String& rStrExp)
+{
+ m_aTokenMap.clear();
+ m_aTokenList.realloc(0);
+ try
+ {
+ const table::CellAddress aRefPos(m_pHelper->getReferencePosition());
+ m_aTokenList = m_pHelper->getFormulaParser()->parseFormula(rStrExp, aRefPos);
+ }
+ catch(const uno::Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION();
+ }
+ GetFormulaOpCodeMapper(); // just to get it initialized
+ m_pTokenArray = m_pHelper->convertToTokenArray(m_aTokenList);
+ const sal_Int32 nLen = static_cast<sal_Int32>(m_pTokenArray->GetLen());
+ FormulaToken** pTokens = m_pTokenArray->GetArray();
+ if ( pTokens && nLen == m_aTokenList.getLength() )
+ {
+ for (sal_Int32 nPos=0; nPos<nLen; nPos++)
+ {
+ m_aTokenMap.insert(::std::map<FormulaToken*,sheet::FormulaToken>::value_type(pTokens[nPos],m_aTokenList[nPos]));
+ }
+ } // if ( pTokens && nLen == m_aTokenList.getLength() )
+
+ FormulaCompiler aCompiler(*m_pTokenArray.get());
+ aCompiler.SetCompileForFAP(TRUE); // #i101512# special handling is needed
+ aCompiler.CompileTokenArray();
+}
+
+void FormulaDlg_Impl::FillDialog(BOOL nFlag)
+{
+ BOOL bNext=TRUE, bPrev=TRUE;
+ if(nFlag)
+ FillControls(bNext, bPrev);
+ FillListboxes();
+ if(nFlag)
+ {
+ aBtnBackward.Enable(bPrev);
+ aBtnForward.Enable(bNext);
+ }
+
+ String aStrResult;
+
+ if ( CalcValue(m_pHelper->getCurrentFormula(), aStrResult ) )
+ aWndFormResult.SetValue( aStrResult );
+ else
+ {
+ aStrResult.Erase();
+ aWndFormResult.SetValue( aStrResult );
+ }
+}
+
+// -----------------------------------------------------------------------------
+void FormulaDlg_Impl::FillListboxes()
+{
+ // Umschalten zwischen den "Seiten"
+ FormEditData* pData = m_pHelper->getFormEditData();
+ String aNewTitle;
+ // 1. Seite: Funktion auswaehlen
+ if ( pFuncDesc && pFuncDesc->getCategory() )
+ {
+ if( pFuncPage->GetCategory() != pFuncDesc->getCategory()->getNumber() + 1 )
+ pFuncPage->SetCategory(static_cast<USHORT>(pFuncDesc->getCategory()->getNumber() + 1));
+
+ USHORT nPos=pFuncPage->GetFuncPos(pFuncDesc);
+
+ pFuncPage->SetFunction(nPos);
+ }
+ else if ( pData )
+ {
+ pFuncPage->SetCategory( pData->GetCatSel() );
+ pFuncPage->SetFunction( pData->GetFuncSel() );
+ }
+ FuncSelHdl(NULL);
+
+ // ResizeArgArr jetzt schon in UpdateFunctionDesc
+
+
+ m_pHelper->setDispatcherLock( TRUE);// Modal-Modus einschalten
+
+ aNewTitle = aTitle1;
+
+ // HelpId fuer 1. Seite ist die aus der Resource
+ m_pParent->SetHelpId( nOldHelp );
+ m_pParent->SetUniqueId( nOldUnique );
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg_Impl::FillControls(BOOL &rbNext, BOOL &rbPrev)
+{
+ // Umschalten zwischen den "Seiten"
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData )
+ return;
+
+ String aNewTitle;
+ // 2. Seite oder Editieren: ausgewaehlte Funktion anzeigen
+
+ xub_StrLen nFStart = pData->GetFStart();
+ String aFormula = m_pHelper->getCurrentFormula();
+ xub_StrLen nNextFStart = nFStart;
+ xub_StrLen nNextFEnd = 0;
+
+ aFormula.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " )" ));
+ DeleteArgs();
+ const IFunctionDescription* pOldFuncDesc = pFuncDesc;
+ BOOL bTestFlag = FALSE;
+
+ if ( m_aFormulaHelper.GetNextFunc( aFormula, FALSE,
+ nNextFStart, &nNextFEnd, &pFuncDesc, &m_aArguments ) )
+ {
+ bTestFlag = (pOldFuncDesc != pFuncDesc);
+ if(bTestFlag)
+ {
+ aFtHeadLine.Hide();
+ aFtFuncName.Hide();
+ aFtFuncDesc.Hide();
+ pParaWin->SetFunctionDesc(pFuncDesc);
+ aFtEditName.SetText( pFuncDesc->getFunctionName() );
+ aFtEditName.Show();
+ pParaWin->Show();
+ const long nHelpId = pFuncDesc->getHelpId();
+ if ( nHelpId )
+ pMEdit->SetSmartHelpId(SmartId(nHelpId));
+ }
+
+ xub_StrLen nOldStart, nOldEnd;
+ m_pHelper->getSelection( nOldStart, nOldEnd );
+ if ( nOldStart != nNextFStart || nOldEnd != nNextFEnd )
+ {
+ m_pHelper->setSelection( nNextFStart, nNextFEnd );
+ }
+ aFuncSel.Min() = nNextFStart;
+ aFuncSel.Max() = nNextFEnd;
+
+ if(!bEditFlag)
+ pMEdit->SetText(m_pHelper->getCurrentFormula());
+ xub_StrLen PrivStart, PrivEnd;
+ m_pHelper->getSelection( PrivStart, PrivEnd);
+ if(!bEditFlag)
+ pMEdit->SetSelection( Selection(PrivStart, PrivEnd));
+
+ nArgs = pFuncDesc->getSuppressedArgumentCount();
+ USHORT nOffset = pData->GetOffset();
+ nEdFocus = pData->GetEdFocus();
+
+ // Verkettung der Edit's fuer Focus-Kontrolle
+
+ if(bTestFlag)
+ pParaWin->SetArgumentOffset(nOffset);
+ USHORT nActiv=0;
+ xub_StrLen nArgPos= m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 );
+ xub_StrLen nEditPos=(xub_StrLen) pMEdit->GetSelection().Min();
+ BOOL bFlag=FALSE;
+
+ for(USHORT i=0;i<nArgs;i++)
+ {
+ sal_Int32 nLength = m_aArguments[i].getLength()+1;
+ pParaWin->SetArgument(i,m_aArguments[i]);
+ if(nArgPos<=nEditPos && nEditPos<nArgPos+nLength)
+ {
+ nActiv=i;
+ bFlag=TRUE;
+ }
+ nArgPos = sal::static_int_cast<xub_StrLen>( nArgPos + nLength );
+ }
+ pParaWin->UpdateParas();
+
+ if(bFlag)
+ {
+ pParaWin->SetActiveLine(nActiv);
+ }
+
+ //pParaWin->SetEdFocus( nEdFocus );
+ UpdateValues();
+ }
+ else
+ {
+ aFtEditName.SetText(String());
+ pMEdit->SetSmartHelpId(m_aSmartEditHelpId);
+ }
+ // Test, ob vorne/hinten noch mehr Funktionen sind
+
+ xub_StrLen nTempStart = m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 );
+ rbNext = m_aFormulaHelper.GetNextFunc( aFormula, FALSE, nTempStart );
+ nTempStart=(xub_StrLen)pMEdit->GetSelection().Min();
+ pData->SetFStart(nTempStart);
+ rbPrev = m_aFormulaHelper.GetNextFunc( aFormula, TRUE, nTempStart );
+}
+// -----------------------------------------------------------------------------
+
+void FormulaDlg_Impl::ClearAllParas()
+{
+ DeleteArgs();
+ pFuncDesc = NULL;
+ pParaWin->ClearAll();
+ aWndResult.SetValue(String());
+ aFtFuncName.SetText(String());
+ FuncSelHdl(NULL);
+
+ if(pFuncPage->IsVisible())
+ {
+ aFtEditName.Hide();
+ pParaWin->Hide();
+
+ aBtnForward.Enable(TRUE); //@new
+ aFtHeadLine.Show();
+ aFtFuncName.Show();
+ aFtFuncDesc.Show();
+ }
+}
+String FormulaDlg_Impl::RepairFormula(const String& aFormula)
+{
+ String aResult('=');
+ try
+ {
+ UpdateTokenArray(aFormula);
+
+ if ( m_aTokenList.getLength() )
+ {
+ const table::CellAddress aRefPos(m_pHelper->getReferencePosition());
+ const String sFormula(m_pHelper->getFormulaParser()->printFormula(m_aTokenList, aRefPos));
+ if ( !sFormula.Len() || sFormula.GetChar(0) != '=' )
+ aResult += sFormula;
+ else
+ aResult = sFormula;
+
+ }
+ }
+ catch(const uno::Exception& )
+ {
+ DBG_ERROR("Exception caught!");
+ }
+ return aResult;
+}
+
+void FormulaDlg_Impl::DoEnter(BOOL bOk)
+{
+ // Eingabe ins Dokument uebernehmen oder abbrechen
+ if ( bOk)
+ {
+ // ggf. Dummy-Argumente entfernen
+ String aInputFormula = m_pHelper->getCurrentFormula();
+ String aString = RepairFormula(pMEdit->GetText());
+ m_pHelper->setSelection(0, aInputFormula.Len());
+ m_pHelper->setCurrentFormula(aString);
+ }
+
+ m_pHelper->switchBack();
+
+ m_pHelper->dispatch(bOk,aBtnMatrix.IsChecked());
+ // Daten loeschen
+ m_pHelper->deleteFormData();
+
+ // Dialog schliessen
+ m_pHelper->doClose(bOk);
+}
+// -----------------------------------------------------------------------------
+
+IMPL_LINK( FormulaDlg_Impl, BtnHdl, PushButton*, pBtn )
+{
+ if ( pBtn == &aBtnCancel )
+ {
+ DoEnter(FALSE); // schliesst den Dialog
+ }
+ else if ( pBtn == &aBtnEnd )
+ {
+ DoEnter(TRUE); // schliesst den Dialog
+ }
+ else if ( pBtn == &aBtnForward )
+ {
+ //@pMEdit->GrabFocus(); // Damit die Selektion auch angezeigt wird.
+ const IFunctionDescription* pDesc =pFuncPage->GetFuncDesc( pFuncPage->GetFunction() );
+
+ if(pDesc==pFuncDesc || !pFuncPage->IsVisible())
+ EditNextFunc( TRUE );
+ else
+ {
+ DblClkHdl(pFuncPage); //new
+ aBtnForward.Enable(FALSE); //new
+ }
+ //@EditNextFunc( TRUE );
+ }
+ else if ( pBtn == &aBtnBackward )
+ {
+ bEditFlag=FALSE;
+ aBtnForward.Enable(TRUE);
+ EditNextFunc( FALSE );
+ aMEFormula.Invalidate();
+ aMEFormula.Update();
+ }
+ //...
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+
+
+// --------------------------------------------------------------------------
+// Funktionen fuer 1. Seite
+// --------------------------------------------------------------------------
+
+void FormulaDlg_Impl::ResizeArgArr( const IFunctionDescription* pNewFunc )
+{
+ if ( pFuncDesc != pNewFunc )
+ {
+ DeleteArgs();
+
+ if ( pNewFunc )
+ nArgs = pNewFunc->getSuppressedArgumentCount();
+
+ pFuncDesc = pNewFunc;
+ }
+}
+// -----------------------------------------------------------------------------
+
+void FormulaDlg_Impl::UpdateFunctionDesc()
+{
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData)
+ return;
+ USHORT nCat = pFuncPage->GetCategory();
+ if ( nCat == LISTBOX_ENTRY_NOTFOUND )
+ nCat = 0;
+ pData->SetCatSel( nCat );
+ USHORT nFunc = pFuncPage->GetFunction();
+ if ( nFunc == LISTBOX_ENTRY_NOTFOUND )
+ nFunc = 0;
+ pData->SetFuncSel( nFunc );
+
+ if ( (pFuncPage->GetFunctionEntryCount() > 0)
+ && (pFuncPage->GetFunction() != LISTBOX_ENTRY_NOTFOUND) )
+ {
+ const IFunctionDescription* pDesc = pFuncPage->GetFuncDesc(pFuncPage->GetFunction() );
+ if (pDesc)
+ {
+ pDesc->initArgumentInfo(); // full argument info is needed
+
+ String aSig = pDesc->getSignature();
+
+ aFtFuncName.SetText( aSig );
+ aFtFuncDesc.SetText( pDesc->getDescription() );
+ ResizeArgArr( pDesc );
+
+ if ( !m_aArguments.empty() ) // noch Argumente da?
+ aSig = pDesc->getFormula( m_aArguments ); // fuer Eingabezeile
+ //@ m_pHelper->setCurrentFormula( aSig );
+ }
+ }
+ else
+ {
+ aFtFuncName.SetText( String() );
+ aFtFuncDesc.SetText( String() );
+
+ //ResizeArgArr( NULL );
+ m_pHelper->setCurrentFormula( String() );
+ }
+}
+// -----------------------------------------------------------------------------
+
+// Handler fuer Listboxen
+
+IMPL_LINK( FormulaDlg_Impl, DblClkHdl, FuncPage*, EMPTYARG )
+{
+ USHORT nFunc = pFuncPage->GetFunction();
+
+ // ex-UpdateLRUList
+ const IFunctionDescription* pDesc = pFuncPage->GetFuncDesc(nFunc);
+ m_pHelper->insertEntryToLRUList(pDesc);
+
+ String aFuncName = pFuncPage->GetSelFunctionName();
+ aFuncName.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+ m_pHelper->setCurrentFormula(aFuncName);
+ pMEdit->ReplaceSelected(aFuncName);
+
+ Selection aSel=pMEdit->GetSelection();
+ aSel.Max()=aSel.Max()-1;
+ pMEdit->SetSelection(aSel);
+
+ FormulaHdl(pMEdit);
+
+ aSel.Min()=aSel.Max();
+ pMEdit->SetSelection(aSel);
+
+ if(nArgs==0)
+ {
+ BtnHdl(&aBtnBackward);
+ }
+
+ pParaWin->SetEdFocus(0);
+ aBtnForward.Enable(FALSE); //@New
+
+ return 0;
+}
+// -----------------------------------------------------------------------------
+
+// --------------------------------------------------------------------------
+// Funktionen fuer rechte Seite
+// --------------------------------------------------------------------------
+void FormulaDlg_Impl::SetData(xub_StrLen nFStart,xub_StrLen nNextFStart,xub_StrLen nNextFEnd,xub_StrLen& PrivStart,xub_StrLen& PrivEnd)
+{
+ xub_StrLen nFEnd;
+
+ // Selektion merken und neue setzen
+ m_pHelper->getSelection( nFStart, nFEnd );
+ m_pHelper->setSelection( nNextFStart, nNextFEnd );
+ if(!bEditFlag)
+ pMEdit->SetText(m_pHelper->getCurrentFormula());
+
+
+ m_pHelper->getSelection( PrivStart, PrivEnd);
+ if(!bEditFlag)
+ {
+ pMEdit->SetSelection( Selection(PrivStart, PrivEnd));
+ aMEFormula.UpdateOldSel();
+ }
+
+ FormEditData* pData = m_pHelper->getFormEditData();
+ pData->SetFStart( nNextFStart );
+ pData->SetOffset( 0 );
+ pData->SetEdFocus( 0 );
+
+ FillDialog();
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg_Impl::EditThisFunc(xub_StrLen nFStart)
+{
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData) return;
+
+ String aFormula = m_pHelper->getCurrentFormula();
+
+ if(nFStart==NOT_FOUND)
+ {
+ nFStart = pData->GetFStart();
+ }
+ else
+ {
+ pData->SetFStart(nFStart);
+ }
+
+ xub_StrLen nNextFStart = nFStart;
+ xub_StrLen nNextFEnd = 0;
+
+ BOOL bFound;
+
+ //@bFound = m_pHelper->getNextFunction( aFormula, FALSE, nNextFStart, &nNextFEnd, &pFuncDesc );
+
+ bFound = m_aFormulaHelper.GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd);
+ if ( bFound )
+ {
+ xub_StrLen PrivStart, PrivEnd;
+ SetData(nFStart,nNextFStart,nNextFEnd,PrivStart, PrivEnd);
+ m_pHelper->showReference(aFormula.Copy(PrivStart, PrivEnd-PrivStart));
+ }
+ else
+ {
+ ClearAllParas();
+ }
+}
+
+void FormulaDlg_Impl::EditNextFunc( BOOL bForward, xub_StrLen nFStart )
+{
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData)
+ return;
+
+ String aFormula = m_pHelper->getCurrentFormula();
+
+ if(nFStart==NOT_FOUND)
+ {
+ nFStart = pData->GetFStart();
+ }
+ else
+ {
+ pData->SetFStart(nFStart);
+ }
+
+ xub_StrLen nNextFStart = 0;
+ xub_StrLen nNextFEnd = 0;
+
+ BOOL bFound;
+ if ( bForward )
+ {
+ nNextFStart = m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 );
+ //@bFound = m_pHelper->getNextFunction( aFormula, FALSE, nNextFStart, &nNextFEnd, &pFuncDesc );
+ bFound = m_aFormulaHelper.GetNextFunc( aFormula, FALSE, nNextFStart, &nNextFEnd);
+ }
+ else
+ {
+ nNextFStart = nFStart;
+ //@bFound = m_pHelper->getNextFunction( aFormula, TRUE, nNextFStart, &nNextFEnd, &pFuncDesc );
+ bFound = m_aFormulaHelper.GetNextFunc( aFormula, TRUE, nNextFStart, &nNextFEnd);
+ }
+
+ if ( bFound )
+ {
+ xub_StrLen PrivStart, PrivEnd;
+ SetData(nFStart,nNextFStart,nNextFEnd,PrivStart, PrivEnd);
+ }
+}
+
+void FormulaDlg_Impl::EditFuncParas(xub_StrLen nEditPos)
+{
+ if(pFuncDesc!=NULL)
+ {
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData) return;
+
+ String aFormula = m_pHelper->getCurrentFormula();
+ aFormula +=')';
+ xub_StrLen nFStart = pData->GetFStart();
+
+ DeleteArgs();
+
+ nArgs = pFuncDesc->getSuppressedArgumentCount();
+
+ sal_Int32 nArgPos=m_aFormulaHelper.GetArgStart( aFormula, nFStart, 0 );
+ m_aFormulaHelper.GetArgStrings(m_aArguments,aFormula, nFStart, nArgs );
+// m_aArguments = ScFormulaUtil::GetArgStrings( aFormula, nFStart, nArgs );
+
+ USHORT nActiv=pParaWin->GetSliderPos();
+ BOOL bFlag=FALSE;
+ ::std::vector< ::rtl::OUString >::iterator aIter = m_aArguments.begin();
+ ::std::vector< ::rtl::OUString >::iterator aEnd = m_aArguments.end();
+ for(USHORT i=0;aIter != aEnd;i++,++aIter)
+ {
+ sal_Int32 nLength=(*aIter).getLength();
+ pParaWin->SetArgument(i,(*aIter));
+ if(nArgPos<=nEditPos && nEditPos<nArgPos+nLength)
+ {
+ nActiv=i;
+ bFlag=TRUE;
+ }
+ nArgPos+=nLength+1;
+ }
+
+ if(bFlag)
+ {
+ pParaWin->SetSliderPos(nActiv);
+ }
+
+ pParaWin->UpdateParas();
+ UpdateValues();
+ }
+
+}
+
+void FormulaDlg_Impl::SaveArg( USHORT nEd )
+{
+ if (nEd<nArgs)
+ {
+ USHORT i;
+ for(i=0;i<=nEd;i++)
+ {
+ if ( m_aArguments[i].getLength() == 0 )
+ m_aArguments[i] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" "));
+ }
+ if(pParaWin->GetArgument(nEd).Len()!=0)
+ m_aArguments[nEd] = pParaWin->GetArgument(nEd);
+
+ USHORT nClearPos=nEd+1;
+ for(i=nEd+1;i<nArgs;i++)
+ {
+ if(pParaWin->GetArgument(i).Len()!=0)
+ {
+ nClearPos=i+1;
+ }
+ }
+
+ for(i=nClearPos;i<nArgs;i++)
+ {
+ m_aArguments[i] = ::rtl::OUString();
+ }
+ }
+}
+
+IMPL_LINK( FormulaDlg_Impl, FxHdl, ParaWin*, pPtr )
+{
+ if(pPtr==pParaWin)
+ {
+ aBtnForward.Enable(TRUE); //@ Damit eine neue Fkt eingegeben werden kann.
+ aTabCtrl.SetCurPageId(TP_FUNCTION);
+
+ String aUndoStr = m_pHelper->getCurrentFormula(); // bevor unten ein ";" eingefuegt wird
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData) return 0;
+
+ USHORT nArgNo = pParaWin->GetActiveLine();
+ nEdFocus=nArgNo;
+
+ SaveArg(nArgNo);
+ UpdateSelection();
+
+ xub_StrLen nFormulaStrPos = pData->GetFStart();
+
+ String aFormula = m_pHelper->getCurrentFormula();
+ xub_StrLen n1 = m_aFormulaHelper.GetArgStart( aFormula, nFormulaStrPos, nEdFocus+pData->GetOffset() );
+
+ pData->SetEdFocus( nEdFocus );
+ pData->SaveValues();
+ pData->SetMode( (USHORT) FORMULA_FORMDLG_FORMULA );
+ pData->SetFStart( n1 );
+ pData->SetUndoStr( aUndoStr );
+ ClearAllParas();
+
+ FillDialog(FALSE);
+ pFuncPage->SetFocus(); //Da Parawin nicht mehr sichtbar
+ }
+ return 0;
+}
+
+IMPL_LINK( FormulaDlg_Impl, ModifyHdl, ParaWin*, pPtr )
+{
+ if(pPtr==pParaWin)
+ {
+ SaveArg(pParaWin->GetActiveLine());
+ UpdateValues();
+
+ UpdateSelection();
+ CalcStruct(pMEdit->GetText());
+ }
+ return 0;
+}
+
+IMPL_LINK( FormulaDlg_Impl, FormulaHdl, MultiLineEdit*, EMPTYARG )
+{
+
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData) return 0;
+
+ bEditFlag=TRUE;
+ String aInputFormula=m_pHelper->getCurrentFormula();
+ String aString=pMEdit->GetText();
+
+ Selection aSel =pMEdit->GetSelection();
+ xub_StrLen nTest=0;
+
+ if(aString.Len()==0) //falls alles geloescht wurde
+ {
+ aString +='=';
+ pMEdit->SetText(aString);
+ aSel .Min()=1;
+ aSel .Max()=1;
+ pMEdit->SetSelection(aSel);
+ }
+ else if(aString.GetChar(nTest)!='=') //falls ersetzt wurde;
+ {
+ aString.Insert( (sal_Unicode)'=', 0 );
+ pMEdit->SetText(aString);
+ aSel .Min()+=1;
+ aSel .Max()+=1;
+ pMEdit->SetSelection(aSel);
+ }
+
+
+ m_pHelper->setSelection(0, aInputFormula.Len());
+ m_pHelper->setCurrentFormula(aString);
+ m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max());
+
+ xub_StrLen nPos=(xub_StrLen)aSel.Min()-1;
+
+ String aStrResult;
+
+ if ( CalcValue(m_pHelper->getCurrentFormula(), aStrResult ) )
+ aWndFormResult.SetValue( aStrResult );
+ else
+ {
+ aStrResult.Erase();
+ aWndFormResult.SetValue( aStrResult );
+ }
+ CalcStruct(aString);
+
+ nPos=GetFunctionPos(nPos);
+
+ if(nPos<aSel.Min()-1)
+ {
+ xub_StrLen nPos1=aString.Search('(',nPos);
+ EditNextFunc( FALSE, nPos1);
+ }
+ else
+ {
+ ClearAllParas();
+ }
+
+ m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max());
+ bEditFlag=FALSE;
+ return 0;
+}
+
+IMPL_LINK( FormulaDlg_Impl, FormulaCursorHdl, EditBox*, EMPTYARG )
+{
+ FormEditData* pData = m_pHelper->getFormEditData();
+ if (!pData) return 0;
+ xub_StrLen nFStart = pData->GetFStart();
+
+ bEditFlag=TRUE;
+
+ String aInputFormula=m_pHelper->getCurrentFormula();
+ String aString=pMEdit->GetText();
+
+ Selection aSel =pMEdit->GetSelection();
+ m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max());
+
+ if(aSel.Min()==0)
+ {
+ aSel.Min()=1;
+ pMEdit->SetSelection(aSel);
+ }
+
+ if(aSel.Min()!=aString.Len())
+ {
+ xub_StrLen nPos=(xub_StrLen)aSel.Min();
+
+ nFStart=GetFunctionPos(nPos - 1);
+
+ if(nFStart<nPos)
+ {
+ xub_StrLen nPos1=m_aFormulaHelper.GetFunctionEnd(aString,nFStart);
+
+ if(nPos1>nPos || nPos1==STRING_NOTFOUND)
+ {
+ EditThisFunc(nFStart);
+ }
+ else
+ {
+ xub_StrLen n=nPos;
+ short nCount=1;
+ while(n>0)
+ {
+ if(aString.GetChar(n)==')')
+ nCount++;
+ else if(aString.GetChar(n)=='(')
+ nCount--;
+ if(nCount==0) break;
+ n--;
+ }
+ if(nCount==0)
+ {
+ nFStart=m_aFormulaHelper.GetFunctionStart(aString,n,TRUE);
+ EditThisFunc(nFStart);
+ }
+ else
+ {
+ ClearAllParas();
+ }
+ }
+ }
+ else
+ {
+ ClearAllParas();
+ }
+ }
+ m_pHelper->setSelection((xub_StrLen)aSel.Min(),(xub_StrLen)aSel.Max());
+
+ bEditFlag=FALSE;
+ return 0;
+}
+
+void FormulaDlg_Impl::UpdateSelection()
+{
+ m_pHelper->setSelection((xub_StrLen)aFuncSel.Min(),(xub_StrLen)aFuncSel.Max());
+ m_pHelper->setCurrentFormula( pFuncDesc->getFormula( m_aArguments ) );
+ pMEdit->SetText(m_pHelper->getCurrentFormula());
+ xub_StrLen PrivStart, PrivEnd;
+ m_pHelper->getSelection( PrivStart, PrivEnd);
+ aFuncSel.Min()=PrivStart;
+ aFuncSel.Max()=PrivEnd;
+
+ nArgs = pFuncDesc->getSuppressedArgumentCount();
+
+ String aFormula=pMEdit->GetText();
+ sal_Int32 nArgPos=m_aFormulaHelper.GetArgStart( aFormula,PrivStart,0);
+
+ USHORT nPos=pParaWin->GetActiveLine();
+
+ for(USHORT i=0;i<nPos;i++)
+ {
+ nArgPos += (m_aArguments[i].getLength() + 1);
+ }
+ sal_Int32 nLength= m_aArguments[nPos].getLength();
+
+ Selection aSel(nArgPos,nArgPos+nLength);
+ m_pHelper->setSelection((USHORT)nArgPos,(USHORT)(nArgPos+nLength));
+ pMEdit->SetSelection(aSel);
+ aMEFormula.UpdateOldSel();
+}
+::std::pair<RefButton*,RefEdit*> FormulaDlg_Impl::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton )
+{
+ aEdRef.Show();
+ pTheRefEdit = pEdit;
+ pTheRefButton = pButton;
+
+ if( pTheRefEdit )
+ {
+ aEdRef.SetRefString( pTheRefEdit->GetText() );
+ aEdRef.SetSelection( pTheRefEdit->GetSelection() );
+ aEdRef.SetHelpId( pTheRefEdit->GetHelpId() );
+ aEdRef.SetUniqueId( pTheRefEdit->GetUniqueId() );
+ }
+
+ aRefBtn.Show( pButton != NULL );
+
+ //m_pHelper->RefInputStart( &aEdRef, pButton ? &aRefBtn : NULL );
+ ::std::pair<RefButton*,RefEdit*> aPair;
+ aPair.first = pButton ? &aRefBtn : NULL;
+ aPair.second = &aEdRef;
+ return aPair;
+}
+void FormulaDlg_Impl::RefInputStartAfter( RefEdit* /*pEdit*/, RefButton* /*pButton*/ )
+{
+ aRefBtn.SetEndImage();
+
+ if( pTheRefEdit )
+ {
+ String aStr = aTitle2;
+ aStr += ' ';
+ aStr += aFtEditName.GetText();
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "( " ) );
+ if( pParaWin->GetActiveLine() > 0 )
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "...; " ) );
+ aStr += pParaWin->GetActiveArgName();
+ if( pParaWin->GetActiveLine() + 1 < nArgs )
+ aStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "; ..." ));
+ aStr.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " )" ) );
+
+ m_pParent->SetText( MnemonicGenerator::EraseAllMnemonicChars( aStr ) );
+ }
+}
+void FormulaDlg_Impl::RefInputDoneAfter( BOOL bForced )
+{
+ aRefBtn.SetStartImage();
+ if( bForced || !aRefBtn.IsVisible() )
+ {
+ aEdRef.Hide();
+ aRefBtn.Hide();
+ if( pTheRefEdit )
+ {
+ pTheRefEdit->SetRefString( aEdRef.GetText() );
+ pTheRefEdit->GrabFocus();
+
+ if( pTheRefButton )
+ pTheRefButton->SetStartImage();
+
+ USHORT nPrivActiv = pParaWin->GetActiveLine();
+ pParaWin->SetArgument( nPrivActiv, aEdRef.GetText() );
+ ModifyHdl( pParaWin );
+ pTheRefEdit = NULL;
+ }
+ m_pParent->SetText( aTitle1 );
+ }
+}
+RefEdit* FormulaDlg_Impl::GetCurrRefEdit()
+{
+ return aEdRef.IsVisible() ? &aEdRef : pParaWin->GetActiveEdit();
+}
+void FormulaDlg_Impl::Update()
+{
+ FormEditData* pData = m_pHelper->getFormEditData();
+ const String sExpression = pMEdit->GetText();
+ aOldFormula = String();
+ UpdateTokenArray(sExpression);
+ FormulaCursorHdl(&aMEFormula);
+ CalcStruct(sExpression);
+ if(pData->GetMode() == FORMULA_FORMDLG_FORMULA)
+ aTabCtrl.SetCurPageId(TP_FUNCTION);
+ else
+ aTabCtrl.SetCurPageId(TP_STRUCT);
+ aBtnMatrix.Check(pData->GetMatrixFlag());
+ /*aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, FormulaDlg_Impl, UpdateFocusHdl));
+ aTimer.Start();*/
+}
+void FormulaDlg_Impl::Update(const String& _sExp)
+{
+ CalcStruct(_sExp);
+ FillDialog();
+ //aBtnForward.Enable(TRUE); //@New
+ FuncSelHdl(NULL);
+}
+void FormulaDlg_Impl::SetMeText(const String& _sText)
+{
+ FormEditData* pData = m_pHelper->getFormEditData();
+ pMEdit->SetText(_sText);
+ pMEdit->SetSelection( pData->GetSelection());
+ aMEFormula.UpdateOldSel();
+}
+FormulaDlgMode FormulaDlg_Impl::SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,BOOL bMatrix,BOOL _bSelect,BOOL _bUpdate)
+{
+ FormulaDlgMode eMode = FORMULA_FORMDLG_FORMULA;
+ if(!bEditFlag)
+ pMEdit->SetText(_sText);
+
+ if ( _bSelect || !bEditFlag )
+ pMEdit->SetSelection( Selection(PrivStart, PrivEnd));
+ if ( _bUpdate )
+ {
+ aMEFormula.UpdateOldSel();
+ pMEdit->Invalidate();
+ m_pHelper->showReference(pMEdit->GetSelected());
+ eMode = FORMULA_FORMDLG_EDIT;
+
+ aBtnMatrix.Check( bMatrix );
+ } // if ( _bUpdate )
+ return eMode;
+}
+BOOL FormulaDlg_Impl::CheckMatrix(String& aFormula)
+{
+ pMEdit->GrabFocus();
+ xub_StrLen nLen = aFormula.Len();
+ BOOL bMatrix = nLen > 3 // Matrix-Formel ?
+ && aFormula.GetChar(0) == '{'
+ && aFormula.GetChar(1) == '='
+ && aFormula.GetChar(nLen-1) == '}';
+ if ( bMatrix )
+ {
+ aFormula.Erase( 0, 1 );
+ aFormula.Erase( aFormula.Len()-1, 1);
+ aBtnMatrix.Check( bMatrix );
+ aBtnMatrix.Disable();
+ } // if ( bMatrix )
+
+ aTabCtrl.SetCurPageId(TP_STRUCT);
+ return bMatrix;
+}
+IMPL_LINK( FormulaDlg_Impl, StructSelHdl, StructPage*, pStruP )
+{
+ bStructUpdate=FALSE;
+ if(pStructPage->IsVisible()) aBtnForward.Enable(FALSE); //@New
+
+ if(pStructPage==pStruP)
+ {
+ /// TODO
+ //ScToken* pSelToken = pStructPage->GetSelectedToken();
+ // ScToken* pOrigToken = ((pSelToken && pSelToken->GetType() == svFAP) ?
+ // pSelToken->GetFAPOrigToken() : pSelToken);
+ //xub_StrLen nTokPos=1;
+
+ //if(pScTokA!=NULL)
+ //{
+ // ScToken* pToken = pScTokA->First();
+
+ // while(pToken!=NULL)
+ // {
+ // String aString;
+ // if ( pToken == pOrigToken )
+ // break;
+ // pComp->CreateStringFromToken( aString,pToken);
+ // nTokPos = sal::static_int_cast<xub_StrLen>( nTokPos + aString.Len() );
+ // pToken=pScTokA->Next();
+ // }
+ // EditThisFunc(nTokPos);
+ //}
+
+ //if( pOrigToken )
+ //{
+ // String aStr;
+ // pComp->CreateStringFromToken( aStr, pOrigToken );
+ // String aEntryTxt=pStructPage->GetSelectedEntryText();
+
+ // if(aEntryTxt!=aStr)
+ // ShowReference(aEntryTxt);
+ //}
+
+ }
+ bStructUpdate=TRUE;
+ return 0;
+}
+IMPL_LINK( FormulaDlg_Impl, MatrixHdl, CheckBox *, EMPTYARG )
+{
+ bUserMatrixFlag=TRUE;
+ return 0;
+}
+
+IMPL_LINK( FormulaDlg_Impl, FuncSelHdl, FuncPage*, EMPTYARG )
+{
+ USHORT nCat = pFuncPage->GetCategory();
+ if ( nCat == LISTBOX_ENTRY_NOTFOUND ) nCat = 0;
+ USHORT nFunc = pFuncPage->GetFunction();
+ if ( nFunc == LISTBOX_ENTRY_NOTFOUND ) nFunc = 0;
+
+ if ( (pFuncPage->GetFunctionEntryCount() > 0)
+ && (pFuncPage->GetFunction() != LISTBOX_ENTRY_NOTFOUND) )
+ {
+ const IFunctionDescription* pDesc =pFuncPage->GetFuncDesc( pFuncPage->GetFunction() );
+
+ if(pDesc!=pFuncDesc) aBtnForward.Enable(TRUE); //new
+
+ if (pDesc)
+ {
+ pDesc->initArgumentInfo(); // full argument info is needed
+
+ String aSig = pDesc->getSignature();
+ aFtHeadLine.SetText( pDesc->getFunctionName() );
+ aFtFuncName.SetText( aSig );
+ aFtFuncDesc.SetText( pDesc->getDescription() );
+ }
+ }
+ else
+ {
+ aFtHeadLine.SetText( String() );
+ aFtFuncName.SetText( String() );
+ aFtFuncDesc.SetText( String() );
+ }
+ return 0;
+}
+
+void FormulaDlg_Impl::UpdateParaWin(const Selection& _rSelection,const String& _sRefStr)
+{
+ Selection theSel = _rSelection;
+ aEdRef.ReplaceSelected( _sRefStr );
+ theSel.Max() = theSel.Min() + _sRefStr.Len();
+ aEdRef.SetSelection( theSel );
+
+ //-------------------------------------
+ // Manuelles Update der Ergebnisfelder:
+ //-------------------------------------
+ USHORT nPrivActiv = pParaWin->GetActiveLine();
+ pParaWin->SetArgument(nPrivActiv,aEdRef.GetText());
+ pParaWin->UpdateParas();
+
+ Edit* pEd = GetCurrRefEdit();
+ if( pEd != NULL )
+ pEd->SetSelection( theSel );
+
+ pParaWin->SetRefMode(FALSE);
+}
+BOOL FormulaDlg_Impl::UpdateParaWin(Selection& _rSelection)
+{
+ pParaWin->SetRefMode(TRUE);
+
+ String aStrEd;
+ Edit* pEd = GetCurrRefEdit();
+ if(pEd!=NULL && pTheRefEdit==NULL)
+ {
+ _rSelection=pEd->GetSelection();
+ _rSelection.Justify();
+ aStrEd=pEd->GetText();
+ aEdRef.SetRefString(aStrEd);
+ aEdRef.SetSelection( _rSelection );
+ }
+ else
+ {
+ _rSelection=aEdRef.GetSelection();
+ _rSelection.Justify();
+ aStrEd= aEdRef.GetText();
+ }
+ return pTheRefEdit == NULL;
+}
+ULONG FormulaDlg_Impl::FindFocusWin(Window *pWin)
+{
+ ULONG nUniqueId=0;
+ if(pWin->HasFocus())
+ {
+ nUniqueId=pWin->GetUniqueId();
+ if(nUniqueId==0)
+ {
+ Window* pParent=pWin->GetParent();
+ while(pParent!=NULL)
+ {
+ nUniqueId=pParent->GetUniqueId();
+
+ if(nUniqueId!=0) break;
+
+ pParent=pParent->GetParent();
+ }
+ }
+ }
+ else
+ {
+ USHORT nCount=pWin->GetChildCount();
+
+ for(USHORT i=0;i<nCount;i++)
+ {
+ Window* pChild=pWin->GetChild(i);
+ nUniqueId=FindFocusWin(pChild);
+ if(nUniqueId>0) break;
+ }
+ }
+ return nUniqueId;
+}
+
+void FormulaDlg_Impl::SetEdSelection()
+{
+ Edit* pEd = GetCurrRefEdit()/*aScParaWin.GetActiveEdit()*/;
+ if( pEd )
+ {
+ Selection theSel = aEdRef.GetSelection();
+ // Edit may have the focus -> call ModifyHdl in addition
+ // to what's happening in GetFocus
+ pEd->GetModifyHdl().Call(pEd);
+ pEd->GrabFocus();
+ pEd->SetSelection(theSel);
+ } // if( pEd )
+}
+// -----------------------------------------------------------------------------
+const FormulaHelper& FormulaDlg_Impl::GetFormulaHelper() const
+{
+ return m_aFormulaHelper;
+}
+//============================================================================
+FormulaModalDialog::FormulaModalDialog( Window* pParent
+ , bool _bSupportFunctionResult
+ , bool _bSupportResult
+ , bool _bSupportMatrix
+ , IFormulaEditorHelper* _pHelper
+ , IFunctionManager* _pFunctionMgr
+ , IControlReferenceHandler* _pDlg ) :
+ ModalDialog( pParent, ModuleRes(RID_FORMULADLG_FORMULA_MODAL) ),
+ m_pImpl( new FormulaDlg_Impl(this,_bSupportFunctionResult
+ , _bSupportResult
+ , _bSupportMatrix
+ ,_pHelper,_pFunctionMgr,_pDlg))
+{
+ FreeResource();
+ SetText(m_pImpl->aTitle1);
+}
+FormulaModalDialog::~FormulaModalDialog()
+{
+}
+// -----------------------------------------------------------------------------
+void FormulaModalDialog::Update(const String& _sExp)
+{
+ m_pImpl->Update(_sExp);
+}
+
+// -----------------------------------------------------------------------------
+void FormulaModalDialog::SetMeText(const String& _sText)
+{
+ m_pImpl->SetMeText(_sText);
+}
+
+// -----------------------------------------------------------------------------
+FormulaDlgMode FormulaModalDialog::SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,BOOL bMatrix,BOOL _bSelect,BOOL _bUpdate)
+{
+ return m_pImpl->SetMeText(_sText,PrivStart, PrivEnd,bMatrix,_bSelect,_bUpdate);
+}
+// -----------------------------------------------------------------------------
+void FormulaModalDialog::CheckMatrix()
+{
+ m_pImpl->aBtnMatrix.Check();
+}
+// -----------------------------------------------------------------------------
+BOOL FormulaModalDialog::CheckMatrix(String& aFormula)
+{
+ return m_pImpl->CheckMatrix(aFormula);
+}
+// -----------------------------------------------------------------------------
+String FormulaModalDialog::GetMeText() const
+{
+ return m_pImpl->pMEdit->GetText();
+}
+// -----------------------------------------------------------------------------
+void FormulaModalDialog::Update()
+{
+ m_pImpl->Update();
+}
+// -----------------------------------------------------------------------------
+const FormulaHelper& FormulaModalDialog::GetFormulaHelper() const
+{
+ return m_pImpl->GetFormulaHelper();
+}
+// -----------------------------------------------------------------------------
+BOOL FormulaModalDialog::isUserMatrix() const
+{
+ return m_pImpl->bUserMatrixFlag;
+}
+void FormulaModalDialog::DoEnter(BOOL _bOk)
+{
+ m_pImpl->DoEnter(_bOk);
+}
+::std::pair<RefButton*,RefEdit*> FormulaModalDialog::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton )
+{
+ return m_pImpl->RefInputStartBefore( pEdit, pButton );
+}
+void FormulaModalDialog::RefInputStartAfter( RefEdit* pEdit, RefButton* pButton )
+{
+ m_pImpl->RefInputStartAfter( pEdit, pButton );
+}
+void FormulaModalDialog::RefInputDoneAfter( BOOL bForced )
+{
+ m_pImpl->RefInputDoneAfter( bForced );
+}
+
+ULONG FormulaModalDialog::FindFocusWin(Window *pWin)
+{
+ return m_pImpl->FindFocusWin( pWin );
+}
+
+void FormulaModalDialog::SetFocusWin(Window *pWin,ULONG nUniqueId)
+{
+ if(pWin->GetUniqueId()==nUniqueId)
+ {
+ pWin->GrabFocus();
+ }
+ else
+ {
+ USHORT nCount=pWin->GetChildCount();
+
+ for(USHORT i=0;i<nCount;i++)
+ {
+ Window* pChild=pWin->GetChild(i);
+ SetFocusWin(pChild,nUniqueId);
+ }
+ }
+}
+
+
+long FormulaModalDialog::PreNotify( NotifyEvent& rNEvt )
+{
+ m_pImpl->PreNotify( rNEvt );
+
+ return ModalDialog::PreNotify(rNEvt);
+}
+
+void FormulaModalDialog::HighlightFunctionParas(const String& aFormula)
+{
+ m_pImpl->m_pHelper->showReference(aFormula);
+}
+
+void FormulaModalDialog::disableOk()
+{
+ m_pImpl->aBtnEnd.Disable();
+}
+// -----------------------------------------------------------------------------
+const IFunctionDescription* FormulaModalDialog::getCurrentFunctionDescription() const
+{
+ OSL_VERIFY(!m_pImpl->pFuncDesc || m_pImpl->pFuncDesc->getSuppressedArgumentCount() == m_pImpl->nArgs);
+ return m_pImpl->pFuncDesc;
+}
+// -----------------------------------------------------------------------------
+void FormulaModalDialog::UpdateParaWin(const Selection& _rSelection,const String& _sRefStr)
+{
+ m_pImpl->UpdateParaWin(_rSelection,_sRefStr);
+}
+BOOL FormulaModalDialog::UpdateParaWin(Selection& _rSelection)
+{
+ return m_pImpl->UpdateParaWin(_rSelection);
+}
+// -----------------------------------------------------------------------------
+RefEdit* FormulaModalDialog::GetActiveEdit()
+{
+ return m_pImpl->pParaWin->GetActiveEdit();
+}
+// -----------------------------------------------------------------------------
+void FormulaModalDialog::SetEdSelection()
+{
+ m_pImpl->SetEdSelection();
+}
+
+// --------------------------------------------------------------------------
+// Initialisierung / gemeinsaME Funktionen fuer Dialog
+// --------------------------------------------------------------------------
+FormulaDlg::FormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
+ Window* pParent
+ , bool _bSupportFunctionResult
+ , bool _bSupportResult
+ , bool _bSupportMatrix
+ , IFormulaEditorHelper* _pHelper,IFunctionManager* _pFunctionMgr,IControlReferenceHandler* _pDlg ) :
+ SfxModelessDialog( pB, pCW, pParent, ModuleRes(RID_FORMULADLG_FORMULA) ),
+ m_pImpl( new FormulaDlg_Impl(this, _bSupportFunctionResult
+ , _bSupportResult
+ , _bSupportMatrix
+ ,_pHelper,_pFunctionMgr,_pDlg))
+{
+ FreeResource();
+ if(GetHelpId()==0) //Hack, da im SfxModelessDialog die HelpId
+ SetHelpId(GetUniqueId()); //fuer einen ModelessDialog entfernt und
+ //in eine UniqueId gewandelt wird, machen
+ //wir das an dieser Stelle rueckgaengig.
+ SetText(m_pImpl->aTitle1);
+}
+
+FormulaDlg::~FormulaDlg()
+{
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg::Update(const String& _sExp)
+{
+ m_pImpl->Update(_sExp);
+}
+
+// -----------------------------------------------------------------------------
+void FormulaDlg::SetMeText(const String& _sText)
+{
+ m_pImpl->SetMeText(_sText);
+}
+
+// -----------------------------------------------------------------------------
+FormulaDlgMode FormulaDlg::SetMeText(const String& _sText,xub_StrLen PrivStart, xub_StrLen PrivEnd,BOOL bMatrix,BOOL _bSelect,BOOL _bUpdate)
+{
+ return m_pImpl->SetMeText(_sText,PrivStart, PrivEnd,bMatrix,_bSelect,_bUpdate);
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg::CheckMatrix()
+{
+ m_pImpl->aBtnMatrix.Check();
+}
+// -----------------------------------------------------------------------------
+BOOL FormulaDlg::CheckMatrix(String& aFormula)
+{
+ return m_pImpl->CheckMatrix(aFormula);
+}
+// -----------------------------------------------------------------------------
+String FormulaDlg::GetMeText() const
+{
+ return m_pImpl->pMEdit->GetText();
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg::Update()
+{
+ m_pImpl->Update();
+ m_pImpl->aTimer.SetTimeout(200);
+ m_pImpl->aTimer.SetTimeoutHdl(LINK( this, FormulaDlg, UpdateFocusHdl));
+ m_pImpl->aTimer.Start();
+}
+
+// -----------------------------------------------------------------------------
+BOOL FormulaDlg::isUserMatrix() const
+{
+ return m_pImpl->bUserMatrixFlag;
+}
+void FormulaDlg::DoEnter(BOOL _bOk)
+{
+ m_pImpl->DoEnter(_bOk);
+}
+::std::pair<RefButton*,RefEdit*> FormulaDlg::RefInputStartBefore( RefEdit* pEdit, RefButton* pButton )
+{
+ return m_pImpl->RefInputStartBefore( pEdit, pButton );
+}
+void FormulaDlg::RefInputStartAfter( RefEdit* pEdit, RefButton* pButton )
+{
+ m_pImpl->RefInputStartAfter( pEdit, pButton );
+}
+void FormulaDlg::RefInputDoneAfter( BOOL bForced )
+{
+ m_pImpl->RefInputDoneAfter( bForced );
+}
+
+ULONG FormulaDlg::FindFocusWin(Window *pWin)
+{
+ return m_pImpl->FindFocusWin( pWin );
+}
+
+void FormulaDlg::SetFocusWin(Window *pWin,ULONG nUniqueId)
+{
+ if(pWin->GetUniqueId()==nUniqueId)
+ {
+ pWin->GrabFocus();
+ }
+ else
+ {
+ USHORT nCount=pWin->GetChildCount();
+
+ for(USHORT i=0;i<nCount;i++)
+ {
+ Window* pChild=pWin->GetChild(i);
+ SetFocusWin(pChild,nUniqueId);
+ }
+ }
+}
+
+
+long FormulaDlg::PreNotify( NotifyEvent& rNEvt )
+{
+ m_pImpl->PreNotify( rNEvt );
+ return SfxModelessDialog::PreNotify(rNEvt);
+}
+
+void FormulaDlg::HighlightFunctionParas(const String& aFormula)
+{
+ m_pImpl->m_pHelper->showReference(aFormula);
+}
+
+void FormulaDlg::disableOk()
+{
+ m_pImpl->aBtnEnd.Disable();
+}
+// -----------------------------------------------------------------------------
+const IFunctionDescription* FormulaDlg::getCurrentFunctionDescription() const
+{
+ OSL_VERIFY(!m_pImpl->pFuncDesc || m_pImpl->pFuncDesc->getSuppressedArgumentCount() == m_pImpl->nArgs);
+ return m_pImpl->pFuncDesc;
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg::UpdateParaWin(const Selection& _rSelection,const String& _sRefStr)
+{
+ m_pImpl->UpdateParaWin(_rSelection,_sRefStr);
+}
+BOOL FormulaDlg::UpdateParaWin(Selection& _rSelection)
+{
+ return m_pImpl->UpdateParaWin(_rSelection);
+}
+// -----------------------------------------------------------------------------
+RefEdit* FormulaDlg::GetActiveEdit()
+{
+ return m_pImpl->pParaWin->GetActiveEdit();
+}
+// -----------------------------------------------------------------------------
+const FormulaHelper& FormulaDlg::GetFormulaHelper() const
+{
+ return m_pImpl->GetFormulaHelper();
+}
+// -----------------------------------------------------------------------------
+void FormulaDlg::SetEdSelection()
+{
+ m_pImpl->SetEdSelection();
+}
+IMPL_LINK( FormulaDlg, UpdateFocusHdl, Timer*, EMPTYARG )
+{
+ FormEditData* pData = m_pImpl->m_pHelper->getFormEditData();
+
+ if (pData) // wird nicht ueber Close zerstoert;
+ {
+ m_pImpl->m_pHelper->setReferenceInput(pData);
+ ULONG nUniqueId=pData->GetUniqueId();
+ SetFocusWin(this,nUniqueId);
+ }
+ return 0;
+}
+
+// -----------------------------------------------------------------------------
+// -----------------------------------------------------------------------------
+void FormEditData::SaveValues()
+{
+ FormEditData* pTemp = new FormEditData(*this);
+
+ Reset();
+ pParent = pTemp;
+}
+// -----------------------------------------------------------------------------
+void FormEditData::Reset()
+{
+ pParent = NULL;
+ nMode = 0;
+ nFStart = 0;
+ nCatSel = 1; //! oder 0 (zuletzt benutzte)
+ nFuncSel = 0;
+ nOffset = 0;
+ nEdFocus = 0;
+ bMatrix =FALSE;
+ nUniqueId=0;
+ aSelection.Min()=0;
+ aSelection.Max()=0;
+ aUndoStr.Erase();
+}
+// -----------------------------------------------------------------------------
+void FormEditData::RestoreValues()
+{
+ FormEditData* pTemp = pParent;
+ DBG_ASSERT(pTemp,"RestoreValues ohne Parent");
+ if (pTemp)
+ {
+ *this = *pTemp;
+ pTemp->pParent = NULL; // sonst wird der auch geloescht!
+ delete pTemp;
+ }
+}
+// -----------------------------------------------------------------------------
+const FormEditData& FormEditData::operator=( const FormEditData& r )
+{
+ pParent = r.pParent;
+ nMode = r.nMode;
+ nFStart = r.nFStart;
+ nCatSel = r.nCatSel;
+ nFuncSel = r.nFuncSel;
+ nOffset = r.nOffset;
+ nEdFocus = r.nEdFocus;
+ aUndoStr = r.aUndoStr;
+ bMatrix = r.bMatrix ;
+ nUniqueId = r.nUniqueId;
+ aSelection = r.aSelection;
+ return *this;
+}
+// -----------------------------------------------------------------------------
+FormEditData::FormEditData()
+{
+ Reset();
+}
+
+FormEditData::~FormEditData()
+{
+ delete pParent;
+}
+
+FormEditData::FormEditData( const FormEditData& r )
+{
+ *this = r;
+}
+
+// -----------------------------------------------------------------------------
+} // formula
+// -----------------------------------------------------------------------------
diff --git a/formula/source/ui/dlg/funcpage.cxx b/formula/source/ui/dlg/funcpage.cxx
new file mode 100644
index 000000000000..3633afa29316
--- /dev/null
+++ b/formula/source/ui/dlg/funcpage.cxx
@@ -0,0 +1,265 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_formula.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+#include "formula/IFunctionDescription.hxx"
+
+#include "funcpage.hxx"
+#include "formdlgs.hrc"
+#include "ForResId.hrc"
+#include "ModuleHelper.hxx"
+//============================================================================
+namespace formula
+{
+
+FormulaListBox::FormulaListBox( Window* pParent, WinBits nWinStyle):
+ ListBox(pParent,nWinStyle)
+{}
+
+FormulaListBox::FormulaListBox( Window* pParent, const ResId& rResId ):
+ ListBox(pParent,rResId)
+{}
+
+void FormulaListBox::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyEvent aKEvt=rKEvt;
+ //ListBox::KeyInput(rKEvt);
+
+ if(aKEvt.GetCharCode()==' ')
+ DoubleClick();
+}
+
+long FormulaListBox::PreNotify( NotifyEvent& rNEvt )
+{
+ NotifyEvent aNotifyEvt=rNEvt;
+
+ long nResult=ListBox::PreNotify(rNEvt);
+
+ USHORT nSwitch=aNotifyEvt.GetType();
+ if(nSwitch==EVENT_KEYINPUT)
+ {
+ KeyInput(*aNotifyEvt.GetKeyEvent());
+ }
+ return nResult;
+}
+
+
+
+//============================================================================
+
+inline USHORT Lb2Cat( USHORT nLbPos )
+{
+ // Kategorie 0 == LRU, sonst Categories == LbPos-1
+ if ( nLbPos > 0 )
+ nLbPos -= 1;
+
+ return nLbPos;
+}
+
+//============================================================================
+
+FuncPage::FuncPage(Window* pParent,const IFunctionManager* _pFunctionManager):
+ TabPage(pParent,ModuleRes(RID_FORMULATAB_FUNCTION)),
+ //
+ aFtCategory ( this, ModuleRes( FT_CATEGORY ) ),
+ aLbCategory ( this, ModuleRes( LB_CATEGORY ) ),
+ aFtFunction ( this, ModuleRes( FT_FUNCTION ) ),
+ aLbFunction ( this, ModuleRes( LB_FUNCTION ) ),
+ m_pFunctionManager(_pFunctionManager)
+{
+ FreeResource();
+ m_aSmartHelpId = aLbFunction.GetSmartHelpId();
+ aLbFunction.SetSmartUniqueId(m_aSmartHelpId);
+
+ InitLRUList();
+
+ const sal_uInt32 nCategoryCount = m_pFunctionManager->getCount();
+ for(sal_uInt32 j= 0; j < nCategoryCount; ++j)
+ {
+ const IFunctionCategory* pCategory = m_pFunctionManager->getCategory(j);
+ aLbCategory.SetEntryData(aLbCategory.InsertEntry(pCategory->getName()),(void*)pCategory);
+ }
+
+ aLbCategory.SelectEntryPos(1);
+ UpdateFunctionList();
+ aLbCategory.SetSelectHdl( LINK( this, FuncPage, SelHdl ) );
+ aLbFunction.SetSelectHdl( LINK( this, FuncPage, SelHdl ) );
+ aLbFunction.SetDoubleClickHdl( LINK( this, FuncPage, DblClkHdl ) );
+}
+// -----------------------------------------------------------------------------
+void FuncPage::impl_addFunctions(const IFunctionCategory* _pCategory)
+{
+ const sal_uInt32 nCount = _pCategory->getCount();
+ for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ {
+ TFunctionDesc pDesc(_pCategory->getFunction(i));
+ aLbFunction.SetEntryData(
+ aLbFunction.InsertEntry(pDesc->getFunctionName() ),(void*)pDesc );
+ } // for(sal_uInt32 i = 0 ; i < nCount; ++i)
+}
+
+void FuncPage::UpdateFunctionList()
+{
+ USHORT nSelPos = aLbCategory.GetSelectEntryPos();
+ const IFunctionCategory* pCategory = static_cast<const IFunctionCategory*>(aLbCategory.GetEntryData(nSelPos));
+ USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ ? Lb2Cat( nSelPos ) : 0;
+
+ (void)nCategory;
+
+ aLbFunction.Clear();
+ aLbFunction.SetUpdateMode( FALSE );
+ //------------------------------------------------------
+
+ if ( nSelPos > 0 )
+ {
+ if ( pCategory == NULL )
+ {
+ const sal_uInt32 nCount = m_pFunctionManager->getCount();
+ for(sal_uInt32 i = 0 ; i < nCount; ++i)
+ {
+ impl_addFunctions(m_pFunctionManager->getCategory(i));
+ }
+ }
+ else
+ {
+ impl_addFunctions(pCategory);
+ }
+ }
+ else // LRU-Liste
+ {
+ ::std::vector< TFunctionDesc >::iterator aIter = aLRUList.begin();
+ ::std::vector< TFunctionDesc >::iterator aEnd = aLRUList.end();
+
+ for ( ; aIter != aEnd; ++aIter )
+ {
+ const IFunctionDescription* pDesc = *aIter;
+ if (pDesc) // may be null if a function is no longer available
+ {
+ aLbFunction.SetEntryData(
+ aLbFunction.InsertEntry( pDesc->getFunctionName() ), (void*)pDesc );
+ }
+ }
+ }
+
+ //------------------------------------------------------
+ aLbFunction.SetUpdateMode( TRUE );
+ aLbFunction.SelectEntryPos(0);
+
+ if(IsVisible()) SelHdl(&aLbFunction);
+}
+
+IMPL_LINK( FuncPage, SelHdl, ListBox*, pLb )
+{
+ if(pLb==&aLbFunction)
+ {
+ const IFunctionDescription* pDesc = GetFuncDesc( GetFunction() );
+ if ( pDesc )
+ {
+ const long nHelpId = pDesc->getHelpId();
+ if ( nHelpId )
+ aLbFunction.SetSmartHelpId(SmartId(nHelpId));
+ }
+ aSelectionLink.Call(this);
+ }
+ else
+ {
+ aLbFunction.SetSmartHelpId(m_aSmartHelpId);
+ UpdateFunctionList();
+ }
+ return 0;
+}
+
+IMPL_LINK( FuncPage, DblClkHdl, ListBox*, EMPTYARG )
+{
+ aDoubleClickLink.Call(this);
+ return 0;
+}
+
+void FuncPage::SetCategory(USHORT nCat)
+{
+ aLbCategory.SelectEntryPos(nCat);
+ UpdateFunctionList();
+}
+USHORT FuncPage::GetFuncPos(const IFunctionDescription* _pDesc)
+{
+ return aLbFunction.GetEntryPos(_pDesc);
+}
+void FuncPage::SetFunction(USHORT nFunc)
+{
+ aLbFunction.SelectEntryPos(nFunc);
+}
+
+void FuncPage::SetFocus()
+{
+ aLbFunction.GrabFocus();
+}
+
+USHORT FuncPage::GetCategory()
+{
+ return aLbCategory.GetSelectEntryPos();
+}
+
+USHORT FuncPage::GetFunction()
+{
+ return aLbFunction.GetSelectEntryPos();
+}
+
+USHORT FuncPage::GetFunctionEntryCount()
+{
+ return aLbFunction.GetSelectEntryCount();
+}
+
+String FuncPage::GetSelFunctionName() const
+{
+ return aLbFunction.GetSelectEntry();
+}
+const IFunctionDescription* FuncPage::GetFuncDesc( USHORT nPos ) const
+{
+ // nicht schoen, aber hoffentlich selten
+ return (const IFunctionDescription*) aLbFunction.GetEntryData(nPos);
+}
+
+void FuncPage::InitLRUList()
+{
+ ::std::vector< const IFunctionDescription*> aRUFunctions;
+ m_pFunctionManager->fillLastRecentlyUsedFunctions(aLRUList);
+}
+
+
+} // formula
+
diff --git a/formula/source/ui/dlg/funcpage.hxx b/formula/source/ui/dlg/funcpage.hxx
new file mode 100644
index 000000000000..09f77cc81019
--- /dev/null
+++ b/formula/source/ui/dlg/funcpage.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef FORMULA_FUNCPAGE_HXX
+#define FORMULA_FUNCPAGE_HXX
+
+#include <svtools/stdctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/tabpage.hxx>
+
+#include <vcl/tabctrl.hxx>
+#include <vcl/button.hxx>
+#include <svtools/svtreebx.hxx>
+
+#include <boost/shared_ptr.hpp>
+#include <vector>
+#include "ModuleHelper.hxx"
+//============================================================================
+namespace formula
+{
+
+class IFunctionDescription;
+class IFunctionManager;
+class IFunctionCategory;
+
+//============================================================================
+class FormulaListBox : public ListBox
+{
+protected:
+
+ virtual void KeyInput( const KeyEvent& rKEvt );
+ virtual long PreNotify( NotifyEvent& rNEvt );
+
+public:
+ FormulaListBox( Window* pParent, WinBits nWinStyle = WB_BORDER );
+
+ FormulaListBox( Window* pParent, const ResId& rResId );
+
+};
+
+
+
+typedef const IFunctionDescription* TFunctionDesc;
+//============================================================================
+class FuncPage : public TabPage
+{
+private:
+ OModuleClient m_aModuleClient;
+ Link aDoubleClickLink;
+ Link aSelectionLink;
+ FixedText aFtCategory;
+ ListBox aLbCategory;
+ FixedText aFtFunction;
+ FormulaListBox aLbFunction;
+ const IFunctionManager*
+ m_pFunctionManager;
+
+ ::std::vector< TFunctionDesc > aLRUList;
+ SmartId m_aSmartHelpId;
+
+
+ void impl_addFunctions(const IFunctionCategory* _pCategory);
+ DECL_LINK( SelHdl, ListBox* );
+ DECL_LINK( DblClkHdl, ListBox* );
+
+protected:
+
+ void UpdateFunctionList();
+ void InitLRUList();
+
+
+public:
+
+ FuncPage( Window* pParent,const IFunctionManager* _pFunctionManager);
+
+ void SetCategory(USHORT nCat);
+ void SetFunction(USHORT nFunc);
+ void SetFocus();
+ USHORT GetCategory();
+ USHORT GetFunction();
+ USHORT GetFunctionEntryCount();
+
+ USHORT GetFuncPos(const IFunctionDescription* _pDesc);
+ const IFunctionDescription* GetFuncDesc( USHORT nPos ) const;
+ String GetSelFunctionName() const;
+
+ void SetDoubleClickHdl( const Link& rLink ) { aDoubleClickLink = rLink; }
+ const Link& GetDoubleClickHdl() const { return aDoubleClickLink; }
+
+ void SetSelectHdl( const Link& rLink ) { aSelectionLink = rLink; }
+ const Link& GetSelectHdl() const { return aSelectionLink; }
+
+};
+
+} // formula
+#endif
+
diff --git a/formula/source/ui/dlg/funcutl.cxx b/formula/source/ui/dlg/funcutl.cxx
new file mode 100644
index 000000000000..4ba8d87c139b
--- /dev/null
+++ b/formula/source/ui/dlg/funcutl.cxx
@@ -0,0 +1,1106 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_formula.hxx"
+
+//----------------------------------------------------------------------------
+#include <vcl/sound.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/scrbar.hxx>
+
+#include "formula/funcutl.hxx"
+#include "formula/IControlReferenceHandler.hxx"
+#include "ControlHelper.hxx"
+#include "ModuleHelper.hxx"
+#include "ForResId.hrc"
+
+
+namespace formula
+{
+//============================================================================
+// class ValWnd
+//----------------------------------------------------------------------------
+
+ValWnd::ValWnd( Window* pParent, const ResId& rId ) : Window( pParent, rId )
+{
+ Font aFnt( GetFont() );
+ aFnt.SetTransparent( TRUE );
+ aFnt.SetWeight( WEIGHT_LIGHT );
+ if ( pParent->IsBackground() )
+ {
+ Wallpaper aBack = pParent->GetBackground();
+ SetFillColor( aBack.GetColor() );
+ SetBackground( aBack );
+ aFnt.SetFillColor( aBack.GetColor() );
+ }
+ else
+ {
+ SetFillColor();
+ SetBackground();
+ }
+ SetFont( aFnt );
+ SetLineColor();
+
+ Size aSzWnd = GetOutputSizePixel();
+ long nHeight = GetTextHeight();
+ long nDiff = aSzWnd.Height()-nHeight;
+
+ aRectOut = Rectangle( Point( 1, ( nDiff<2 ) ? 1 : nDiff/2),
+ Size ( aSzWnd.Width()-2, nHeight ) );
+ SetClipRegion( Region( aRectOut ) );
+}
+
+//----------------------------------------------------------------------------
+
+void __EXPORT ValWnd::Paint( const Rectangle& )
+{
+ DrawText( aRectOut.TopLeft(), aStrValue );
+}
+
+//----------------------------------------------------------------------------
+
+void ValWnd::SetValue( const String& rStrVal )
+{
+ if ( aStrValue != rStrVal )
+ {
+ aStrValue = rStrVal;
+ DrawRect( aRectOut ); // alten Text loeschen
+ Paint( aRectOut ); // und neu malen
+ }
+}
+
+//============================================================================
+// class ArgEdit
+//----------------------------------------------------------------------------
+
+ArgEdit::ArgEdit( Window* pParent, const ResId& rResId )
+ : RefEdit( pParent, rResId ),
+ pEdPrev ( NULL ),
+ pEdNext ( NULL ),
+ pSlider ( NULL ),
+ nArgs ( 0 )
+{
+}
+
+//----------------------------------------------------------------------------
+
+void ArgEdit::Init( ArgEdit* pPrevEdit, ArgEdit* pNextEdit,
+ ScrollBar& rArgSlider, USHORT nArgCount )
+{
+ pEdPrev = pPrevEdit;
+ pEdNext = pNextEdit;
+ pSlider = &rArgSlider;
+ nArgs = nArgCount;
+}
+
+//----------------------------------------------------------------------------
+
+// Cursorsteuerung fuer EditFelder im Argument-Dialog
+
+void __EXPORT ArgEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ KeyCode aCode = rKEvt.GetKeyCode();
+ BOOL bUp = (aCode.GetCode() == KEY_UP);
+ BOOL bDown = (aCode.GetCode() == KEY_DOWN);
+ ArgEdit* pEd = NULL;
+
+ if ( pSlider
+ && ( !aCode.IsShift() && !aCode.IsMod1() && !aCode.IsMod2() )
+ && ( bUp || bDown ) )
+ {
+ if ( nArgs > 1 )
+ {
+ long nThumb = pSlider->GetThumbPos();
+ BOOL bDoScroll = FALSE;
+ BOOL bChangeFocus = FALSE;
+
+ if ( bDown )
+ {
+ if ( nArgs > 4 )
+ {
+ if ( !pEdNext )
+ {
+ nThumb++;
+ bDoScroll = ( nThumb+3 < (long)nArgs );
+ }
+ else
+ {
+ pEd = pEdNext;
+ bChangeFocus = TRUE;
+ }
+ }
+ else if ( pEdNext )
+ {
+ pEd = pEdNext;
+ bChangeFocus = TRUE;
+ }
+ }
+ else // if ( bUp )
+ {
+ if ( nArgs > 4 )
+ {
+ if ( !pEdPrev )
+ {
+ nThumb--;
+ bDoScroll = ( nThumb >= 0 );
+ }
+ else
+ {
+ pEd = pEdPrev;
+ bChangeFocus = TRUE;
+ }
+ }
+ else if ( pEdPrev )
+ {
+ pEd = pEdPrev;
+ bChangeFocus = TRUE;
+ }
+ }
+
+ if ( bDoScroll )
+ {
+ pSlider->SetThumbPos( nThumb );
+ ((Link&)pSlider->GetEndScrollHdl()).Call( pSlider );
+ }
+ else if ( bChangeFocus )
+ {
+ pEd->GrabFocus();
+ }
+ else
+ Sound::Beep();
+ }
+ else
+ Sound::Beep();
+ }
+ else
+ RefEdit::KeyInput( rKEvt );
+}
+
+
+
+
+/*************************************************************************
+#* Member: ArgInput Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Konstruktor der Klasse ArgInput
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ArgInput::ArgInput()
+{
+ pFtArg=NULL;
+ pBtnFx=NULL;
+ pEdArg=NULL;
+ pRefBtn=NULL;
+}
+
+/*************************************************************************
+#* Member: InitArgInput Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Initialisiert die Pointer der Klasse
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ArgInput::InitArgInput(FixedText* pftArg,
+ ImageButton* pbtnFx,
+ ArgEdit* pedArg,
+ RefButton* prefBtn)
+{
+ pFtArg =pftArg;
+ pBtnFx =pbtnFx;
+ pEdArg =pedArg;
+ pRefBtn=prefBtn;
+
+ if(pBtnFx!=NULL)
+ {
+ pBtnFx->SetClickHdl ( LINK( this, ArgInput, FxBtnClickHdl ) );
+ pBtnFx->SetGetFocusHdl( LINK( this, ArgInput, FxBtnFocusHdl ) );
+ }
+ if(pRefBtn!=NULL)
+ {
+ pRefBtn->SetClickHdl ( LINK( this, ArgInput, RefBtnClickHdl ) );
+ pRefBtn->SetGetFocusHdl( LINK( this, ArgInput, RefBtnFocusHdl ) );
+ }
+ if(pEdArg!=NULL)
+ {
+ pEdArg->SetGetFocusHdl ( LINK( this, ArgInput, EdFocusHdl ) );
+ pEdArg->SetModifyHdl ( LINK( this, ArgInput, EdModifyHdl ) );
+ }
+
+}
+
+/*************************************************************************
+#* Member: SetArgName Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Setzt den Namen fuer das Argument
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::SetArgName(const String &aArg)
+{
+ if(pFtArg !=NULL) pFtArg->SetText(aArg );
+}
+
+/*************************************************************************
+#* Member: GetArgName Datum:06.02.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Liefert den Namen fuer das Argument zurueck
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+String ArgInput::GetArgName()
+{
+ String aPrivArgName;
+ if(pFtArg !=NULL)
+ aPrivArgName=pFtArg->GetText();
+
+ return aPrivArgName;
+}
+
+
+/*************************************************************************
+#* Member: SetArgName Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Setzt den Namen fuer das Argument
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::SetArgNameFont (const Font &aFont)
+{
+ if(pFtArg !=NULL) pFtArg->SetFont(aFont);
+}
+
+/*************************************************************************
+#* Member: SetArgSelection Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Stellt die Selection fuer die EditBox ein.
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::SetArgSelection (const Selection& rSel )
+{
+ if(pEdArg !=NULL) pEdArg ->SetSelection(rSel );
+}
+
+/*************************************************************************
+#* Member: SetArgSelection Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Liefert die Selection fuer die EditBox zurueck.
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+Selection ArgInput::GetArgSelection ()
+{
+ Selection aSel;
+ if(pEdArg !=NULL) aSel=pEdArg ->GetSelection();
+ return aSel;
+}
+
+/*************************************************************************
+#* Member: SetArgSelection Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Ersetzt die Selection in der EditBox.
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::ReplaceSelOfArg(const String& rStr )
+{
+ if(pEdArg !=NULL) pEdArg ->ReplaceSelected(rStr );
+}
+
+
+
+/*************************************************************************
+#* Member: SetArgVal Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Setzt den Wert fuer das Argument
+#*
+#* Input: String
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::SetArgVal(const String &aVal)
+{
+ if(pEdArg !=NULL)
+ {
+ pEdArg ->SetRefString(aVal );
+ }
+}
+
+/*************************************************************************
+#* Member: SetArgName Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Liefert den Wert fuer das Argument
+#*
+#* Input: ---
+#*
+#* Output: String
+#*
+#************************************************************************/
+String ArgInput::GetArgVal()
+{
+ String aResult;
+ if(pEdArg!=NULL)
+ {
+ aResult=pEdArg->GetText();
+ }
+ return aResult;
+}
+
+/*************************************************************************
+#* Member: SetArgName Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Versteckt die Controls
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::Hide()
+{
+ if ( pFtArg && pBtnFx && pEdArg && pRefBtn)
+ {
+ pFtArg->Hide();
+ pBtnFx->Hide();
+ pEdArg->Hide();
+ pRefBtn->Hide();
+ }
+}
+
+/*************************************************************************
+#* Member: SetArgName Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Zaubert die Controls wieder hervor.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::Show()
+{
+ if ( pFtArg && pBtnFx && pEdArg && pRefBtn)
+ {
+ pFtArg->Show();
+ pBtnFx->Show();
+ pEdArg->Show();
+ pRefBtn->Show();
+ }
+}
+
+/*************************************************************************
+#* Member: FxClick Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Gibt den Event weiter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::FxClick()
+{
+ aFxClickLink.Call(this);
+}
+
+/*************************************************************************
+#* Member: RefClick Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Gibt den Event weiter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::RefClick()
+{
+ aRefClickLink.Call(this);
+}
+
+/*************************************************************************
+#* Member: FxFocus Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Gibt den Event weiter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::FxFocus()
+{
+ aFxFocusLink.Call(this);
+}
+
+/*************************************************************************
+#* Member: RefFocus Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Gibt den Event weiter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::RefFocus()
+{
+ aRefFocusLink.Call(this);
+}
+
+/*************************************************************************
+#* Member: EdFocus Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Gibt den Event weiter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::EdFocus()
+{
+ aEdFocusLink.Call(this);
+}
+
+/*************************************************************************
+#* Member: EdModify Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Gibt den Event weiter.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ArgInput::EdModify()
+{
+ aEdModifyLink.Call(this);
+}
+
+/*************************************************************************
+#* Handle: FxBtnHdl Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Handle fuer Fx-Button Click-Event.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( ArgInput, FxBtnClickHdl, ImageButton*, pBtn )
+{
+ if(pBtn==pBtnFx) FxClick();
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: RefBtnClickHdl Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Handle fuer Fx-Button Click-Event.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( ArgInput, RefBtnClickHdl,RefButton*, pBtn )
+{
+ if(pRefBtn==pBtn) RefClick();
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: FxBtnFocusHdl Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Handle fuer Fx-Button Focus-Event.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( ArgInput, FxBtnFocusHdl, ImageButton*, pBtn )
+{
+ if(pBtn==pBtnFx) FxFocus();
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: RefBtnFocusHdl Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Handle fuer Fx-Button Focus-Event.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( ArgInput, RefBtnFocusHdl,RefButton*, pBtn )
+{
+ if(pRefBtn==pBtn) RefFocus();
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: EdFocusHdl Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Handle fuer Fx-Button Focus-Event.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( ArgInput, EdFocusHdl, ArgEdit*, pEd )
+{
+ if(pEd==pEdArg) EdFocus();
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: RefBtnClickHdl Datum:13.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ArgInput
+#*
+#* Funktion: Handle fuer Fx-Button Focus-Event.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( ArgInput, EdModifyHdl,ArgEdit*, pEd )
+{
+ if(pEd==pEdArg) EdModify();
+
+ return 0;
+}
+
+/*************************************************************************
+#* Member: EditBox Datum:20.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Konstruktor der Klasse ArgInput
+#*
+#* Input: Parent, Window-Style
+#*
+#* Output: ---
+#*
+#************************************************************************/
+EditBox::EditBox( Window* pParent,WinBits nWinStyle)
+ :Control(pParent,nWinStyle|WB_DIALOGCONTROL)
+{
+ pMEdit=new MultiLineEdit(this,WB_LEFT | WB_VSCROLL | (nWinStyle & WB_TABSTOP) |
+ WB_NOBORDER | WB_NOHIDESELECTION | WB_IGNORETAB);
+
+ pMEdit->Show();
+ aOldSel=pMEdit->GetSelection();
+}
+
+/*************************************************************************
+#* Member: EditBox Datum:20.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Konstruktor der Klasse ArgInput
+#*
+#* Input: Parent, Resource
+#*
+#* Output: ---
+#*
+#************************************************************************/
+EditBox::EditBox( Window* pParent, const ResId& rResId )
+ :Control(pParent,rResId),
+ bMouseFlag(FALSE)
+{
+ WinBits nStyle=GetStyle();
+ SetStyle( nStyle| WB_DIALOGCONTROL);
+
+ pMEdit=new MultiLineEdit(this,WB_LEFT | WB_VSCROLL | (nStyle & WB_TABSTOP) |
+ WB_NOBORDER | WB_NOHIDESELECTION | WB_IGNORETAB);
+ pMEdit->Show();
+ aOldSel=pMEdit->GetSelection();
+ Resize();
+ WinBits nWinStyle=GetStyle() | WB_DIALOGCONTROL;
+ SetStyle(nWinStyle);
+
+ // #105582# the HelpId from the resource must be set for the MultiLineEdit,
+ // not for the control that contains it.
+ pMEdit->SetSmartHelpId( GetSmartHelpId() );
+ SetSmartHelpId( SmartId() );
+}
+
+EditBox::~EditBox()
+{
+ MultiLineEdit* pTheEdit=pMEdit;
+ pMEdit->Disable();
+ pMEdit=NULL;
+ delete pTheEdit;
+}
+/*************************************************************************
+#* Member: EditBox Datum:20.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Wenn sich die Selektion geaendert hat, so wird
+#* diese Funktion aufgerufen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void EditBox::SelectionChanged()
+{
+ aSelChangedLink.Call(this);
+}
+
+/*************************************************************************
+#* Member: EditBox Datum:20.05.98
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Wenn sich die Groesse geaendert hat, so muss
+#* auch der MultiLineEdit angepasst werden..
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void EditBox::Resize()
+{
+ Size aSize=GetOutputSizePixel();
+ if(pMEdit!=NULL) pMEdit->SetOutputSizePixel(aSize);
+}
+
+/*************************************************************************
+#* Member: GetFocus Datum:26.05.98
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Wenn der Control aktiviert wird, so wird
+#* die Selection aufgehoben und der Cursor ans
+#* Ende gesetzt.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void EditBox::GetFocus()
+{
+ if(pMEdit!=NULL)
+ {
+ pMEdit->GrabFocus();
+ }
+}
+
+
+
+/*************************************************************************
+#* Member: EditBox Datum:20.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Wenn ein Event ausgeloest wird, so wird diese Routine
+#* zuerst aufgerufen und ein PostUserEvent verschickt.
+#*
+#* Input: Notify-Event
+#*
+#* Output: ---
+#*
+#************************************************************************/
+long EditBox::PreNotify( NotifyEvent& rNEvt )
+{
+ long nResult=TRUE;
+
+ if(pMEdit==NULL) return nResult;
+
+ USHORT nSwitch=rNEvt.GetType();
+ if(nSwitch==EVENT_KEYINPUT)// || nSwitch==EVENT_KEYUP)
+ {
+ const KeyCode& aKeyCode=rNEvt.GetKeyEvent()->GetKeyCode();
+ USHORT nKey=aKeyCode.GetCode();
+ if( (nKey==KEY_RETURN && !aKeyCode.IsShift()) || nKey==KEY_TAB )
+ {
+ nResult=GetParent()->Notify(rNEvt);
+ }
+ else
+ {
+ nResult=Control::PreNotify(rNEvt);
+ Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ) );
+ }
+
+ }
+ else
+ {
+ nResult=Control::PreNotify(rNEvt);
+
+ if(nSwitch==EVENT_MOUSEBUTTONDOWN || nSwitch==EVENT_MOUSEBUTTONUP)
+ {
+ bMouseFlag=TRUE;
+ Application::PostUserEvent( LINK( this, EditBox, ChangedHdl ) );
+ }
+ }
+ return nResult;
+}
+
+/*************************************************************************
+#* Member: EditBox Datum:21.01.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: EditBox
+#*
+#* Funktion: Wenn ein Event ausgeloest wurde, so wird diese Routine
+#* zuerst aufgerufen.
+#*
+#* Input: Key-Event
+#*
+#* Output: ---
+#*
+#************************************************************************/
+IMPL_LINK( EditBox, ChangedHdl, EditBox*, EMPTYARG )
+{
+ if(pMEdit!=NULL)
+ {
+ Selection aNewSel=pMEdit->GetSelection();
+
+ if(aNewSel.Min()!=aOldSel.Min() || aNewSel.Max()!=aOldSel.Max())
+ {
+ SelectionChanged();
+ aOldSel=aNewSel;
+ }
+ }
+ return 0;
+}
+
+void EditBox::UpdateOldSel()
+{
+ // if selection is set for editing a function, store it as aOldSel,
+ // so SelectionChanged isn't called in the next ChangedHdl call
+
+ if (pMEdit)
+ aOldSel = pMEdit->GetSelection();
+}
+//----------------------------------------------------------------------------
+
+//============================================================================
+// class RefEdit
+//----------------------------------------------------------------------------
+
+#define SC_ENABLE_TIME 100
+
+RefEdit::RefEdit( Window* _pParent,IControlReferenceHandler* pParent, const ResId& rResId ) :
+ Edit( _pParent, rResId ),
+ pAnyRefDlg( pParent ),
+ bSilentFocus( FALSE )
+{
+ aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
+ aTimer.SetTimeout( SC_ENABLE_TIME );
+}
+
+RefEdit::RefEdit( Window* pParent, const ResId& rResId ) :
+ Edit( pParent, rResId ),
+ pAnyRefDlg( NULL ),
+ bSilentFocus( FALSE )
+{
+}
+
+RefEdit::~RefEdit()
+{
+ aTimer.SetTimeoutHdl( Link() );
+ aTimer.Stop();
+}
+
+void RefEdit::SetRefString( const XubString& rStr )
+{
+ Edit::SetText( rStr );
+}
+
+void RefEdit::SetText( const XubString& rStr )
+{
+ Edit::SetText( rStr );
+ UpdateHdl( &aTimer );
+}
+
+void RefEdit::StartUpdateData()
+{
+ aTimer.Start();
+}
+
+void RefEdit::SilentGrabFocus()
+{
+ bSilentFocus = TRUE;
+ GrabFocus();
+ bSilentFocus = FALSE;
+}
+
+void RefEdit::SetRefDialog( IControlReferenceHandler* pDlg )
+{
+ pAnyRefDlg = pDlg;
+
+ if( pDlg )
+ {
+ aTimer.SetTimeoutHdl( LINK( this, RefEdit, UpdateHdl ) );
+ aTimer.SetTimeout( SC_ENABLE_TIME );
+ }
+ else
+ {
+ aTimer.SetTimeoutHdl( Link() );
+ aTimer.Stop();
+ }
+}
+
+void RefEdit::Modify()
+{
+ Edit::Modify();
+ if( pAnyRefDlg )
+ pAnyRefDlg->HideReference();
+}
+
+void RefEdit::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
+ pAnyRefDlg->ReleaseFocus( this );
+ else
+ Edit::KeyInput( rKEvt );
+}
+
+void RefEdit::GetFocus()
+{
+ Edit::GetFocus();
+ if( !bSilentFocus )
+ StartUpdateData();
+}
+
+void RefEdit::LoseFocus()
+{
+ Edit::LoseFocus();
+ if( pAnyRefDlg )
+ pAnyRefDlg->HideReference();
+}
+
+IMPL_LINK( RefEdit, UpdateHdl, Timer*, EMPTYARG )
+{
+ if( pAnyRefDlg )
+ pAnyRefDlg->ShowReference( GetText() );
+ return 0;
+}
+
+
+//============================================================================
+// class RefButton
+//----------------------------------------------------------------------------
+RefButton::RefButton( Window* _pParent, const ResId& rResId) :
+ ImageButton( _pParent, rResId ),
+ aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
+ aImgRefStartHC( ModuleRes( RID_BMP_REFBTN1_H ) ),
+ aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
+ aImgRefDoneHC( ModuleRes( RID_BMP_REFBTN2_H ) ),
+ pAnyRefDlg( NULL ),
+ pRefEdit( NULL )
+{
+ SetStartImage();
+}
+
+RefButton::RefButton( Window* _pParent, const ResId& rResId, RefEdit* pEdit, IControlReferenceHandler* _pDlg ) :
+ ImageButton( _pParent, rResId ),
+ aImgRefStart( ModuleRes( RID_BMP_REFBTN1 ) ),
+ aImgRefStartHC( ModuleRes( RID_BMP_REFBTN1_H ) ),
+ aImgRefDone( ModuleRes( RID_BMP_REFBTN2 ) ),
+ aImgRefDoneHC( ModuleRes( RID_BMP_REFBTN2_H ) ),
+ pAnyRefDlg( _pDlg ),
+ pRefEdit( pEdit )
+{
+ SetStartImage();
+}
+
+void RefButton::SetStartImage()
+{
+ SetModeImage( aImgRefStart );
+ SetModeImage( aImgRefStartHC, BMP_COLOR_HIGHCONTRAST );
+}
+
+void RefButton::SetEndImage()
+{
+ SetModeImage( aImgRefDone );
+ SetModeImage( aImgRefDoneHC, BMP_COLOR_HIGHCONTRAST );
+}
+
+void RefButton::SetReferences( IControlReferenceHandler* pDlg, RefEdit* pEdit )
+{
+ pAnyRefDlg = pDlg;
+ pRefEdit = pEdit;
+}
+
+//----------------------------------------------------------------------------
+
+void RefButton::Click()
+{
+ if( pAnyRefDlg )
+ pAnyRefDlg->ToggleCollapsed( pRefEdit, this );
+}
+
+void RefButton::KeyInput( const KeyEvent& rKEvt )
+{
+ const KeyCode& rKeyCode = rKEvt.GetKeyCode();
+ if( pAnyRefDlg && !rKeyCode.GetModifier() && (rKeyCode.GetCode() == KEY_F2) )
+ pAnyRefDlg->ReleaseFocus( pRefEdit );
+ else
+ ImageButton::KeyInput( rKEvt );
+}
+
+void RefButton::GetFocus()
+{
+ ImageButton::GetFocus();
+ if( pRefEdit )
+ pRefEdit->StartUpdateData();
+}
+
+void RefButton::LoseFocus()
+{
+ ImageButton::LoseFocus();
+ if( pRefEdit )
+ pRefEdit->Modify();
+}
+
+
+} // formula
diff --git a/formula/source/ui/dlg/makefile.mk b/formula/source/ui/dlg/makefile.mk
new file mode 100644
index 000000000000..688e169d26d2
--- /dev/null
+++ b/formula/source/ui/dlg/makefile.mk
@@ -0,0 +1,66 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+
+PRJNAME=formula
+TARGET=uidlg
+IMGLST_SRS=$(SRS)$/$(TARGET).srs
+BMP_IN=$(PRJ)$/res
+
+# --- Settings ----------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files -------------------------------------
+
+# ... resource files ............................
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ formdlgs.src \
+ parawin.src
+
+# ... object files ............................
+
+EXCEPTIONSFILES= \
+ $(SLO)$/formula.obj \
+ $(SLO)$/FormulaHelper.obj \
+ $(SLO)$/parawin.obj \
+ $(SLO)$/funcutl.obj \
+ $(SLO)$/funcpage.obj \
+ $(SLO)$/structpg.obj
+
+SLOFILES= \
+ $(EXCEPTIONSFILES)
+
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/formula/source/ui/dlg/parawin.cxx b/formula/source/ui/dlg/parawin.cxx
new file mode 100644
index 000000000000..3876621a3ec0
--- /dev/null
+++ b/formula/source/ui/dlg/parawin.cxx
@@ -0,0 +1,600 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_formula.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+
+#include "parawin.hxx"
+#include "parawin.hrc"
+#include "helpids.hrc"
+#include "formula/formdata.hxx"
+#include "formula/IFunctionDescription.hxx"
+#include "ModuleHelper.hxx"
+#include "ForResId.hrc"
+
+#define VAR_ARGS 30
+namespace formula
+{
+//============================================================================
+
+ParaWin::ParaWin(Window* pParent,IControlReferenceHandler* _pDlg,Point aPos):
+ TabPage (pParent,ModuleRes(RID_FORMULATAB_PARAMETER)),
+ pFuncDesc ( NULL ),
+ pMyParent (_pDlg),
+ aFtEditDesc ( this, ModuleRes( FT_EDITDESC ) ),
+ aFtArgName ( this, ModuleRes( FT_PARNAME ) ),
+ aFtArgDesc ( this, ModuleRes( FT_PARDESC ) ),
+
+ aFtArg1 ( this, ModuleRes( FT_ARG1 ) ),
+ aFtArg2 ( this, ModuleRes( FT_ARG2 ) ),
+ aFtArg3 ( this, ModuleRes( FT_ARG3 ) ),
+ aFtArg4 ( this, ModuleRes( FT_ARG4 ) ),
+
+ aBtnFx1 ( this, ModuleRes( BTN_FX1 ) ),
+ aBtnFx2 ( this, ModuleRes( BTN_FX2 ) ),
+ aBtnFx3 ( this, ModuleRes( BTN_FX3 ) ),
+ aBtnFx4 ( this, ModuleRes( BTN_FX4 ) ),
+
+ aEdArg1 ( this, ModuleRes( ED_ARG1 ) ),
+ aEdArg2 ( this, ModuleRes( ED_ARG2 ) ),
+ aEdArg3 ( this, ModuleRes( ED_ARG3 ) ),
+ aEdArg4 ( this, ModuleRes( ED_ARG4 ) ),
+
+ aRefBtn1 ( this, ModuleRes( RB_ARG1 ) ),
+ aRefBtn2 ( this, ModuleRes( RB_ARG2 ) ),
+ aRefBtn3 ( this, ModuleRes( RB_ARG3 ) ),
+ aRefBtn4 ( this, ModuleRes( RB_ARG4 ) ),
+
+ aSlider ( this, ModuleRes( WND_SLIDER ) ),
+ m_sOptional ( ModuleRes( STR_OPTIONAL ) ),
+ m_sRequired ( ModuleRes( STR_REQUIRED ) ),
+ bRefMode (FALSE)
+{
+ Image aFxHC( ModuleRes( IMG_FX_H ) );
+ FreeResource();
+ aDefaultString=aFtEditDesc.GetText();
+
+ SetPosPixel(aPos);
+ nEdFocus=NOT_FOUND;
+ nActiveLine=0;
+ Size aSize = aSlider.GetSizePixel();
+ aSize.Width() = GetSettings().GetStyleSettings().GetScrollBarSize();
+ aSlider.SetSizePixel( aSize );
+ aSlider.SetEndScrollHdl( LINK( this, ParaWin, ScrollHdl ) );
+ aSlider.SetScrollHdl( LINK( this, ParaWin, ScrollHdl ) );
+
+ aBtnFx1.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
+ aBtnFx2.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
+ aBtnFx3.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
+ aBtnFx4.SetModeImage( aFxHC, BMP_COLOR_HIGHCONTRAST );
+
+ InitArgInput( 0, aFtArg1, aBtnFx1, aEdArg1, aRefBtn1);
+ InitArgInput( 1, aFtArg2, aBtnFx2, aEdArg2, aRefBtn2);
+ InitArgInput( 2, aFtArg3, aBtnFx3, aEdArg3, aRefBtn3);
+ InitArgInput( 3, aFtArg4, aBtnFx4, aEdArg4, aRefBtn4);
+ ClearAll();
+}
+
+void ParaWin::UpdateArgDesc( USHORT nArg )
+{
+ if (nArg==NOT_FOUND) return;
+
+ if ( nArgs > 4 )
+ nArg = sal::static_int_cast<USHORT>( nArg + GetSliderPos() );
+ //@ nArg += (USHORT)aSlider.GetThumbPos();
+
+ if ( (nArgs > 0) && (nArg<nArgs) )
+ {
+ String aArgDesc;
+ String aArgName;
+
+ SetArgumentDesc( String() );
+ SetArgumentText( String() );
+
+ if ( nArgs < VAR_ARGS )
+ {
+ USHORT nRealArg = (aVisibleArgMapping.size() < nArg) ? aVisibleArgMapping[nArg] : nArg;
+ aArgDesc = pFuncDesc->getParameterDescription(nRealArg);
+ aArgName = pFuncDesc->getParameterName(nRealArg);
+ aArgName += ' ';
+ aArgName += (pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ;
+ }
+ else
+ {
+ USHORT nFix = nArgs - VAR_ARGS;
+ USHORT nPos = ( nArg < nFix ? nArg : nFix );
+ USHORT nRealArg = (nPos < aVisibleArgMapping.size() ?
+ aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
+ aArgDesc = pFuncDesc->getParameterDescription(nRealArg);
+ aArgName = pFuncDesc->getParameterName(nRealArg);
+ if ( nArg >= nFix )
+ aArgName += String::CreateFromInt32(nArg-nFix+1);
+ aArgName += ' ';
+
+ aArgName += (nArg > nFix || pFuncDesc->isParameterOptional(nRealArg)) ? m_sOptional : m_sRequired ;
+ }
+
+ SetArgumentDesc(aArgDesc);
+ SetArgumentText(aArgName);
+ }
+}
+
+void ParaWin::UpdateArgInput( USHORT nOffset, USHORT i )
+{
+ USHORT nArg = nOffset + i;
+ if ( nArgs < VAR_ARGS)
+ {
+ if(nArg<nArgs)
+ {
+ USHORT nRealArg = aVisibleArgMapping[nArg];
+ SetArgNameFont (i,(pFuncDesc->isParameterOptional(nRealArg))
+ ? aFntLight : aFntBold );
+ SetArgName (i,pFuncDesc->getParameterName(nRealArg));
+ }
+ }
+ else
+ {
+ USHORT nFix = nArgs - VAR_ARGS;
+ USHORT nPos = ( nArg < nFix ? nArg : nFix );
+ USHORT nRealArg = (nPos < aVisibleArgMapping.size() ?
+ aVisibleArgMapping[nPos] : aVisibleArgMapping.back());
+ SetArgNameFont( i,
+ (nArg > nFix || pFuncDesc->isParameterOptional(nRealArg)) ?
+ aFntLight : aFntBold );
+ if ( nArg >= nFix )
+ {
+ String aArgName( pFuncDesc->getParameterName(nRealArg) );
+ aArgName += String::CreateFromInt32(nArg-nFix+1);
+ SetArgName( i, aArgName );
+ }
+ else
+ SetArgName( i, pFuncDesc->getParameterName(nRealArg) );
+ }
+ if(nArg<nArgs) SetArgVal(i,aParaArray[nArg]);
+ //@ aArgInput[i].SetArgVal( *(pArgArr[nOffset+i]) );
+
+}
+
+ParaWin::~ParaWin()
+{
+ // #i66422# if the focus changes during destruction of the controls,
+ // don't call the focus handlers
+ Link aEmptyLink;
+ aBtnFx1.SetGetFocusHdl( aEmptyLink );
+ aBtnFx2.SetGetFocusHdl( aEmptyLink );
+ aBtnFx3.SetGetFocusHdl( aEmptyLink );
+ aBtnFx4.SetGetFocusHdl( aEmptyLink );
+}
+
+USHORT ParaWin::GetActiveLine()
+{
+ return nActiveLine;
+}
+
+void ParaWin::SetActiveLine(USHORT no)
+{
+ if(no<nArgs)
+ {
+ long nOffset = GetSliderPos();
+ nActiveLine=no;
+ long nNewEdPos=(long)nActiveLine-nOffset;
+ if(nNewEdPos<0 || nNewEdPos>3)
+ {
+ nOffset+=nNewEdPos;
+ SetSliderPos((USHORT) nOffset);
+ nOffset=GetSliderPos();
+ }
+ nEdFocus=no-(USHORT)nOffset;
+ UpdateArgDesc( nEdFocus );
+ }
+}
+
+RefEdit* ParaWin::GetActiveEdit()
+{
+ if(nArgs>0 && nEdFocus!=NOT_FOUND)
+ {
+ return aArgInput[nEdFocus].GetArgEdPtr();
+ }
+ else
+ {
+ return NULL;
+ }
+}
+
+
+String ParaWin::GetArgument(USHORT no)
+{
+ String aStr;
+ if(no<aParaArray.size())
+ {
+ aStr=aParaArray[no];
+ if(no==nActiveLine && aStr.Len()==0)
+ aStr+=' ';
+ }
+ return aStr;
+}
+
+String ParaWin::GetActiveArgName()
+{
+ String aStr;
+ if(nArgs>0 && nEdFocus!=NOT_FOUND)
+ {
+ aStr=aArgInput[nEdFocus].GetArgName();
+ }
+ return aStr;
+}
+
+
+void ParaWin::SetArgument(USHORT no, const String& aString)
+{
+ if(no<aParaArray.size())
+ {
+ aParaArray[no] = aString;
+ aParaArray[no].EraseLeadingChars();
+ }
+}
+
+void ParaWin::DelParaArray()
+{
+ ::std::vector<String>().swap(aParaArray);
+}
+
+void ParaWin::SetArgumentFonts(const Font&aBoldFont,const Font&aLightFont)
+{
+ aFntBold=aBoldFont;
+ aFntLight=aLightFont;
+}
+
+void ParaWin::SetFunctionDesc(const IFunctionDescription* pFDesc)
+{
+ pFuncDesc=pFDesc;
+
+ SetArgumentDesc( String() );
+ SetArgumentText( String() );
+ SetEditDesc( String() );
+ nArgs = 0;
+ if ( pFuncDesc!=NULL)
+ {
+ if ( pFuncDesc->getDescription().getLength() )
+ {
+ SetEditDesc(pFuncDesc->getDescription());
+ }
+ else
+ {
+ SetEditDesc(aDefaultString);
+ }
+ long nHelpId = pFuncDesc->getHelpId();
+ nArgs = pFuncDesc->getSuppressedArgumentCount();
+ pFuncDesc->fillVisibleArgumentMapping(aVisibleArgMapping);
+ aSlider.Hide();
+ SetHelpId( nHelpId );
+ aEdArg1.SetHelpId( nHelpId );
+ aEdArg2.SetHelpId( nHelpId );
+ aEdArg3.SetHelpId( nHelpId );
+ aEdArg4.SetHelpId( nHelpId );
+
+ // Unique-IDs muessen gleich bleiben fuer Automatisierung
+ SetUniqueId( HID_FORMULA_FAP_PAGE );
+ aEdArg1.SetUniqueId( HID_FORMULA_FAP_EDIT1 );
+ aEdArg2.SetUniqueId( HID_FORMULA_FAP_EDIT2 );
+ aEdArg3.SetUniqueId( HID_FORMULA_FAP_EDIT3 );
+ aEdArg4.SetUniqueId( HID_FORMULA_FAP_EDIT4 );
+ SetActiveLine(0);
+ }
+ else
+ {
+ nActiveLine=0;
+ }
+
+}
+
+void ParaWin::SetArgumentText(const String& aText)
+{
+ aFtArgName.SetText(aText);
+}
+
+void ParaWin::SetArgumentDesc(const String& aText)
+{
+ aFtArgDesc.SetText(aText);
+}
+
+void ParaWin::SetEditDesc(const String& aText)
+{
+ aFtEditDesc.SetText(aText);
+}
+
+void ParaWin::SetArgName(USHORT no,const String& aText)
+{
+ aArgInput[no].SetArgName(aText);
+}
+
+void ParaWin::SetArgNameFont(USHORT no,const Font& aFont)
+{
+ aArgInput[no].SetArgNameFont(aFont);
+}
+
+void ParaWin::SetArgVal(USHORT no,const String& aText)
+{
+ aArgInput[no].SetArgVal(aText);
+}
+
+void ParaWin::HideParaLine(USHORT no)
+{
+ aArgInput[no].Hide();
+}
+
+void ParaWin::ShowParaLine(USHORT no)
+{
+ aArgInput[no].Show();
+}
+
+void ParaWin::SetEdFocus(USHORT no)
+{
+ UpdateArgDesc(no);
+ if(no<4 && no<aParaArray.size())
+ aArgInput[no].GetArgEdPtr()->GrabFocus();
+}
+
+
+void ParaWin::InitArgInput( USHORT nPos, FixedText& rFtArg, ImageButton& rBtnFx,
+ ArgEdit& rEdArg, RefButton& rRefBtn)
+{
+
+ rRefBtn.SetReferences(pMyParent,&rEdArg);
+ rEdArg.SetRefDialog(pMyParent);
+
+ aArgInput[nPos].InitArgInput (&rFtArg,&rBtnFx,&rEdArg,&rRefBtn);
+
+ aArgInput[nPos].Hide();
+
+ aArgInput[nPos].SetFxClickHdl ( LINK( this, ParaWin, GetFxHdl ) );
+ aArgInput[nPos].SetFxFocusHdl ( LINK( this, ParaWin, GetFxFocusHdl ) );
+ aArgInput[nPos].SetEdFocusHdl ( LINK( this, ParaWin, GetEdFocusHdl ) );
+ aArgInput[nPos].SetEdModifyHdl ( LINK( this, ParaWin, ModifyHdl ) );
+}
+
+void ParaWin::ClearAll()
+{
+ SetFunctionDesc(NULL);
+ SetArgumentOffset(0);
+}
+
+void ParaWin::SetArgumentOffset(USHORT nOffset)
+{
+ DelParaArray();
+ aSlider.SetThumbPos(0);
+
+ aParaArray.resize(nArgs);
+
+ if ( nArgs > 0 )
+ {
+ for ( int i=0; i<4 && i<nArgs; i++ )
+ {
+ String aString;
+ aArgInput[i].SetArgVal(aString);
+ aArgInput[i].GetArgEdPtr()->Init(
+ (i==0) ? (ArgEdit *)NULL : aArgInput[i-1].GetArgEdPtr(),
+ (i==3 || i==nArgs-1) ? (ArgEdit *)NULL : aArgInput[i+1].GetArgEdPtr(),
+ aSlider, nArgs );
+ }
+ }
+
+ if ( nArgs < 5 )
+ {
+ aSlider.Hide();
+ }
+ else
+ {
+ //aSlider.SetEndScrollHdl( LINK( this, ScFormulaDlg, ScrollHdl ) );
+ aSlider.SetPageSize( 4 );
+ aSlider.SetVisibleSize( 4 );
+ aSlider.SetLineSize( 1 );
+ aSlider.SetRange( Range( 0, nArgs ) );
+ aSlider.SetThumbPos( nOffset );
+ aSlider.Show();
+ }
+
+ UpdateParas();
+}
+
+void ParaWin::UpdateParas()
+{
+ USHORT i;
+ USHORT nOffset = GetSliderPos();
+
+ if ( nArgs > 0 )
+ {
+ for ( i=0; (i<nArgs) && (i<4); i++ )
+ {
+ UpdateArgInput( nOffset, i );
+ ShowParaLine(i);
+ }
+ }
+
+ for ( i=nArgs; i<4; i++ ) HideParaLine(i);
+}
+
+
+USHORT ParaWin::GetSliderPos()
+{
+ return (USHORT) aSlider.GetThumbPos();
+}
+
+void ParaWin::SetSliderPos(USHORT nSliderPos)
+{
+ USHORT nOffset = GetSliderPos();
+
+ if(aSlider.IsVisible() && nOffset!=nSliderPos)
+ {
+ aSlider.SetThumbPos(nSliderPos);
+ for ( USHORT i=0; i<4; i++ )
+ {
+ UpdateArgInput( nSliderPos, i );
+ }
+ }
+}
+
+void ParaWin::SliderMoved()
+{
+ USHORT nOffset = GetSliderPos();
+
+ for ( USHORT i=0; i<4; i++ )
+ {
+ UpdateArgInput( nOffset, i );
+ }
+ if(nEdFocus!=NOT_FOUND)
+ {
+ UpdateArgDesc( nEdFocus );
+ aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
+ nActiveLine=nEdFocus+nOffset;
+ ArgumentModified();
+ }
+ aScrollLink.Call(this);
+}
+
+void ParaWin::ArgumentModified()
+{
+ aArgModifiedLink.Call(this);
+}
+
+void ParaWin::FxClick()
+{
+ aFxLink.Call(this);
+}
+
+
+IMPL_LINK( ParaWin, GetFxHdl, ArgInput*, pPtr )
+{
+ USHORT nOffset = GetSliderPos();
+ nEdFocus=NOT_FOUND;
+ for ( USHORT nPos=0; nPos<5;nPos++)
+ {
+ if(pPtr == &aArgInput[nPos])
+ {
+ nEdFocus=nPos;
+ break;
+ }
+ }
+
+ if(nEdFocus!=NOT_FOUND)
+ {
+ aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
+ nActiveLine=nEdFocus+nOffset;
+ FxClick();
+ }
+ return 0;
+}
+
+IMPL_LINK( ParaWin, GetFxFocusHdl, ArgInput*, pPtr )
+{
+ USHORT nOffset = GetSliderPos();
+ nEdFocus=NOT_FOUND;
+ for ( USHORT nPos=0; nPos<5;nPos++)
+ {
+ if(pPtr == &aArgInput[nPos])
+ {
+ nEdFocus=nPos;
+ break;
+ }
+ }
+
+ if(nEdFocus!=NOT_FOUND)
+ {
+ aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
+ UpdateArgDesc( nEdFocus );
+ nActiveLine=nEdFocus+nOffset;
+ }
+ return 0;
+}
+
+
+
+IMPL_LINK( ParaWin, GetEdFocusHdl, ArgInput*, pPtr )
+{
+ USHORT nOffset = GetSliderPos();
+ nEdFocus=NOT_FOUND;
+ for ( USHORT nPos=0; nPos<5;nPos++)
+ {
+ if(pPtr == &aArgInput[nPos])
+ {
+ nEdFocus=nPos;
+ break;
+ }
+ }
+
+ if(nEdFocus!=NOT_FOUND)
+ {
+ aArgInput[nEdFocus].SetArgSelection(Selection(0,SELECTION_MAX ));
+ UpdateArgDesc( nEdFocus );
+ nActiveLine=nEdFocus+nOffset;
+ ArgumentModified();
+ }
+
+ return 0;
+}
+
+
+IMPL_LINK( ParaWin, ScrollHdl, ScrollBar*, EMPTYARG )
+{
+ SliderMoved();
+
+ return 0;
+}
+
+IMPL_LINK( ParaWin, ModifyHdl, ArgInput*, pPtr )
+{
+ USHORT nOffset = GetSliderPos();
+ nEdFocus=NOT_FOUND;
+ for ( USHORT nPos=0; nPos<5;nPos++)
+ {
+ if(pPtr == &aArgInput[nPos])
+ {
+ nEdFocus=nPos;
+ break;
+ }
+ }
+ if(nEdFocus!=NOT_FOUND)
+ {
+ aParaArray[nEdFocus+nOffset] = aArgInput[nEdFocus].GetArgVal();
+ UpdateArgDesc( nEdFocus);
+ nActiveLine=nEdFocus+nOffset;
+ }
+
+ ArgumentModified();
+ return 0;
+}
+
+
+
+} // formula
diff --git a/formula/source/ui/dlg/parawin.hrc b/formula/source/ui/dlg/parawin.hrc
new file mode 100644
index 000000000000..f6367c6259db
--- /dev/null
+++ b/formula/source/ui/dlg/parawin.hrc
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// #define RID_SCTAB_PARAMETER 256
+
+#define FT_PARNAME 1
+#define FT_PARDESC 2
+#define FT_EDITDESC 3
+#define FT_ARG1 4
+#define FT_ARG2 5
+#define FT_ARG3 6
+#define FT_ARG4 7
+#define BTN_FX1 8
+#define BTN_FX2 9
+#define BTN_FX3 10
+#define BTN_FX4 11
+#define ED_ARG1 12
+#define ED_ARG2 13
+#define ED_ARG3 14
+#define ED_ARG4 15
+#define RB_ARG1 16
+#define RB_ARG2 17
+#define RB_ARG3 18
+#define RB_ARG4 19
+#define WND_SLIDER 20
+#define IMG_FX_H 30
+
+#define STR_OPTIONAL 1
+#define STR_REQUIRED 2
+
diff --git a/formula/source/ui/dlg/parawin.hxx b/formula/source/ui/dlg/parawin.hxx
new file mode 100644
index 000000000000..bfaebccdca09
--- /dev/null
+++ b/formula/source/ui/dlg/parawin.hxx
@@ -0,0 +1,174 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef FORMULA_PARAWIN_HXX
+#define FORMULA_PARAWIN_HXX
+
+#include <svtools/stdctrl.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/tabctrl.hxx>
+#include <vcl/scrbar.hxx>
+
+#include <vector>
+#include "formula/funcutl.hxx"
+#include "ControlHelper.hxx"
+#include "ModuleHelper.hxx"
+
+namespace formula
+{
+//============================================================================
+#define NOT_FOUND 0xffff
+//============================================================================
+class IFunctionDescription;
+class IControlReferenceHandler;
+
+class ParaWin : public TabPage
+{
+private:
+ OModuleClient m_aModuleClient;
+ Link aScrollLink;
+ Link aFxLink;
+ Link aArgModifiedLink;
+
+ ::std::vector<USHORT> aVisibleArgMapping;
+ const IFunctionDescription* pFuncDesc;
+ IControlReferenceHandler* pMyParent;
+ USHORT nArgs; // unsuppressed arguments
+ Font aFntBold;
+ Font aFntLight;
+
+ FixedInfo aFtEditDesc;
+ FixedText aFtArgName;
+ FixedInfo aFtArgDesc;
+
+ FixedText aFtArg1;
+ FixedText aFtArg2;
+ FixedText aFtArg3;
+ FixedText aFtArg4;
+
+ ImageButton aBtnFx1;
+ ImageButton aBtnFx2;
+ ImageButton aBtnFx3;
+ ImageButton aBtnFx4;
+
+ ArgEdit aEdArg1;
+ ArgEdit aEdArg2;
+ ArgEdit aEdArg3;
+ ArgEdit aEdArg4;
+
+ RefButton aRefBtn1;
+ RefButton aRefBtn2;
+ RefButton aRefBtn3;
+ RefButton aRefBtn4;
+
+ ScrollBar aSlider;
+ String m_sOptional;
+ String m_sRequired;
+ BOOL bRefMode;
+
+ USHORT nEdFocus;
+ USHORT nActiveLine;
+
+ ArgInput aArgInput[4];
+ String aDefaultString;
+ ::std::vector<String>
+ aParaArray;
+
+ DECL_LINK( ScrollHdl, ScrollBar* );
+ DECL_LINK( ModifyHdl, ArgInput* );
+ DECL_LINK( GetEdFocusHdl, ArgInput* );
+ DECL_LINK( GetFxFocusHdl, ArgInput* );
+ DECL_LINK( GetFxHdl, ArgInput* );
+
+protected:
+
+ virtual void SliderMoved();
+ virtual void ArgumentModified();
+ virtual void FxClick();
+
+ void InitArgInput( USHORT nPos, FixedText& rFtArg, ImageButton& rBtnFx,
+ ArgEdit& rEdArg, RefButton& rRefBtn);
+
+ void DelParaArray();
+ void SetArgumentDesc(const String& aText);
+ void SetArgumentText(const String& aText);
+
+
+ void SetArgName (USHORT no,const String &aArg);
+ void SetArgNameFont (USHORT no,const Font&);
+ void SetArgVal (USHORT no,const String &aArg);
+
+ void HideParaLine(USHORT no);
+ void ShowParaLine(USHORT no);
+ void UpdateArgDesc( USHORT nArg );
+ void UpdateArgInput( USHORT nOffset, USHORT i );
+
+public:
+ ParaWin(Window* pParent,IControlReferenceHandler* _pDlg,Point aPos);
+ ~ParaWin();
+
+ void SetFunctionDesc(const IFunctionDescription* pFDesc);
+ void SetArgumentOffset(USHORT nOffset);
+ void SetEditDesc(const String& aText);
+ void UpdateParas();
+ void ClearAll();
+
+ BOOL IsRefMode() {return bRefMode;}
+ void SetRefMode(BOOL bFlag) {bRefMode=bFlag;}
+
+ USHORT GetActiveLine();
+ void SetActiveLine(USHORT no);
+ RefEdit* GetActiveEdit();
+ String GetActiveArgName();
+
+ String GetArgument(USHORT no);
+ void SetArgument(USHORT no, const String& aString);
+ void SetArgumentFonts(const Font&aBoldFont,const Font&aLightFont);
+
+ void SetEdFocus(USHORT nEditLine); //Sichtbare Editzeilen
+ USHORT GetSliderPos();
+ void SetSliderPos(USHORT nSliderPos);
+
+ void SetScrollHdl( const Link& rLink ) { aScrollLink = rLink; }
+ const Link& GetScrollHdl() const { return aScrollLink; }
+
+ void SetArgModifiedHdl( const Link& rLink ) { aArgModifiedLink = rLink; }
+ const Link& GetArgModifiedHdl() const { return aArgModifiedLink; }
+
+ void SetFxHdl( const Link& rLink ) { aFxLink = rLink; }
+ const Link& GetFxHdl() const { return aFxLink; }
+};
+
+
+
+} // formula
+
+#endif // FORMULA_PARAWIN_HXX
+
diff --git a/formula/source/ui/dlg/parawin.src b/formula/source/ui/dlg/parawin.src
new file mode 100644
index 000000000000..eda2bfcecda9
--- /dev/null
+++ b/formula/source/ui/dlg/parawin.src
@@ -0,0 +1,189 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#include "parawin.hrc"
+#include "ForResId.hrc"
+#include "helpids.hrc"
+
+#define STD_MASKCOLOR Color { Red=0xFFFF; Green=0x0000; Blue=0xFFFF; }
+ //---------------------------------------------------------------------------
+
+#define FT_ARGBLOCK( y ) \
+ Pos = MAP_APPFONT (6 , y ) ; \
+ Size = MAP_APPFONT ( 74 , 8 ) ; \
+ Right = TRUE ;
+
+#define FXBUTTONBLOCK( y ) \
+ Pos = MAP_APPFONT (83 , y-1 ) ; \
+ Size = MAP_APPFONT ( 13 , 15 ) ; \
+ TabStop = TRUE ; \
+ ButtonImage = Image\
+ {\
+ ImageBitmap = Bitmap\
+ {\
+ File = "fx.bmp" ; \
+ };\
+ MaskColor = STD_MASKCOLOR;\
+ };
+
+#define ED_ARGBLOCK( y ) \
+ Border = TRUE; \
+ Pos = MAP_APPFONT( 98, y ); \
+ Size = MAP_APPFONT( 66, 12 ); \
+ TabStop = TRUE;
+
+#define RB_ARGBLOCK( y ) \
+ Pos = MAP_APPFONT ( 166 , y-1 ) ; \
+ Size = MAP_APPFONT ( 13 , 15 ) ; \
+ TabStop = FALSE ; \
+ QuickHelpText [ en-US ] = "Select"; \
+
+ //---------------------------------------------------------------------------
+
+ // jetzt alles zusammen
+
+TabPage RID_FORMULATAB_PARAMETER
+{
+ Border = FALSE;
+ Size = MAP_APPFONT( 203, 128 );
+ DialogControl = TRUE;
+ SVLook = TRUE;
+
+ FixedText FT_EDITDESC
+ {
+ Pos = MAP_APPFONT (3 , 6 ) ;
+ Size = MAP_APPFONT ( 198 , 20 ) ;
+ WordBreak = TRUE ;
+ Text [ en-US ] = "Function not known";
+ };
+
+ FixedText FT_PARNAME
+ {
+ Pos = MAP_APPFONT ( 3, 29) ;
+ Size = MAP_APPFONT ( 198 , 10 ) ;
+ };
+ FixedText FT_PARDESC
+ {
+ Pos = MAP_APPFONT ( 3, 42 ) ;
+ Size = MAP_APPFONT ( 198 , 20 ) ;
+ WordBreak = TRUE ;
+ };
+
+ FixedText FT_ARG1 { FT_ARGBLOCK ( 66 ) };
+ FixedText FT_ARG2 { FT_ARGBLOCK ( 81 ) };
+ FixedText FT_ARG3 { FT_ARGBLOCK ( 96 ) };
+ FixedText FT_ARG4 { FT_ARGBLOCK ( 111 ) };
+
+ ImageButton BTN_FX1
+ {
+ HelpId=HID_FORMULA_FAP_BTN_FX1;
+ FXBUTTONBLOCK ( 64 )
+ };
+ ImageButton BTN_FX2
+ {
+ HelpId=HID_FORMULA_FAP_BTN_FX2;
+ FXBUTTONBLOCK ( 79 )
+ };
+
+ ImageButton BTN_FX3
+ {
+ HelpId=HID_FORMULA_FAP_BTN_FX3;
+ FXBUTTONBLOCK ( 94 )
+ };
+ ImageButton BTN_FX4
+ {
+ HelpId=HID_FORMULA_FAP_BTN_FX4;
+ FXBUTTONBLOCK ( 109 )
+ };
+ Edit ED_ARG1 { ED_ARGBLOCK ( 64 ) };
+ Edit ED_ARG2 { ED_ARGBLOCK ( 79 ) };
+ Edit ED_ARG3 { ED_ARGBLOCK ( 94 ) };
+ Edit ED_ARG4 { ED_ARGBLOCK ( 109 ) };
+
+ ImageButton RB_ARG1
+ {
+ HelpId=HID_FORMULA_FAP_BTN_REF1;
+ RB_ARGBLOCK ( 64 )
+ };
+
+ ImageButton RB_ARG2
+ {
+ HelpId=HID_FORMULA_FAP_BTN_REF2;
+ RB_ARGBLOCK ( 79 )
+ };
+ ImageButton RB_ARG3
+ {
+ HelpId=HID_FORMULA_FAP_BTN_REF3;
+ RB_ARGBLOCK ( 94 )
+ };
+ ImageButton RB_ARG4
+ {
+ HelpId=HID_FORMULA_FAP_BTN_REF4;
+ RB_ARGBLOCK ( 109 )
+ };
+
+ ScrollBar WND_SLIDER
+ {
+ Pos = MAP_APPFONT ( 183, 63 ) ;
+ Size = MAP_APPFONT ( 8 , 59 ) ;
+ VScroll = TRUE ;
+ };
+
+ String STR_OPTIONAL
+ {
+ Text [ en-US ] = "(optional)" ;
+ };
+ String STR_REQUIRED
+ {
+ Text [ en-US ] = "(required)" ;
+ };
+
+ Image IMG_FX_H
+ {
+ ImageBitmap = Bitmap { File = "fx_h.bmp" ; };
+ MaskColor = STD_MASKCOLOR;
+ };
+
+};
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/formula/source/ui/dlg/structpg.cxx b/formula/source/ui/dlg/structpg.cxx
new file mode 100644
index 000000000000..3c7da5a3f8b0
--- /dev/null
+++ b/formula/source/ui/dlg/structpg.cxx
@@ -0,0 +1,227 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_formula.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+
+#include "structpg.hxx"
+#include "formdlgs.hrc"
+#include "formula/formdata.hxx"
+#include "formula/formula.hxx"
+#include "ModuleHelper.hxx"
+#include "formula/IFunctionDescription.hxx"
+#include "ForResId.hrc"
+
+//----------------------------------------------------------------------------
+namespace formula
+{
+StructListBox::StructListBox(Window* pParent, const ResId& rResId ):
+ SvTreeListBox(pParent,rResId )
+{
+ bActiveFlag=FALSE;
+
+ Font aFont( GetFont() );
+ Size aSize = aFont.GetSize();
+ aSize.Height() -= 2;
+ aFont.SetSize( aSize );
+ SetFont( aFont );
+}
+
+SvLBoxEntry* StructListBox::InsertStaticEntry(
+ const XubString& rText,
+ const Image& rEntryImg, const Image& rEntryImgHC,
+ SvLBoxEntry* pParent, ULONG nPos, IFormulaToken* pToken )
+{
+ SvLBoxEntry* pEntry = InsertEntry( rText, rEntryImg, rEntryImg, pParent, FALSE, nPos, pToken );
+ SvLBoxContextBmp* pBmpItem = static_cast< SvLBoxContextBmp* >( pEntry->GetFirstItem( SV_ITEM_ID_LBOXCONTEXTBMP ) );
+ DBG_ASSERT( pBmpItem, "StructListBox::InsertStaticEntry - missing item" );
+ pBmpItem->SetBitmap1( rEntryImgHC, BMP_COLOR_HIGHCONTRAST );
+ pBmpItem->SetBitmap2( rEntryImgHC, BMP_COLOR_HIGHCONTRAST );
+ return pEntry;
+}
+
+void StructListBox::SetActiveFlag(BOOL bFlag)
+{
+ bActiveFlag=bFlag;
+}
+
+BOOL StructListBox::GetActiveFlag()
+{
+ return bActiveFlag;
+}
+
+void StructListBox::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ bActiveFlag=TRUE;
+ SvTreeListBox::MouseButtonDown(rMEvt);
+}
+
+void StructListBox::GetFocus()
+{
+ bActiveFlag=TRUE;
+ SvTreeListBox::GetFocus();
+}
+
+void StructListBox::LoseFocus()
+{
+ bActiveFlag=FALSE;
+ SvTreeListBox::LoseFocus();
+}
+
+//==============================================================================
+
+StructPage::StructPage(Window* pParent):
+ TabPage(pParent,ModuleRes(RID_FORMULATAB_STRUCT)),
+ //
+ aFtStruct ( this, ModuleRes( FT_STRUCT ) ),
+ aTlbStruct ( this, ModuleRes( TLB_STRUCT ) ),
+ maImgEnd ( ModuleRes( BMP_STR_END ) ),
+ maImgError ( ModuleRes( BMP_STR_ERROR ) ),
+ maImgEndHC ( ModuleRes( BMP_STR_END_H ) ),
+ maImgErrorHC ( ModuleRes( BMP_STR_ERROR_H ) ),
+ pSelectedToken ( NULL )
+{
+ aTlbStruct.SetWindowBits(WB_HASLINES|WB_CLIPCHILDREN|
+ WB_HASBUTTONS|WB_HSCROLL|WB_NOINITIALSELECTION);
+
+ aTlbStruct.SetNodeDefaultImages();
+ aTlbStruct.SetDefaultExpandedEntryBmp( Image( ModuleRes( BMP_STR_OPEN ) ) );
+ aTlbStruct.SetDefaultCollapsedEntryBmp( Image( ModuleRes( BMP_STR_CLOSE ) ) );
+ aTlbStruct.SetDefaultExpandedEntryBmp( Image( ModuleRes( BMP_STR_OPEN_H ) ), BMP_COLOR_HIGHCONTRAST );
+ aTlbStruct.SetDefaultCollapsedEntryBmp( Image( ModuleRes( BMP_STR_CLOSE_H ) ), BMP_COLOR_HIGHCONTRAST );
+
+ FreeResource();
+
+ aTlbStruct.SetSelectHdl(LINK( this, StructPage, SelectHdl ) );
+}
+
+void StructPage::ClearStruct()
+{
+ aTlbStruct.SetActiveFlag(FALSE);
+ aTlbStruct.Clear();
+}
+
+SvLBoxEntry* StructPage::InsertEntry( const XubString& rText, SvLBoxEntry* pParent,
+ USHORT nFlag,ULONG nPos,IFormulaToken* pIFormulaToken)
+{
+ aTlbStruct.SetActiveFlag( FALSE );
+
+ SvLBoxEntry* pEntry = NULL;
+ switch( nFlag )
+ {
+ case STRUCT_FOLDER:
+ pEntry = aTlbStruct.InsertEntry( rText, pParent, FALSE, nPos, pIFormulaToken );
+ break;
+ case STRUCT_END:
+ pEntry = aTlbStruct.InsertStaticEntry( rText, maImgEnd, maImgEndHC, pParent, nPos, pIFormulaToken );
+ break;
+ case STRUCT_ERROR:
+ pEntry = aTlbStruct.InsertStaticEntry( rText, maImgError, maImgErrorHC, pParent, nPos, pIFormulaToken );
+ break;
+ }
+
+ if( pEntry && pParent )
+ aTlbStruct.Expand( pParent );
+ return pEntry;
+}
+
+String StructPage::GetEntryText(SvLBoxEntry* pEntry) const
+{
+ String aString;
+ if(pEntry!=NULL)
+ aString=aTlbStruct.GetEntryText(pEntry);
+ return aString;
+}
+
+SvLBoxEntry* StructPage::GetParent(SvLBoxEntry* pEntry) const
+{
+ return aTlbStruct.GetParent(pEntry);
+}
+IFormulaToken* StructPage::GetFunctionEntry(SvLBoxEntry* pEntry)
+{
+ if(pEntry!=NULL)
+ {
+ IFormulaToken * pToken=(IFormulaToken *)pEntry->GetUserData();
+ if(pToken!=NULL)
+ {
+ if ( !(pToken->isFunction() || pToken->getArgumentCount() > 1 ) )
+ {
+ return GetFunctionEntry(aTlbStruct.GetParent(pEntry));
+ }
+ else
+ {
+ return pToken;
+ }
+ }
+ }
+ return NULL;
+}
+
+IMPL_LINK( StructPage, SelectHdl, SvTreeListBox*, pTlb )
+{
+ if(aTlbStruct.GetActiveFlag())
+ {
+ if(pTlb==&aTlbStruct)
+ {
+ SvLBoxEntry* pCurEntry=aTlbStruct.GetCurEntry();
+ if(pCurEntry!=NULL)
+ {
+ pSelectedToken=(IFormulaToken *)pCurEntry->GetUserData();
+ if(pSelectedToken!=NULL)
+ {
+ if ( !(pSelectedToken->isFunction() || pSelectedToken->getArgumentCount() > 1) )
+ {
+ pSelectedToken = GetFunctionEntry(pCurEntry);
+ }
+ }
+ }
+ }
+
+ aSelLink.Call(this);
+ }
+ return 0;
+}
+
+IFormulaToken* StructPage::GetSelectedToken()
+{
+ return pSelectedToken;
+}
+
+String StructPage::GetSelectedEntryText()
+{
+ return aTlbStruct.GetEntryText(aTlbStruct.GetCurEntry());
+}
+
+} // formula
+
diff --git a/formula/source/ui/dlg/structpg.hxx b/formula/source/ui/dlg/structpg.hxx
new file mode 100644
index 000000000000..8e5dff4e6ed9
--- /dev/null
+++ b/formula/source/ui/dlg/structpg.hxx
@@ -0,0 +1,123 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef SC_STRUCTPG_HXX
+#define SC_STRUCTPG_HXX
+
+#include <svtools/stdctrl.hxx>
+#include <vcl/lstbox.hxx>
+#include <vcl/group.hxx>
+#include <svtools/svmedit.hxx>
+#include <vcl/tabpage.hxx>
+#include <vcl/tabctrl.hxx>
+#include <svtools/svtreebx.hxx>
+#include "formula/IFunctionDescription.hxx"
+#include "ModuleHelper.hxx"
+
+//============================================================================
+
+//============================================================================
+namespace formula
+{
+
+class IFormulaToken;
+class StructListBox : public SvTreeListBox
+{
+private:
+
+ BOOL bActiveFlag;
+
+protected:
+ virtual void MouseButtonDown( const MouseEvent& rMEvt );
+
+public:
+
+ StructListBox(Window* pParent, const ResId& rResId );
+
+ /** Inserts an entry with static image (no difference between collapsed/expanded). */
+ SvLBoxEntry* InsertStaticEntry(
+ const XubString& rText,
+ const Image& rEntryImg,
+ const Image& rEntryImgHC,
+ SvLBoxEntry* pParent = NULL,
+ ULONG nPos = LIST_APPEND,
+ IFormulaToken* pToken = NULL );
+
+ void SetActiveFlag(BOOL bFlag=TRUE);
+ BOOL GetActiveFlag();
+ void GetFocus();
+ void LoseFocus();
+};
+
+//============================================================================
+
+class StructPage : public TabPage
+ , public IStructHelper
+{
+private:
+ OModuleClient m_aModuleClient;
+ Link aSelLink;
+
+ FixedText aFtStruct;
+ StructListBox aTlbStruct;
+ Image maImgEnd;
+ Image maImgError;
+ Image maImgEndHC;
+ Image maImgErrorHC;
+
+ IFormulaToken* pSelectedToken;
+
+ DECL_LINK( SelectHdl, SvTreeListBox* );
+
+ using Window::GetParent;
+
+protected:
+
+ IFormulaToken* GetFunctionEntry(SvLBoxEntry* pEntry);
+
+public:
+
+ StructPage( Window* pParent);
+
+ void ClearStruct();
+ virtual SvLBoxEntry* InsertEntry(const XubString& rText, SvLBoxEntry* pParent,
+ USHORT nFlag,ULONG nPos=0,IFormulaToken* pScToken=NULL);
+
+ virtual String GetEntryText(SvLBoxEntry* pEntry) const;
+ virtual SvLBoxEntry* GetParent(SvLBoxEntry* pEntry) const;
+
+ String GetSelectedEntryText();
+ IFormulaToken* GetSelectedToken();
+
+ void SetSelectionHdl( const Link& rLink ) { aSelLink = rLink; }
+ const Link& GetSelectionHdl() const { return aSelLink; }
+};
+
+} // formula
+
+#endif
+
diff --git a/formula/source/ui/inc/ForResId.hrc b/formula/source/ui/inc/ForResId.hrc
new file mode 100644
index 000000000000..32b59f296cec
--- /dev/null
+++ b/formula/source/ui/inc/ForResId.hrc
@@ -0,0 +1,74 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef FORMULA_FORRESID_HRC
+#define FORMULA_FORRESID_HRC
+
+// include -----------------------------------------------------------
+
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+#define RID_DIALOG_START RID_FORMULA_START
+#define RID_PAGE_START RID_FORMULA_START
+#define RID_ERRORBOX_START RID_FORMULA_START
+#define RID_QUERYBOX_START RID_FORMULA_START
+#define RID_TOOLBOX_START RID_FORMULA_START
+#define RID_BITMAP_START RID_FORMULA_START
+#define RID_IMAGE_START RID_FORMULA_START
+#define RID_IMAGELIST_START RID_FORMULA_START
+#define RID_MENU_START RID_FORMULA_START
+#define RID_STRING_START RID_FORMULA_START
+#define RID_UNTYPED_START RID_FORMULA_START
+#define RID_WARN_START RID_FORMULA_START
+#define RID_CONTROL_START RID_FORMULA_START
+#define RID_MISC_START RID_FORMULA_START
+
+// Dialog Control Id's -----------------------------------------------------------
+
+// strings
+
+// bitmap
+#define RID_BMP_REFBTN1 (RID_BITMAP_START + 0)
+#define RID_BMP_REFBTN1_H (RID_BITMAP_START + 1)
+#define RID_BMP_REFBTN2 (RID_BITMAP_START + 2)
+#define RID_BMP_REFBTN2_H (RID_BITMAP_START + 3)
+
+
+// pages
+#define RID_FORMULATAB_STRUCT (RID_PAGE_START + 0)
+#define RID_FORMULATAB_FUNCTION (RID_PAGE_START + 1)
+#define RID_FORMULADLG_FORMULA (RID_PAGE_START + 2)
+#define RID_FORMULATAB_PARAMETER (RID_PAGE_START + 3)
+#define RID_FORMULADLG_FORMULA_MODAL (RID_PAGE_START + 4)
+
+// misc
+
+// -----------------------------------------------------------------------
+
+#endif // FORMULA_FORRESID_HRC
diff --git a/formula/source/ui/inc/ModuleHelper.hxx b/formula/source/ui/inc/ModuleHelper.hxx
new file mode 100644
index 000000000000..23079b1e6705
--- /dev/null
+++ b/formula/source/ui/inc/ModuleHelper.hxx
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#ifndef FORMULA_MODULE_HELPER_RPT_HXX_
+#define FORMULA_MODULE_HELPER_RPT_HXX_
+
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <tools/resmgr.hxx>
+#include "formula/formuladllapi.h"
+//.........................................................................
+namespace formula
+{
+//.........................................................................
+ //=========================================================================
+ //= OModule
+ //=========================================================================
+ class OModuleImpl;
+ class FORMULA_DLLPUBLIC OModule
+ {
+ friend class OModuleClient;
+
+ private:
+ OModule();
+ // not implemented. OModule is a static class
+
+ protected:
+ static ::osl::Mutex s_aMutex; /// access safety
+ static sal_Int32 s_nClients; /// number of registered clients
+ static OModuleImpl* s_pImpl; /// impl class. lives as long as at least one client for the module is registered
+
+ public:
+ /// get the vcl res manager of the module
+ static ResMgr* getResManager();
+ protected:
+ /// register a client for the module
+ static void registerClient();
+ /// revoke a client for the module
+ static void revokeClient();
+
+ private:
+ /** ensure that the impl class exists
+ @precond m_aMutex is guarded when this method gets called
+ */
+ static void ensureImpl();
+ };
+
+ //=========================================================================
+ //= OModuleClient
+ //=========================================================================
+ /** base class for objects which uses any global module-specific ressources
+ */
+ class FORMULA_DLLPUBLIC OModuleClient
+ {
+ public:
+ OModuleClient() { OModule::registerClient(); }
+ ~OModuleClient() { OModule::revokeClient(); }
+ };
+
+ //=========================================================================
+ //= ModuleRes
+ //=========================================================================
+ /** specialized ResId, using the ressource manager provided by the global module
+ */
+ class FORMULA_DLLPUBLIC ModuleRes : public ::ResId
+ {
+ public:
+ ModuleRes(USHORT _nId) : ResId(_nId, *OModule::getResManager()) { }
+ };
+//.........................................................................
+} // namespace formula
+//.........................................................................
+
+#endif // FORMULA_MODULE_HELPER_RPT_HXX_
+
+
diff --git a/formula/source/ui/resource/ModuleHelper.cxx b/formula/source/ui/resource/ModuleHelper.cxx
new file mode 100644
index 000000000000..20b053a5ce0e
--- /dev/null
+++ b/formula/source/ui/resource/ModuleHelper.cxx
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+#include "ModuleHelper.hxx"
+#include <comphelper/configurationhelper.hxx>
+#include <comphelper/processfactory.hxx>
+#include <osl/thread.h>
+#include <com/sun/star/util/XMacroExpander.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <rtl/uri.hxx>
+#include <tools/debug.hxx>
+#ifndef _SOLAR_HRC
+#include <svl/solar.hrc>
+#endif
+
+#define EXPAND_PROTOCOL "vnd.sun.star.expand:"
+#define ENTER_MOD_METHOD() \
+ ::osl::MutexGuard aGuard(s_aMutex); \
+ ensureImpl()
+
+//.........................................................................
+namespace formula
+{
+//.........................................................................
+ using namespace ::com::sun::star;
+//=========================================================================
+//= OModuleImpl
+//=========================================================================
+/** implementation for <type>OModule</type>. not threadsafe, has to be guarded by it's owner
+*/
+class OModuleImpl
+{
+ ResMgr* m_pRessources;
+
+public:
+ /// ctor
+ OModuleImpl();
+ ~OModuleImpl();
+
+ /// get the manager for the ressources of the module
+ ResMgr* getResManager();
+};
+
+DBG_NAME( rpt_OModuleImpl )
+//-------------------------------------------------------------------------
+OModuleImpl::OModuleImpl()
+ :m_pRessources(NULL)
+{
+ DBG_CTOR( rpt_OModuleImpl,NULL);
+
+}
+
+//-------------------------------------------------------------------------
+OModuleImpl::~OModuleImpl()
+{
+ if (m_pRessources)
+ delete m_pRessources;
+
+ DBG_DTOR( rpt_OModuleImpl,NULL);
+}
+
+//-------------------------------------------------------------------------
+ResMgr* OModuleImpl::getResManager()
+{
+ // note that this method is not threadsafe, which counts for the whole class !
+
+ if (!m_pRessources)
+ {
+ // create a manager with a fixed prefix
+ rtl::OString sName = rtl::OString( "forui" );
+ m_pRessources = ResMgr::CreateResMgr(sName);
+ }
+ return m_pRessources;
+}
+
+//=========================================================================
+//= OModule
+//=========================================================================
+::osl::Mutex OModule::s_aMutex;
+sal_Int32 OModule::s_nClients = 0;
+OModuleImpl* OModule::s_pImpl = NULL;
+//-------------------------------------------------------------------------
+ResMgr* OModule::getResManager()
+{
+ ENTER_MOD_METHOD();
+ return s_pImpl->getResManager();
+}
+
+//-------------------------------------------------------------------------
+void OModule::registerClient()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ ++s_nClients;
+}
+
+//-------------------------------------------------------------------------
+void OModule::revokeClient()
+{
+ ::osl::MutexGuard aGuard(s_aMutex);
+ if (!--s_nClients && s_pImpl)
+ {
+ delete s_pImpl;
+ s_pImpl = NULL;
+ }
+}
+
+//-------------------------------------------------------------------------
+void OModule::ensureImpl()
+{
+ if (s_pImpl)
+ return;
+ s_pImpl = new OModuleImpl();
+}
+
+//.........................................................................
+} // namespace formula
+//.........................................................................
+
diff --git a/formula/source/ui/resource/makefile.mk b/formula/source/ui/resource/makefile.mk
new file mode 100644
index 000000000000..602359e1ea49
--- /dev/null
+++ b/formula/source/ui/resource/makefile.mk
@@ -0,0 +1,49 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ=..$/..$/..
+PRJINC=$(PRJ)$/source
+PRJNAME=formula
+TARGET=ui_resource
+ENABLE_EXCEPTIONS=TRUE
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+#SRS1NAME=ui_res
+#SRC1FILES= \
+# ui_resource.src
+
+
+SLOFILES= $(SLO)$/ModuleHelper.obj \
+
+# --- Targets ----------------------------------
+
+.INCLUDE : target.mk