summaryrefslogtreecommitdiff
path: root/sc/source/ui/formdlg
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/formdlg')
-rw-r--r--sc/source/ui/formdlg/dwfunctr.cxx1182
-rw-r--r--sc/source/ui/formdlg/dwfunctr.hrc37
-rw-r--r--sc/source/ui/formdlg/dwfunctr.src155
-rw-r--r--sc/source/ui/formdlg/formdata.cxx61
-rw-r--r--sc/source/ui/formdlg/formdlgs.src29
-rw-r--r--sc/source/ui/formdlg/formula.cxx667
-rw-r--r--sc/source/ui/formdlg/makefile.mk55
-rw-r--r--sc/source/ui/formdlg/privsplt.cxx422
8 files changed, 2608 insertions, 0 deletions
diff --git a/sc/source/ui/formdlg/dwfunctr.cxx b/sc/source/ui/formdlg/dwfunctr.cxx
new file mode 100644
index 000000000000..1d522fb3211e
--- /dev/null
+++ b/sc/source/ui/formdlg/dwfunctr.cxx
@@ -0,0 +1,1182 @@
+/*************************************************************************
+ *
+ * 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_sc.hxx"
+
+
+
+// INCLUDE ---------------------------------------------------------------
+
+#include <editeng/editview.hxx>
+#include <sfx2/bindings.hxx>
+#include <sfx2/dispatch.hxx>
+#include <sfx2/objsh.hxx>
+#include <sfx2/viewsh.hxx>
+
+#include "sc.hrc"
+#include "global.hxx" // ScAddress
+#include "scresid.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "appoptio.hxx"
+#include "compiler.hxx"
+
+#include "dwfunctr.hrc"
+#include "dwfunctr.hxx"
+
+// -----------------------------------------------------------------------
+
+#define ARG_SEPERATOR String("; ")
+SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX )
+
+/*************************************************************************
+#* Member: ScFunctionChildWindow Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionChildWindow
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionChildWindow
+#* Ableitung vom SfxChildWindow als "Behaelter" fuer
+#* Funktions- Fenster in Clac
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP,
+ USHORT nId,
+ SfxBindings* pBindings,
+ SfxChildWinInfo* pInfo ) :
+ SfxChildWindow( pParentP, nId )
+{
+ ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this,
+ pParentP, ScResId( FID_FUNCTION_BOX ) );
+ pWindow = pWin;
+
+ eChildAlignment = SFX_ALIGN_RIGHT;
+
+ pWin->Initialize( pInfo );
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Konstruktor der Klasse ScFunctionDockWin
+#*
+#* Input: Sfx- Verknuepfungen, Fenster, Resource
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP,
+ SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) :
+
+ SfxDockingWindow( pBindingsP, pCW, pParent, rResId ),
+ aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT),
+ aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ),
+ aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ),
+ aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ),
+ aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ),
+ aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ),
+ aOldSize (0,0)
+{
+ FreeResource();
+ InitLRUList();
+ SetStyle(GetStyle()|WB_CLIPCHILDREN);
+
+ aTimer.SetTimeout(200);
+ aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl));
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+ aFiFuncDesc.SetUpdateMode(TRUE);
+ pAllFuncList=&aFuncList;
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ nArgs=0;
+ nDockMode=0;
+ bSizeFlag=FALSE;
+ aCatBox.SetDropDownLineCount(9);
+ Font aFont=aFiFuncDesc.GetFont();
+ aFont.SetColor(Color(COL_BLACK));
+ aFiFuncDesc.SetFont(aFont);
+ aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent?
+//? SetBackground();
+
+ Link aLink=LINK( this, ScFunctionDockWin, SelHdl);
+ aCatBox.SetSelectHdl(aLink);
+ aFuncList.SetSelectHdl(aLink);
+ aDDFuncList.SetSelectHdl(aLink);
+
+ Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl);
+ aFuncList.SetDoubleClickHdl(a2Link);
+ aDDFuncList.SetSelectHdl(aLink);
+ aInsertButton.SetClickHdl(a2Link);
+
+ Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl);
+ aPrivatSplit.SetCtrModifiedHdl(a3Link);
+ StartListening( *pBindingsP, TRUE );
+
+ Point aTopLeft=aCatBox.GetPosPixel();
+ //String aString=aCatBox.GetEntry( 0)+String("www");
+ String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ aCatBox.SelectEntryPos(0);
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+ SelHdl(&aCatBox);
+ bInit=TRUE;
+}
+
+/*************************************************************************
+#* Member: ScFunctionDockWin Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Destruktor der Klasse ScFunctionDockWin
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+__EXPORT ScFunctionDockWin::~ScFunctionDockWin()
+{
+ EndListening( GetBindings() );
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::InitLRUList()
+{
+ const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions();
+ USHORT nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (USHORT)LRU_MAX );
+ USHORT* pLRUListIds = rAppOpt.GetLRUFuncList();
+
+ USHORT i;
+ for ( i=0; i<LRU_MAX; i++ )
+ aLRUList[i] = NULL;
+
+ if ( pLRUListIds )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+ for ( i=0; i<nLRUFuncCount; i++ )
+ aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] );
+ }
+
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+
+ if(nSelPos == 0)
+ UpdateFunctionList();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:10.12.99
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateLRUList()
+{
+ if (pFuncDesc && pFuncDesc->nFIndex!=0)
+ {
+ ScModule* pScMod = SC_MOD();
+ pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex);
+ }
+}
+
+
+/*************************************************************************
+#* Member: SetSize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetSize()
+{
+ USHORT nSelEntry=0;
+ SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment();
+ short nNewDockMode;
+ switch(aChildAlign)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+
+ nNewDockMode=1;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aFuncList.GetSelectEntryPos();
+ aFuncList.Clear();
+ aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel());
+ aDDFuncList.Enable();
+ aDDFuncList.Show();
+ aPrivatSplit.Disable();
+ aPrivatSplit.Hide();
+ aFuncList.Disable();
+ aFuncList.Hide();
+ pAllFuncList=&aDDFuncList;
+ SelHdl(&aCatBox);
+ aDDFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+
+ default: nNewDockMode=0;
+ if(nDockMode!=nNewDockMode)
+ {
+ nDockMode=nNewDockMode;
+ nSelEntry=aDDFuncList.GetSelectEntryPos();
+ aDDFuncList.Clear();
+ aDDFuncList.Disable();
+ aDDFuncList.Hide();
+ aPrivatSplit.Enable();
+ aPrivatSplit.Show();
+ aFuncList.Enable();
+ aFuncList.Show();
+ pAllFuncList=&aFuncList;
+ SelHdl(&aCatBox);
+ aFuncList.SelectEntryPos(nSelEntry);
+ }
+ break;
+ }
+
+ if(nDockMode==0)
+ {
+ SetLeftRightSize();
+ }
+ else
+ {
+ SetTopBottonSize();
+ }
+}
+/*************************************************************************
+#* Member: SetLeftRightSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einstellen,
+#* wenn Links oder Rechts angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetLeftRightSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ //@ SetUpdateMode( FALSE);
+
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+
+ Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() );
+
+ Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(),
+ GetOutputSizePixel().Height()-2*aTxtSize.Height());
+ aPrivatSplit.SetYRange(aYRange);
+
+
+ if(aOldSize.Width()!=aNewSize.Width())
+ SetMyWidthLeRi(aNewSize);
+
+ if(aOldSize.Height()!=aNewSize.Height())
+ SetMyHeightLeRi(aNewSize);
+
+ aOldSize=aNewSize;
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+
+}
+/*************************************************************************
+#* Member: SetTopBottonSize Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Groesse fuer die einzelnen Controls einzustellen.
+#* wenn oben oder unten angedockt wird.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetTopBottonSize()
+{
+ if(bSizeFlag==FALSE)
+ {
+ bSizeFlag=TRUE;
+ Size aDiffSize=GetSizePixel();
+ Size aNewSize=GetOutputSizePixel();
+ aDiffSize.Width()-=aNewSize.Width();
+ aDiffSize.Height()-=aNewSize.Height();
+
+ SetMyWidthToBo(aNewSize);
+ SetMyHeightToBo(aNewSize);
+
+ aNewSize.Width()+=aDiffSize.Width();
+ aNewSize.Height()+=aDiffSize.Height();
+ //SetSizePixel(aNewSize);
+ //@ SetUpdateMode( TRUE);
+ bSizeFlag=FALSE;
+ }
+}
+
+/*************************************************************************
+#* Member: SetMyWidthLeRi Datum:15.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen,wenn Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X();
+ aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X();
+ aFDSize.Width()=aFLSize.Width();
+ aSplitterSize.Width()=aFLSize.Width();
+
+ aCatBox.SetSizePixel(aCDSize);
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetSizePixel(aSplitterSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen bei Li oder Re
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aSplitterSize=aPrivatSplit.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFLTopLeft=aFuncList.GetPosPixel();
+ Point aSplitterTopLeft=aPrivatSplit.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ long nTxtHeight = aFuncList.GetTextHeight();
+
+ short nY=(short)(3*nTxtHeight+
+ aFuncList.GetPosPixel().Y()+aSplitterSize.Height());
+
+ aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4;
+ if(nY>aFDTopLeft.Y())
+ {
+ aFDSize.Height()-=nY-aFDTopLeft.Y();
+ aFDTopLeft.Y()=nY;
+ }
+ aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1;
+ aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1;
+
+ aFuncList.SetSizePixel(aFLSize);
+ aPrivatSplit.SetPosPixel(aSplitterTopLeft);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetMyWidthToBo Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Breite fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth;
+
+ Size aCDSize=aCatBox.GetSizePixel();
+ Size aDdFLSize=aDDFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aCDTopLeft=aCatBox.GetPosPixel();
+ Point aDdFLTopLeft=aDDFuncList.GetPosPixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X();
+ aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X();
+
+ aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X();
+
+ aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X();
+
+ aDDFuncList.SetPosPixel(aDdFLTopLeft);
+ aDDFuncList.SetSizePixel(aDdFLSize);
+ aCatBox.SetSizePixel(aCDSize);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+}
+
+/*************************************************************************
+#* Member: SetHeight Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Hoehe fuer die einzelnen Controls und
+#* das Fenster einstellen, wenn oben oder
+#* unten angedockt werden soll.
+#*
+#* Input: neue Fenstergroesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize)
+{
+ if((ULONG)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight;
+
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+ Point aCBTopLeft=aCatBox.GetPosPixel();
+ aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y();
+ aFiFuncDesc.SetSizePixel(aFDSize);
+
+}
+
+/*************************************************************************
+#* Member: SetDescription Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Erklaerungstext fuer die Funktion einstellen.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::SetDescription()
+{
+ aFiFuncDesc.SetText( EMPTY_STRING );
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pDesc->initArgumentInfo(); // full argument info is needed
+
+ String aString=pAllFuncList->GetSelectEntry();
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" ));
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " ));
+ }
+
+ aString+=pDesc->GetParamList();
+
+ if(nDockMode==0)
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" ));
+ }
+ else
+ {
+ aString += '\n';
+ }
+
+ aString+=*(pDesc->pFuncDesc);
+
+ aFiFuncDesc.SetText(aString);
+ aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT);
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+
+ }
+ }
+
+/*************************************************************************
+#* Member: Resizing Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize )
+{
+ if((ULONG)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth;
+ if((ULONG)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight;
+
+}
+
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Schliessen des Fensters
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+
+BOOL __EXPORT ScFunctionDockWin::Close()
+{
+ SfxBoolItem aItem( FID_FUNCTION_BOX, FALSE );
+
+ GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aItem, 0L );
+
+ SfxDockingWindow::Close();
+
+ return( TRUE );
+}
+
+
+/*************************************************************************
+#* Member: CheckAlignment Datum:16.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberprueft den Andockmodus und stellt die
+#* Groessen dementsprechend ein.
+#*
+#* Input: Das neue Alignment
+#*
+#* Output: Das uebergebene Alignment
+#*
+#************************************************************************/
+SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */,
+ SfxChildAlignment aChildAlign)
+{
+ String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww"));
+ Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() );
+ if(!bInit)
+ {
+ eSfxOldAlignment=eSfxNewAlignment;
+ eSfxNewAlignment=aChildAlign;
+ }
+ else
+ {
+ bInit=FALSE;
+ eSfxOldAlignment=aChildAlign;
+ eSfxNewAlignment=aChildAlign;
+ }
+
+ switch(eSfxOldAlignment)
+ {
+ case SFX_ALIGN_HIGHESTTOP:
+ case SFX_ALIGN_TOP:
+ case SFX_ALIGN_LOWESTTOP:
+ case SFX_ALIGN_LOWESTBOTTOM:
+ case SFX_ALIGN_BOTTOM:
+ case SFX_ALIGN_TOOLBOXTOP:
+ case SFX_ALIGN_TOOLBOXBOTTOM:
+
+ nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+
+ 10*aTxtSize.Width()+
+ aFuncList.GetPosPixel().X();*/
+ nMinHeight=0;
+
+ break;
+
+ case SFX_ALIGN_NOALIGNMENT:
+
+ aString = aCatBox.GetEntry(0);
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www"));
+ aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString),
+ aFiFuncDesc.GetTextHeight() );
+
+ default: Point aTopLeft=aCatBox.GetPosPixel();
+ nMinWidth=aTxtSize.Width()+aTopLeft.X()
+ +2*aFuncList.GetPosPixel().X();
+ nMinHeight=19*aTxtSize.Height();
+ //aCatBox.SelectEntryPos(0);
+
+ break;
+ }
+
+ return aChildAlign;
+}
+/*************************************************************************
+#* Member: Close Datum:07.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aenderungen erkennen
+#*
+#* Input: ---
+#*
+#* Output: TRUE
+#*
+#************************************************************************/
+void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ )
+{
+// const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint);
+ /*
+ if ( pPoolItemHint
+ && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) )
+ {
+ // Die Liste der Farben hat sich geaendert
+ pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable();
+ FillValueSet();
+ }
+ */
+}
+
+
+/*************************************************************************
+#* Member: Resize Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Ueberladene Funktion um die Groesse der
+#* einzelnen Controls einzustellen.
+#*
+#* Input: neue Groesse
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void __EXPORT ScFunctionDockWin::Resize()
+{
+ if ( !IsFloatingMode() ||
+ !GetFloatingWindow()->IsRollUp() )
+ {
+ Size aQSize=GetOutputSizePixel();
+ Resizing( aQSize);
+ SetSize();
+ }
+ SfxDockingWindow::Resize();
+}
+
+/*************************************************************************
+#* Member: UpdateFunctionList Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Aktualisiert die Liste der Funktionen ab-
+#* haengig von der eingestellten Kategorie.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::UpdateFunctionList()
+{
+ USHORT nSelPos = aCatBox.GetSelectEntryPos();
+ USHORT nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos )
+ ? (nSelPos-1) : 0;
+
+ pAllFuncList->Clear();
+ pAllFuncList->SetUpdateMode( FALSE );
+
+ if ( nSelPos > 0 )
+ {
+ ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr();
+
+ const ScFuncDesc* pDesc = pFuncMgr->First( nCategory );
+ while ( pDesc )
+ {
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ pDesc = pFuncMgr->Next();
+ }
+ }
+ else // LRU-Liste
+ {
+ for ( USHORT i=0; i<LRU_MAX && aLRUList[i]; i++ )
+ {
+ const ScFuncDesc* pDesc = aLRUList[i];
+ pAllFuncList->SetEntryData(
+ pAllFuncList->InsertEntry( *(pDesc->pFuncName) ),
+ (void*)pDesc );
+ }
+ }
+
+
+ //------------------------------------------------------
+ pAllFuncList->SetUpdateMode( TRUE );
+
+ if ( pAllFuncList->GetEntryCount() > 0 )
+ {
+ pAllFuncList->Enable();
+ pAllFuncList->SelectEntryPos( 0 );
+ }
+ else
+ {
+ pAllFuncList->Disable();
+ }
+}
+
+/*************************************************************************
+#* Member: DoEnter Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen
+#* nach betaetigen der Uebernehmen- Schaltflaeche
+#* oder einem Doppelklick in die Funktionsliste.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScFunctionDockWin::DoEnter(BOOL /* bOk */) //@@ ???
+{
+ String aFirstArgStr;
+ String aParaStr;
+ String aArgStr;
+ String aString=pAllFuncList->GetSelectEntry();
+ SfxViewShell* pCurSh = SfxViewShell::Current();
+ nArgs=0;
+
+ if(aString.Len()>0)
+ {
+
+ ScModule* pScMod = SC_MOD();
+ ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh);
+ ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh );
+ if(!pScMod->IsEditMode())
+ {
+ pScMod->SetInputMode(SC_INPUT_TABLE);
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ if (pHdl)
+ pHdl->ClearText();
+ }
+ const ScFuncDesc* pDesc =
+ (const ScFuncDesc*)pAllFuncList->GetEntryData(
+ pAllFuncList->GetSelectEntryPos() );
+ if (pDesc)
+ {
+ pFuncDesc=pDesc;
+ UpdateLRUList();
+ nArgs = pDesc->nArgCount;
+ if(nArgs>0)
+ {
+ // NOTE: Theoretically the first parameter could have the
+ // suppress flag as well, but practically it doesn't.
+ aFirstArgStr = *(pDesc->ppDefArgNames[0]);
+ aFirstArgStr.EraseLeadingAndTrailingChars();
+ aFirstArgStr.SearchAndReplaceAll(' ', '_');
+ aArgStr = aFirstArgStr;
+ if ( nArgs != VAR_ARGS )
+ { // no VarArgs or Fix plus VarArgs, but not VarArgs only
+ String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " ));
+ USHORT nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 );
+ for ( USHORT nArg = 1;
+ nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ )
+ {
+ if (!pDesc->pDefArgFlags[nArg].bSuppress)
+ {
+ aArgStr += aArgSep;
+ String sTmp(*(pDesc->ppDefArgNames[nArg]));
+ sTmp.EraseLeadingAndTrailingChars();
+ sTmp.SearchAndReplaceAll(' ', '_');
+ aArgStr += sTmp;
+ }
+ }
+ }
+ }
+ }
+ if (pHdl)
+ {
+ if(pHdl->GetEditString().Len()==0)
+ {
+ aString = '=';
+ aString += pAllFuncList->GetSelectEntry();
+ }
+ EditView *pEdView=pHdl->GetActiveView();
+ if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen
+ {
+ if(nArgs>0)
+ {
+ pHdl->InsertFunction(aString);
+ pEdView->InsertText(aArgStr,TRUE);
+ ESelection aESel=pEdView->GetSelection();
+ aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len();
+ pEdView->SetSelection(aESel);
+ pHdl->DataChanged();
+ }
+ else
+ {
+ aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" ));
+ pEdView->InsertText(aString,FALSE);
+ pHdl->DataChanged();
+ }
+ }
+ }
+ InitLRUList();
+ }
+ if ( pCurSh )
+ {
+ Window* pShellWnd = pCurSh->GetWindow();
+
+ if ( pShellWnd )
+ pShellWnd->GrabFocus();
+ }
+
+
+}
+
+
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb )
+{
+ if ( pLb == &aCatBox)
+ {
+ UpdateFunctionList();
+ SetDescription();
+ }
+
+ if ( pLb == &aFuncList||pLb == &aDDFuncList)
+ {
+ SetDescription();
+ }
+
+
+ //SetSize();
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SelHdl Datum:06.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung der Kategorie wird die
+#* die Liste der Funktionen aktualisiert.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl )
+{
+ if ((ImageButton *)pCtrl == &aInsertButton ||
+ (ListBox *)pCtrl == &aFuncList)
+ {
+ DoEnter(TRUE); // Uebernimmt die Eingabe
+ }
+ //...
+
+ return 0;
+}
+
+/*************************************************************************
+#* Handle: SetSplitHdl Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScFunctionDockWin
+#*
+#* Funktion: Bei einer Aenderung des Split- Controls werden die
+#* einzelnen Controls an die neue Groesse angepasst.
+#*
+#* Input: Zeiger auf Control
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl )
+{
+ if (pCtrl == &aPrivatSplit)
+ {
+ short nDeltaY=aPrivatSplit.GetDeltaY();
+ Size aFLSize=aFuncList.GetSizePixel();
+ Size aFDSize=aFiFuncDesc.GetSizePixel();
+ Point aFDTopLeft=aFiFuncDesc.GetPosPixel();
+
+ aFLSize.Height()+=nDeltaY;
+ aFDSize.Height()-=nDeltaY;
+ aFDTopLeft.Y()+=nDeltaY;
+ aFuncList.SetSizePixel(aFLSize);
+ aFiFuncDesc.SetPosPixel(aFDTopLeft);
+ aFiFuncDesc.SetSizePixel(aFDSize);
+ /*
+ aFuncList.Invalidate();
+ aFuncList.Update();
+ aFiFuncDesc.Invalidate();
+ aFiFuncDesc.Update();
+ */
+ }
+ //...
+
+ return 0;
+}
+
+void ScFunctionDockWin::ToggleFloatingMode()
+{
+ aSplitterInitPos = Point();
+ SfxDockingWindow::ToggleFloatingMode();
+
+ eSfxNewAlignment=GetAlignment();
+ eSfxOldAlignment=eSfxNewAlignment;
+
+ aOldSize.Height()=0;
+ aOldSize.Width()=0;
+ aTimer.Start();
+}
+
+IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG )
+{
+ CheckAlignment(eSfxOldAlignment,eSfxNewAlignment);
+ SetSize();
+ return 0;
+}
+
+void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo)
+{
+ String aStr;
+ if(pInfo!=NULL)
+ {
+ if ( pInfo->aExtraString.Len() )
+ {
+ xub_StrLen nPos = pInfo->aExtraString.Search(
+ String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:")));
+
+ // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn
+ // er nicht vorhanden ist, liegt eine "altere Version vor
+ if ( nPos != STRING_NOTFOUND )
+ {
+ xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos);
+ if ( n1 != STRING_NOTFOUND )
+ {
+ xub_StrLen n2 = pInfo->aExtraString.Search(')', n1);
+ if ( n2 != STRING_NOTFOUND )
+ {
+ // Alignment-String herausschneiden
+ aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1);
+ pInfo->aExtraString.Erase(nPos, n2 - nPos + 1);
+ aStr.Erase(0, n1-nPos+1);
+ }
+ }
+ }
+ }
+ }
+ SfxDockingWindow::Initialize(pInfo);
+
+ if ( aStr.Len())
+ {
+ aSplitterInitPos=aPrivatSplit.GetPosPixel();
+ aSplitterInitPos.Y()=(USHORT) aStr.ToInt32();
+ xub_StrLen n1 = aStr.Search(';');
+ aStr.Erase(0, n1+1);
+ USHORT nSelPos=sal::static_int_cast<USHORT>( aStr.ToInt32() );
+ aCatBox.SelectEntryPos(nSelPos);
+ SelHdl(&aCatBox);
+
+ // if the window has already been shown (from SfxDockingWindow::Initialize if docked),
+ // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW
+
+ UseSplitterInitPos();
+ }
+}
+
+//-------------------------------------------------------------------------
+
+void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const
+{
+ SfxDockingWindow::FillInfo(rInfo);
+ Point aPoint=aPrivatSplit.GetPosPixel();
+ rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" ));
+ rInfo.aExtraString += String::CreateFromInt32(aPoint.Y());
+ rInfo.aExtraString += ';';
+ rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos());
+ rInfo.aExtraString += ')';
+}
+
+void ScFunctionDockWin::UseSplitterInitPos()
+{
+ if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() )
+ {
+ aPrivatSplit.MoveSplitTo(aSplitterInitPos);
+ aSplitterInitPos = Point(); // use only once
+ }
+}
+
+void ScFunctionDockWin::StateChanged( StateChangedType nStateChange )
+{
+ SfxDockingWindow::StateChanged( nStateChange );
+
+ if (nStateChange == STATE_CHANGE_INITSHOW)
+ {
+ UseSplitterInitPos(); // set initial splitter position if necessary
+ }
+}
+
+
diff --git a/sc/source/ui/formdlg/dwfunctr.hrc b/sc/source/ui/formdlg/dwfunctr.hrc
new file mode 100644
index 000000000000..388fea28b7ca
--- /dev/null
+++ b/sc/source/ui/formdlg/dwfunctr.hrc
@@ -0,0 +1,37 @@
+/*************************************************************************
+ *
+ * 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 CB_CAT 1
+#define LB_FUNC 2
+#define DDLB_FUNC 3
+#define IMB_INSERT 1
+#define FI_FUNCDESC 1
+#define FT_SPLIT 2
+
+
+// ********************************************************************** EOF
+
diff --git a/sc/source/ui/formdlg/dwfunctr.src b/sc/source/ui/formdlg/dwfunctr.src
new file mode 100644
index 000000000000..6f8a054dd6ff
--- /dev/null
+++ b/sc/source/ui/formdlg/dwfunctr.src
@@ -0,0 +1,155 @@
+/*************************************************************************
+ *
+ * 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 ---------------------------------------------------------------
+#include "sc.hrc"
+#include "dwfunctr.hrc"
+ // pragma ----------------------------------------------------------------
+
+ // RID_SVXDLG_CALCFUNC --------------------------------------------------
+DockingWindow FID_FUNCTION_BOX
+{
+ Border = TRUE ;
+ Hide = TRUE ;
+ SVLook = TRUE ;
+ Sizeable = TRUE ;
+ Moveable = TRUE ;
+ Closeable = TRUE ;
+ Zoomable = TRUE ;
+ Dockable = TRUE ;
+ EnableResizing = TRUE ;
+ Size = MAP_APPFONT ( 130 , 160 ) ;
+ HelpId = HID_FUNCTION_BOX ;
+ ListBox CB_CAT
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 20 , 4 ) ;
+ Size = MAP_APPFONT ( 56 , 80 ) ;
+ DropDown = TRUE ;
+ AutoSize = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = 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 DDLB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 103 , 4 ) ;
+ Size = MAP_APPFONT ( 56 , 80 ) ;
+ Hide = TRUE ;
+ TabStop = TRUE ;
+ DropDown = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ ListBox LB_FUNC
+ {
+ Border = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 19 ) ;
+ Size = MAP_APPFONT ( 72 , 90 ) ;
+ TabStop = TRUE ;
+ AutoHScroll = TRUE ;
+ };
+ FixedText FI_FUNCDESC
+ {
+ WordBreak = TRUE ;
+ Border = TRUE ;
+ SVLook = TRUE ;
+ Pos = MAP_APPFONT ( 3 , 115 ) ;
+ Size = MAP_APPFONT ( 72 , 40 ) ;
+ };
+ Control FT_SPLIT
+ {
+ Pos = MAP_APPFONT ( 3 , 110 ) ;
+ Size = MAP_APPFONT ( 72 , 3 ) ;
+ };
+ ImageButton IMB_INSERT
+ {
+ Pos = MAP_APPFONT ( 3 , 4 ) ;
+ Size = MAP_APPFONT ( 13 , 13 ) ;
+ TabStop = TRUE ;
+ ButtonImage = Image
+ {
+ ImageBitmap = Bitmap
+ {
+ File = "fx.bmp" ;
+ };
+ MaskColor = STD_MASKCOLOR;
+ };
+ DefButton = TRUE ;
+ QuickHelpText [ en-US ] = "Insert Function into calculation sheet" ;
+ };
+ Text [ en-US ] = "Functions" ;
+};
+ // ********************************************************************** EOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/sc/source/ui/formdlg/formdata.cxx b/sc/source/ui/formdlg/formdata.cxx
new file mode 100644
index 000000000000..e493e3f7b00f
--- /dev/null
+++ b/sc/source/ui/formdlg/formdata.cxx
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * 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_sc.hxx"
+
+
+#include <tools/debug.hxx>
+
+#include "formdata.hxx"
+
+//============================================================================
+
+ScFormEditData::ScFormEditData() : formula::FormEditData()
+{
+ Reset();
+}
+
+ScFormEditData::~ScFormEditData()
+{
+}
+
+ScFormEditData::ScFormEditData( const ScFormEditData& r ) : formula::FormEditData(r)
+{
+ *this = r;
+}
+// -----------------------------------------------------------------------------
+void ScFormEditData::SaveValues()
+{
+ ScFormEditData* pTemp = new ScFormEditData(*this);
+
+ Reset();
+ pParent = pTemp;
+}
+
+
+
diff --git a/sc/source/ui/formdlg/formdlgs.src b/sc/source/ui/formdlg/formdlgs.src
new file mode 100644
index 000000000000..e3550030c74e
--- /dev/null
+++ b/sc/source/ui/formdlg/formdlgs.src
@@ -0,0 +1,29 @@
+/*************************************************************************
+ *
+ * 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 "sc.hrc"
+ //---------------------------------------------------------------------------
diff --git a/sc/source/ui/formdlg/formula.cxx b/sc/source/ui/formdlg/formula.cxx
new file mode 100644
index 000000000000..2d9cdef1b54e
--- /dev/null
+++ b/sc/source/ui/formdlg/formula.cxx
@@ -0,0 +1,667 @@
+/*************************************************************************
+ *
+ * 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_sc.hxx"
+
+
+
+//----------------------------------------------------------------------------
+
+#include "scitems.hxx"
+#include <sfx2/dispatch.hxx>
+#include <sfx2/docfile.hxx>
+#include <sfx2/objsh.hxx>
+#include <svl/zforlist.hxx>
+#include <svl/stritem.hxx>
+#include <svtools/svtreebx.hxx>
+#include <sfx2/viewfrm.hxx>
+#include <vcl/svapp.hxx>
+#include <vcl/mnemonic.hxx>
+#include <unotools/charclass.hxx>
+#include <tools/urlobj.hxx>
+#include <formula/formulahelper.hxx>
+#include <formula/IFunctionDescription.hxx>
+
+#include "tokenuno.hxx"
+#include "formula.hxx"
+#include "formdata.hxx"
+#include "globstr.hrc"
+#include "scresid.hxx"
+#include "reffact.hxx"
+#include "document.hxx"
+#include "cell.hxx"
+#include "scmod.hxx"
+#include "inputhdl.hxx"
+#include "tabvwsh.hxx"
+#include "appoptio.hxx"
+#include "docsh.hxx"
+#include "funcdesc.hxx"
+#include "formula/token.hxx"
+#include "tokenarray.hxx"
+#include "sc.hrc"
+#include "servuno.hxx"
+#include "unonames.hxx"
+#include "externalrefmgr.hxx"
+
+#include <com/sun/star/table/CellAddress.hpp>
+
+//============================================================================
+using namespace formula;
+using namespace com::sun::star;
+
+ScDocument* ScFormulaDlg::pDoc = NULL;
+ScAddress ScFormulaDlg::aCursorPos;
+
+
+
+// --------------------------------------------------------------------------
+// Initialisierung / gemeinsame Funktionen fuer Dialog
+// --------------------------------------------------------------------------
+
+ScFormulaDlg::ScFormulaDlg( SfxBindings* pB, SfxChildWindow* pCW,
+ Window* pParent, ScViewData* pViewData,formula::IFunctionManager* _pFunctionMgr )
+ : formula::FormulaDlg( pB, pCW, pParent, true,true,true,this, _pFunctionMgr,this)
+ , m_aHelper(this,pB)
+{
+ m_aHelper.SetWindow(this);
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputEnterHandler();
+ ScTabViewShell* pScViewShell = NULL;
+
+ // title has to be from the view that opened the dialog,
+ // even if it's not the current view
+
+ SfxObjectShell* pParentDoc = NULL;
+ if ( pB )
+ {
+ SfxDispatcher* pMyDisp = pB->GetDispatcher();
+ if (pMyDisp)
+ {
+ SfxViewFrame* pMyViewFrm = pMyDisp->GetFrame();
+ if (pMyViewFrm)
+ {
+ pScViewShell = PTR_CAST( ScTabViewShell, pMyViewFrm->GetViewShell() );
+ if( pScViewShell )
+ pScViewShell->UpdateInputHandler(TRUE);
+ pParentDoc = pMyViewFrm->GetObjectShell();
+ }
+ }
+ }
+ //if ( !pParentDoc && pScViewShell ) // use current only if above fails
+ // pParentDoc = pScViewShell->GetObjectShell();
+ //if ( pParentDoc )
+ // aDocName = pParentDoc->GetTitle();
+
+ if ( pDoc == NULL )
+ pDoc = pViewData->GetDocument();
+ m_xParser.set(ScServiceProvider::MakeInstance(SC_SERVICE_FORMULAPARS,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY);
+ uno::Reference< beans::XPropertySet> xSet(m_xParser,uno::UNO_QUERY);
+ xSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_COMPILEFAP)),uno::makeAny(sal_True));
+
+ m_xOpCodeMapper.set(ScServiceProvider::MakeInstance(SC_SERVICE_OPCODEMAPPER,(ScDocShell*)pDoc->GetDocumentShell()),uno::UNO_QUERY);
+
+ ScInputHandler* pInputHdl = SC_MOD()->GetInputHdl(pScViewShell);
+
+ DBG_ASSERT( pInputHdl, "Missing input handler :-/" );
+
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+
+ m_aHelper.enableInput( FALSE );
+ m_aHelper.EnableSpreadsheets();
+ m_aHelper.Init();
+ m_aHelper.SetDispatcherLock( TRUE );
+
+ notifyChange();
+ fill();
+
+ ScFormEditData* pData = pScMod->GetFormEditData();
+ if (!pData)
+ {
+ //Nun wird es Zeit den Inputhandler festzulegen
+ pScMod->SetRefInputHdl(pScMod->GetInputHdl());
+
+ pDoc = pViewData->GetDocument();
+ SCCOL nCol = pViewData->GetCurX();
+ SCROW nRow = pViewData->GetCurY();
+ SCTAB nTab = pViewData->GetTabNo();
+ aCursorPos = ScAddress( nCol, nRow, nTab );
+
+ pScMod->InitFormEditData(); // neu anlegen
+ pData = pScMod->GetFormEditData();
+ pData->SetInputHandler(pScMod->GetInputHdl());
+ pData->SetDocShell(pViewData->GetDocShell());
+
+ DBG_ASSERT(pData,"FormEditData ist nicht da");
+
+ formula::FormulaDlgMode eMode = FORMULA_FORMDLG_FORMULA; // Default...
+
+ // Formel vorhanden? Dann editieren
+
+ String aFormula;
+ pDoc->GetFormula( nCol, nRow, nTab, aFormula );
+ BOOL bEdit = ( aFormula.Len() > 1 );
+ BOOL bMatrix = FALSE;
+ if ( bEdit )
+ {
+ bMatrix = CheckMatrix(aFormula);
+
+ xub_StrLen nFStart = 0;
+ xub_StrLen nFEnd = 0;
+ if ( GetFormulaHelper().GetNextFunc( aFormula, FALSE, nFStart, &nFEnd) )
+ {
+ pScMod->InputReplaceSelection( aFormula );
+ pScMod->InputSetSelection( nFStart, nFEnd );
+ xub_StrLen PrivStart, PrivEnd;
+ pScMod->InputGetSelection( PrivStart, PrivEnd);
+
+ eMode = SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,TRUE,TRUE);
+ pData->SetFStart( nFStart );
+ }
+ else
+ bEdit = FALSE;
+ }
+
+ if ( !bEdit )
+ {
+ String aNewFormula = '=';
+ if ( aFormula.Len() > 0 && aFormula.GetChar(0) == '=' )
+ aNewFormula=aFormula;
+
+ pScMod->InputReplaceSelection( aNewFormula );
+ pScMod->InputSetSelection( 1, aNewFormula.Len()+1 );
+ xub_StrLen PrivStart, PrivEnd;
+ pScMod->InputGetSelection( PrivStart, PrivEnd);
+ SetMeText(pScMod->InputGetFormulaStr(),PrivStart, PrivEnd,bMatrix,FALSE,FALSE);
+
+ pData->SetFStart( 1 ); // hinter dem "="
+ }
+
+ pData->SetMode( (USHORT) eMode );
+ String rStrExp = GetMeText();
+
+ pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp );
+
+ Update(rStrExp);
+ } // if (!pData)
+
+}
+
+void ScFormulaDlg::notifyChange()
+{
+ ScModule* pScMod = SC_MOD();
+
+ ScInputHandler* pInputHdl = pScMod->GetInputHdl();
+ if ( pInputHdl )
+ pInputHdl->NotifyChange( NULL );
+}
+// -----------------------------------------------------------------------------
+void ScFormulaDlg::fill()
+{
+ ScModule* pScMod = SC_MOD();
+ ScFormEditData* pData = pScMod->GetFormEditData();
+ notifyChange();
+ String rStrExp;
+ if (pData)
+ {
+ // Daten schon vorhanden -> Zustand wiederherstellen (nach Umschalten)
+ // pDoc und aCursorPos nicht neu initialisieren
+ //pDoc = pViewData->GetDocument();
+ if(IsInputHdl(pData->GetInputHandler()))
+ {
+ pScMod->SetRefInputHdl(pData->GetInputHandler());
+ }
+ else
+ {
+ PtrTabViewShell pTabViewShell;
+ ScInputHandler* pInputHdl = GetNextInputHandler(pData->GetDocShell(),&pTabViewShell);
+
+ if ( pInputHdl == NULL ) //DocShell hat keinen InputHandler mehr,
+ { //hat der Anwender halt Pech gehabt.
+ disableOk();
+ pInputHdl = pScMod->GetInputHdl();
+ }
+ else
+ {
+ pInputHdl->SetRefViewShell(pTabViewShell);
+ }
+ pScMod->SetRefInputHdl(pInputHdl);
+ pData->SetInputHandler(pInputHdl);
+ }
+
+ String aOldFormulaTmp(pScMod->InputGetFormulaStr());
+ pScMod->InputSetSelection( 0, aOldFormulaTmp.Len());
+
+ rStrExp=pData->GetUndoStr();
+ pScMod->InputReplaceSelection(rStrExp);
+
+ SetMeText(rStrExp);
+
+ pCell = new ScFormulaCell( pDoc, aCursorPos, rStrExp );
+
+ Update();
+ // Jetzt nochmals zurueckschalten, da evtl. neues Doc geoeffnet wurde!
+ pScMod->SetRefInputHdl(NULL);
+ }
+}
+
+__EXPORT ScFormulaDlg::~ScFormulaDlg()
+{
+ ScModule* pScMod = SC_MOD();
+ ScFormEditData* pData = pScMod->GetFormEditData();
+
+ if (pData) // wird nicht ueber Close zerstoert;
+ {
+ //Referenz Inputhandler zuruecksetzen
+ pScMod->SetRefInputHdl(NULL);
+ } // if (pData) // wird nicht ueber Close zerstoert;
+
+ delete pCell;
+}
+
+BOOL ScFormulaDlg::IsInputHdl(ScInputHandler* pHdl)
+{
+ BOOL bAlive = FALSE;
+
+ // gehoert der InputHandler zu irgendeiner ViewShell ?
+
+ TypeId aScType = TYPE(ScTabViewShell);
+ SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType );
+ while ( pSh && !bAlive )
+ {
+ if (((ScTabViewShell*)pSh)->GetInputHandler() == pHdl)
+ bAlive = TRUE;
+ pSh = SfxViewShell::GetNext( *pSh, &aScType );
+ }
+
+ return bAlive;
+
+}
+
+ScInputHandler* ScFormulaDlg::GetNextInputHandler(ScDocShell* pDocShell,PtrTabViewShell* ppViewSh)
+{
+ ScInputHandler* pHdl=NULL;
+
+ SfxViewFrame* pFrame = SfxViewFrame::GetFirst( pDocShell );
+ while( pFrame && pHdl==NULL)
+ {
+ SfxViewShell* p = pFrame->GetViewShell();
+ ScTabViewShell* pViewSh = PTR_CAST(ScTabViewShell,p);
+ if(pViewSh!=NULL)
+ {
+ pHdl=pViewSh->GetInputHandler();
+ if(ppViewSh!=NULL) *ppViewSh=pViewSh;
+ }
+ pFrame = SfxViewFrame::GetNext( *pFrame, pDocShell );
+ }
+
+
+ return pHdl;
+}
+
+
+BOOL __EXPORT ScFormulaDlg::Close()
+{
+ DoEnter(FALSE);
+ return TRUE;
+}
+
+// --------------------------------------------------------------------------
+// Funktionen fuer rechte Seite
+// --------------------------------------------------------------------------
+bool ScFormulaDlg::calculateValue( const String& rStrExp, String& rStrResult )
+{
+ BOOL bResult = TRUE;
+
+ ::std::auto_ptr<ScFormulaCell> pFCell( new ScFormulaCell( pDoc, aCursorPos, rStrExp ) );
+
+ // #35521# HACK! um bei ColRowNames kein #REF! zu bekommen,
+ // wenn ein Name eigentlich als Bereich in die Gesamt-Formel
+ // eingefuegt wird, bei der Einzeldarstellung aber als
+ // single-Zellbezug interpretiert wird
+ BOOL bColRowName = pCell->HasColRowName();
+ if ( bColRowName )
+ {
+ // ColRowName im RPN-Code?
+ if ( pCell->GetCode()->GetCodeLen() <= 1 )
+ { // ==1: einzelner ist als Parameter immer Bereich
+ // ==0: es waere vielleicht einer, wenn..
+ String aBraced( '(' );
+ aBraced += rStrExp;
+ aBraced += ')';
+ pFCell.reset( new ScFormulaCell( pDoc, aCursorPos, aBraced ) );
+ }
+ else
+ bColRowName = FALSE;
+ }
+
+ USHORT nErrCode = pFCell->GetErrCode();
+ if ( nErrCode == 0 )
+ {
+ SvNumberFormatter& aFormatter = *(pDoc->GetFormatTable());
+ Color* pColor;
+ if ( pFCell->IsValue() )
+ {
+ double n = pFCell->GetValue();
+ ULONG nFormat = aFormatter.GetStandardFormat( n, 0,
+ pFCell->GetFormatType(), ScGlobal::eLnge );
+ aFormatter.GetOutputString( n, nFormat,
+ rStrResult, &pColor );
+ }
+ else
+ {
+ String aStr;
+
+ pFCell->GetString( aStr );
+ ULONG nFormat = aFormatter.GetStandardFormat(
+ pFCell->GetFormatType(), ScGlobal::eLnge);
+ aFormatter.GetOutputString( aStr, nFormat,
+ rStrResult, &pColor );
+ }
+
+ ScRange aTestRange;
+ if ( bColRowName || (aTestRange.Parse(rStrExp) & SCA_VALID) )
+ rStrResult.AppendAscii(RTL_CONSTASCII_STRINGPARAM( " ..." ));
+ // Bereich
+ }
+ else
+ rStrResult += ScGlobal::GetErrorString(nErrCode);
+
+ if(!isUserMatrix() && pFCell->GetMatrixFlag())
+ {
+ CheckMatrix();
+ }
+
+ return bResult;
+}
+
+
+
+// virtuelle Methoden von ScAnyRefDlg:
+void ScFormulaDlg::RefInputStart( formula::RefEdit* pEdit, formula::RefButton* pButton )
+{
+ ::std::pair<formula::RefButton*,formula::RefEdit*> aPair = RefInputStartBefore( pEdit, pButton );
+ m_aHelper.RefInputStart( aPair.second, aPair.first);
+ RefInputStartAfter( aPair.second, aPair.first );
+}
+void ScFormulaDlg::RefInputDone( BOOL bForced )
+{
+ m_aHelper.RefInputDone( bForced );
+ RefInputDoneAfter( bForced );
+}
+
+void ScFormulaDlg::SetReference( const ScRange& rRef, ScDocument* pRefDoc )
+{
+ const IFunctionDescription* pFunc = getCurrentFunctionDescription();
+ if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
+ {
+ Selection theSel;
+ BOOL bRefNull = UpdateParaWin(theSel);
+
+ if ( rRef.aStart != rRef.aEnd && bRefNull )
+ {
+ RefInputStart(GetActiveEdit());
+ }
+
+ String aRefStr;
+ BOOL bOtherDoc = ( pRefDoc != pDoc && pRefDoc->GetDocumentShell()->HasName() );
+ if ( bOtherDoc )
+ {
+ // Referenz auf anderes Dokument - wie inputhdl.cxx
+
+ DBG_ASSERT(rRef.aStart.Tab()==rRef.aEnd.Tab(), "nStartTab!=nEndTab");
+
+ String aTmp;
+ rRef.Format( aTmp, SCA_VALID|SCA_TAB_3D, pRefDoc ); // immer 3d
+
+ SfxObjectShell* pObjSh = pRefDoc->GetDocumentShell();
+
+ // #i75893# convert escaped URL of the document to something user friendly
+// String aFileName = pObjSh->GetMedium()->GetName();
+ String aFileName = pObjSh->GetMedium()->GetURLObject().GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
+
+ aRefStr = '\'';
+ aRefStr += aFileName;
+ aRefStr.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "'#" ));
+ aRefStr += aTmp;
+ }
+ else
+ {
+ USHORT nFmt = ( rRef.aStart.Tab() == aCursorPos.Tab() )
+ ? SCA_VALID
+ : SCA_VALID | SCA_TAB_3D;
+ rRef.Format( aRefStr, nFmt, pRefDoc, pRefDoc->GetAddressConvention() );
+ }
+
+ UpdateParaWin(theSel,aRefStr);
+ }
+}
+
+BOOL ScFormulaDlg::IsRefInputMode() const
+{
+ const IFunctionDescription* pDesc = getCurrentFunctionDescription();
+ BOOL bRef = (pDesc && (pDesc->getSuppressedArgumentCount() > 0)) && (pDoc!=NULL);
+ return bRef;
+}
+
+BOOL ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const
+{
+ // not allowed: different from this doc, and no name
+ // pDocSh is always a ScDocShell
+ if ( pDocSh && ((ScDocShell*)pDocSh)->GetDocument() != pDoc && !pDocSh->HasName() )
+ return FALSE;
+
+ return TRUE; // everything else is allowed
+}
+
+void ScFormulaDlg::SetActive()
+{
+ const IFunctionDescription* pFunc = getCurrentFunctionDescription();
+ if ( pFunc && pFunc->getSuppressedArgumentCount() > 0 )
+ {
+ RefInputDone();
+ SetEdSelection();
+ }
+}
+
+void ScFormulaDlg::SaveLRUEntry(const ScFuncDesc* pFuncDescP)
+{
+ if (pFuncDescP && pFuncDescP->nFIndex!=0)
+ {
+ ScModule* pScMod = SC_MOD();
+ pScMod->InsertEntryToLRUList(pFuncDescP->nFIndex);
+ }
+}
+
+void ScFormulaDlg::doClose(BOOL /*_bOk*/)
+{
+ m_aHelper.DoClose( ScFormulaDlgWrapper::GetChildWindowId() );
+}
+void ScFormulaDlg::insertEntryToLRUList(const formula::IFunctionDescription* _pDesc)
+{
+ const ScFuncDesc* pDesc = dynamic_cast<const ScFuncDesc*>(_pDesc);
+ SaveLRUEntry(pDesc);
+}
+void ScFormulaDlg::showReference(const String& _sFormula)
+{
+ ShowReference(_sFormula);
+}
+void ScFormulaDlg::ShowReference(const String& _sFormula)
+{
+ m_aHelper.ShowReference(_sFormula);
+}
+void ScFormulaDlg::HideReference( BOOL bDoneRefMode )
+{
+ m_aHelper.HideReference(bDoneRefMode);
+}
+void ScFormulaDlg::ViewShellChanged( ScTabViewShell* pScViewShell )
+{
+ m_aHelper.ViewShellChanged( pScViewShell );
+}
+void ScFormulaDlg::AddRefEntry( )
+{
+
+}
+BOOL ScFormulaDlg::IsTableLocked( ) const
+{
+ // per Default kann bei Referenzeingabe auch die Tabelle umgeschaltet werden
+ return FALSE;
+}
+void ScFormulaDlg::ToggleCollapsed( formula::RefEdit* pEdit, formula::RefButton* pButton)
+{
+ m_aHelper.ToggleCollapsed(pEdit,pButton);
+}
+void ScFormulaDlg::ReleaseFocus( formula::RefEdit* pEdit, formula::RefButton* pButton)
+{
+ m_aHelper.ReleaseFocus(pEdit,pButton);
+}
+void ScFormulaDlg::dispatch(BOOL _bOK,BOOL _bMartixChecked)
+{
+ SfxBoolItem aRetItem( SID_DLG_RETOK, _bOK );
+ SfxBoolItem aMatItem( SID_DLG_MATRIX, _bMartixChecked );
+ SfxStringItem aStrItem( SCITEM_STRING, getCurrentFormula() );
+
+ // Wenn durch Dokument-Umschalterei die Eingabezeile weg war/ist,
+ // ist der String leer. Dann nicht die alte Formel loeschen.
+ if ( !aStrItem.GetValue().Len() )
+ aRetItem.SetValue( FALSE ); // FALSE = Cancel
+
+ m_aHelper.SetDispatcherLock( FALSE ); // Modal-Modus ausschalten
+
+ clear();
+
+ GetBindings().GetDispatcher()->Execute( SID_INS_FUNCTION,
+ SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD,
+ &aRetItem, &aStrItem, &aMatItem, 0L );
+}
+void ScFormulaDlg::setDispatcherLock( BOOL bLock )
+{
+ m_aHelper.SetDispatcherLock( bLock );
+}
+void ScFormulaDlg::setReferenceInput(const formula::FormEditData* _pData)
+{
+ ScModule* pScMod = SC_MOD();
+ ScFormEditData* pData = const_cast<ScFormEditData*>(dynamic_cast<const ScFormEditData*>(_pData));
+ pScMod->SetRefInputHdl(pData->GetInputHandler());
+}
+void ScFormulaDlg::deleteFormData()
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->ClearFormEditData(); // pData wird ungueltig!
+}
+void ScFormulaDlg::clear()
+{
+ pDoc = NULL;
+
+ //Referenz Inputhandler zuruecksetzen
+ ScModule* pScMod = SC_MOD();
+ pScMod->SetRefInputHdl(NULL);
+
+ // Enable() der Eingabezeile erzwingen:
+ ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ if ( pScViewShell )
+ pScViewShell->UpdateInputHandler();
+}
+void ScFormulaDlg::switchBack()
+{
+ ScModule* pScMod = SC_MOD();
+ // auf das Dokument zurueckschalten
+ // (noetig, weil ein fremdes oben sein kann - #34222#)
+ ScInputHandler* pHdl = pScMod->GetInputHdl();
+ if ( pHdl )
+ {
+ pHdl->ViewShellGone(NULL); // -> aktive View neu holen
+ pHdl->ShowRefFrame();
+ }
+
+ // aktuelle Tabelle ggF. restaurieren (wg. Maus-RefInput)
+ ScTabViewShell* pScViewShell = PTR_CAST(ScTabViewShell, SfxViewShell::Current());
+ if ( pScViewShell )
+ {
+ ScViewData* pVD=pScViewShell->GetViewData();
+ SCTAB nExecTab = aCursorPos.Tab();
+ if ( nExecTab != pVD->GetTabNo() )
+ pScViewShell->SetTabNo( nExecTab );
+
+ SCROW nRow=aCursorPos.Row();
+ SCCOL nCol=aCursorPos.Col();
+
+ if(pVD->GetCurX()!=nCol || pVD->GetCurY()!=nRow)
+ pScViewShell->SetCursor(nCol,nRow);
+ }
+}
+formula::FormEditData* ScFormulaDlg::getFormEditData() const
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->GetFormEditData();
+}
+void ScFormulaDlg::setCurrentFormula(const String& _sReplacement)
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputReplaceSelection(_sReplacement);
+}
+void ScFormulaDlg::setSelection(xub_StrLen _nStart,xub_StrLen _nEnd)
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputSetSelection( _nStart, _nEnd );
+}
+void ScFormulaDlg::getSelection(xub_StrLen& _nStart,xub_StrLen& _nEnd) const
+{
+ ScModule* pScMod = SC_MOD();
+ pScMod->InputGetSelection( _nStart, _nEnd );
+}
+String ScFormulaDlg::getCurrentFormula() const
+{
+ ScModule* pScMod = SC_MOD();
+ return pScMod->InputGetFormulaStr();
+}
+formula::IFunctionManager* ScFormulaDlg::getFunctionManager()
+{
+ return ScGlobal::GetStarCalcFunctionMgr();
+}
+uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
+{
+ return m_xParser;
+}
+uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
+{
+ return m_xOpCodeMapper;
+}
+
+table::CellAddress ScFormulaDlg::getReferencePosition() const
+{
+ return table::CellAddress(aCursorPos.Tab(),aCursorPos.Col(),aCursorPos.Row());
+}
+
+::std::auto_ptr<formula::FormulaTokenArray> ScFormulaDlg::convertToTokenArray(const uno::Sequence< sheet::FormulaToken >& _aTokenList)
+{
+ ::std::auto_ptr<formula::FormulaTokenArray> pArray(new ScTokenArray());
+ pArray->Fill( _aTokenList, pDoc->GetExternalRefManager());
+ return pArray;
+}
+
diff --git a/sc/source/ui/formdlg/makefile.mk b/sc/source/ui/formdlg/makefile.mk
new file mode 100644
index 000000000000..339e8fa4d581
--- /dev/null
+++ b/sc/source/ui/formdlg/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# 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=sc
+TARGET=formdlgs
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : scpre.mk
+.INCLUDE : settings.mk
+.INCLUDE : sc.mk
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+# --- Files --------------------------------------------------------
+
+SLOFILES = \
+ $(SLO)$/formula.obj \
+ $(SLO)$/formdata.obj \
+ $(SLO)$/privsplt.obj \
+ $(SLO)$/dwfunctr.obj
+
+SRS1NAME=$(TARGET)
+SRC1FILES = \
+ dwfunctr.src
+
+# --- Tagets -------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/sc/source/ui/formdlg/privsplt.cxx b/sc/source/ui/formdlg/privsplt.cxx
new file mode 100644
index 000000000000..a3b27ba21b1d
--- /dev/null
+++ b/sc/source/ui/formdlg/privsplt.cxx
@@ -0,0 +1,422 @@
+/*************************************************************************
+ *
+ * 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_sc.hxx"
+
+
+
+#include "privsplt.hxx"
+
+/*************************************************************************
+#* Member: ScPrivatSplit Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: MD_Test
+#*
+#* Funktion: Konstruktor der Klasse ScPrivatSplit
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+ScPrivatSplit::ScPrivatSplit( Window* pParent, const ResId& rResId,
+ SC_SPLIT_DIRECTION eSplit):
+ Control( pParent, rResId )
+{
+ Point aPos=GetPosPixel();
+ nOldX=(short)aPos.X();
+ nOldY=(short)aPos.Y();
+ nNewX=(short)aPos.X();
+ nNewY=(short)aPos.Y();
+ eScSplit=eSplit;
+ aXMovingRange.Min()=nNewX;
+ aXMovingRange.Max()=nNewX;
+ aYMovingRange.Min()=nNewY;
+ aYMovingRange.Max()=nNewY;
+
+ aWinPointer=GetPointer();
+
+ aMovingFlag=FALSE;
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ aWinPointer=Pointer(POINTER_HSPLIT);
+ }
+ else
+ {
+ aWinPointer=Pointer(POINTER_VSPLIT);
+ }
+ SetPointer(aWinPointer);
+}
+
+
+/*************************************************************************
+#* Member: MouseButtonDown Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Reagiert auf einen einzelnen Mouse-Event. Nach Aufruf
+#* werden alle Mauseingaben an dieses Control weitergeleitet.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScPrivatSplit::MouseButtonDown( const MouseEvent& rMEvt )
+{
+ Point aPos=LogicToPixel(rMEvt.GetPosPixel());
+
+ nOldX=(short)aPos.X();
+ nOldY=(short)aPos.Y();
+
+ CaptureMouse();
+}
+
+/*************************************************************************
+#* Member: MouseButtonUp Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Ende einer Benutzeraktion mit der Maus. Es werden
+#* die aktuelle Maus- Koordinaten ermittelt und fuer
+#* die Verschiebung des Fensters verwendet.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScPrivatSplit::MouseButtonUp( const MouseEvent& rMEvt )
+{
+ ReleaseMouse();
+
+ Point aPos=LogicToPixel(rMEvt.GetPosPixel());
+ Point a2Pos=GetPosPixel();
+ Point a3Pos=a2Pos;
+
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ nNewX=(short)aPos.X();
+ nDeltaX=nNewX-nOldX;
+ a2Pos.X()+=nDeltaX;
+ if(a2Pos.X()<aXMovingRange.Min())
+ {
+ nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Min();
+ }
+ else if(a2Pos.X()>aXMovingRange.Max())
+ {
+ nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Max();
+ }
+ }
+ else
+ {
+ nNewY=(short)aPos.Y();
+ nDeltaY=nNewY-nOldY;
+ a2Pos.Y()+=nDeltaY;
+ if(a2Pos.Y()<aYMovingRange.Min())
+ {
+ nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Min();
+ }
+ else if(a2Pos.Y()>aYMovingRange.Max())
+ {
+ nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Max();
+ }
+ }
+ SetPosPixel(a2Pos);
+ Invalidate();
+ Update();
+ CtrModified();
+}
+
+/*************************************************************************
+#* Member: MouseMove Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Reagiert kontinuierlich auf Mausbewegungen. Es werden
+#* die aktuelle Maus- Koordinaten ermittelt und fuer
+#* die Verschiebung des Fensters verwendet.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+
+void ScPrivatSplit::MouseMove( const MouseEvent& rMEvt )
+{
+ Point aPos=LogicToPixel(rMEvt.GetPosPixel());
+ Point a2Pos=GetPosPixel();
+ Point a3Pos=a2Pos;
+ if(rMEvt.IsLeft())
+ {
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ nNewX=(short)aPos.X();
+ nDeltaX=nNewX-nOldX;
+ a2Pos.X()+=nDeltaX;
+
+ if(a2Pos.X()<aXMovingRange.Min())
+ {
+ nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Min();
+ }
+ else if(a2Pos.X()>aXMovingRange.Max())
+ {
+ nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Max();
+ }
+ }
+ else
+ {
+ nNewY=(short)aPos.Y();
+ nDeltaY=nNewY-nOldY;
+ a2Pos.Y()+=nDeltaY;
+ if(a2Pos.Y()<aYMovingRange.Min())
+ {
+ nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Min();
+ }
+ else if(a2Pos.Y()>aYMovingRange.Max())
+ {
+ nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Max();
+ }
+ }
+
+ SetPosPixel(a2Pos);
+
+ CtrModified();
+ Invalidate();
+ Update();
+ }
+}
+
+/*************************************************************************
+#* Member: SetYRange Datum:14.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Setzt den Range fuer die Y- Verschiebung
+#*
+#* Input: neuer Bereich
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ScPrivatSplit::SetYRange(Range cRgeY)
+{
+ aYMovingRange=cRgeY;
+}
+
+
+
+/*************************************************************************
+#* Member: GetDeltaY Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Liefert die relative x-Verschiebung zurueck
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+short ScPrivatSplit::GetDeltaX()
+{
+ return nDeltaX;
+}
+
+/*************************************************************************
+#* Member: GetDeltaY Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Liefert die relative y-Verschiebung zurueck
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+short ScPrivatSplit::GetDeltaY()
+{
+ return nDeltaY;
+}
+
+/*************************************************************************
+#* Member: CtrModified Datum:13.10.97
+#*------------------------------------------------------------------------
+#*
+#* Klasse: ScPrivatSplit
+#*
+#* Funktion: Teilt einem installierten Handler mit, dass
+#* eine Veraenderung eingetreten ist.
+#*
+#* Input: ---
+#*
+#* Output: ---
+#*
+#************************************************************************/
+void ScPrivatSplit::CtrModified()
+{
+ aCtrModifiedLink.Call( this );
+}
+
+void ScPrivatSplit::MoveSplitTo(Point aPos)
+{
+ Point a2Pos=GetPosPixel();
+ nOldX=(short)a2Pos.X();
+ nOldY=(short)a2Pos.Y();
+ Point a3Pos=a2Pos;
+
+ if(eScSplit==SC_SPLIT_HORZ)
+ {
+ nNewX=(short)aPos.X();
+ nDeltaX=nNewX-nOldX;
+ a2Pos.X()+=nDeltaX;
+ if(a2Pos.X()<aXMovingRange.Min())
+ {
+ nDeltaX=(short)(aXMovingRange.Min()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Min();
+ }
+ else if(a2Pos.X()>aXMovingRange.Max())
+ {
+ nDeltaX=(short)(aXMovingRange.Max()-a3Pos.X());
+ a2Pos.X()=aXMovingRange.Max();
+ }
+ }
+ else
+ {
+ nNewY=(short)aPos.Y();
+ nDeltaY=nNewY-nOldY;
+ a2Pos.Y()+=nDeltaY;
+ if(a2Pos.Y()<aYMovingRange.Min())
+ {
+ nDeltaY=(short)(aYMovingRange.Min()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Min();
+ }
+ else if(a2Pos.Y()>aYMovingRange.Max())
+ {
+ nDeltaY=(short)(aYMovingRange.Max()-a3Pos.Y());
+ a2Pos.Y()=aYMovingRange.Max();
+ }
+ }
+ SetPosPixel(a2Pos);
+ Invalidate();
+ Update();
+ CtrModified();
+}
+
+
+void ScPrivatSplit::ImplInitSettings( BOOL bFont, BOOL bForeground, BOOL bBackground )
+{
+ const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
+
+ if ( bFont )
+ {
+ Font aFont = rStyleSettings.GetAppFont();
+ if ( IsControlFont() )
+ aFont.Merge( GetControlFont() );
+ SetFont( aFont );
+ }
+
+ if ( bFont || bForeground )
+ {
+ Color aTextColor = rStyleSettings.GetButtonTextColor();
+ if ( IsControlForeground() )
+ aTextColor = GetControlForeground();
+ SetTextColor( aTextColor );
+ }
+
+ if ( bBackground )
+ {
+ SetBackground( rStyleSettings.GetFaceColor());
+ }
+ if ( IsBackground() )
+ {
+ SetFillColor( GetBackground().GetColor() );
+ SetBackground();
+ }
+ Invalidate();
+}
+
+// -----------------------------------------------------------------------
+
+void ScPrivatSplit::StateChanged( StateChangedType nType )
+{
+ if ( (nType == STATE_CHANGE_ZOOM) ||
+ (nType == STATE_CHANGE_CONTROLFONT) )
+ {
+ ImplInitSettings( TRUE, FALSE, FALSE );
+ Invalidate();
+ }
+ if ( nType == STATE_CHANGE_CONTROLFOREGROUND )
+ {
+ ImplInitSettings( FALSE, TRUE, FALSE );
+ Invalidate();
+ }
+ else if ( nType == STATE_CHANGE_CONTROLBACKGROUND )
+ {
+ ImplInitSettings( FALSE, FALSE, TRUE );
+ Invalidate();
+ }
+
+ Control::StateChanged( nType );
+}
+
+// -----------------------------------------------------------------------
+
+void ScPrivatSplit::DataChanged( const DataChangedEvent& rDCEvt )
+{
+ if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) &&
+ (rDCEvt.GetFlags() & SETTINGS_STYLE) )
+ {
+ ImplInitSettings( TRUE, TRUE, TRUE );
+ Invalidate();
+ }
+ else
+ Window::DataChanged( rDCEvt );
+}
+
+