2000-09-18 16:15:01 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* $RCSfile: inputwin.cxx,v $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2006-12-04 14:10:44 +00:00
|
|
|
* $Revision: 1.17 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2006-12-04 14:10:44 +00:00
|
|
|
* last change: $Author: rt $ $Date: 2006-12-04 15:10:44 $
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* This library 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 for more details.
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
2005-09-09 09:44:29 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2000-09-18 16:15:01 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 22:11:41 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifndef _GEN_HXX //autogen
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXIMGMGR_HXX //autogen
|
|
|
|
#include <sfx2/imgmgr.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXVIEWFRM_HXX //autogen
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SFXDISPATCH_HXX //autogen
|
|
|
|
#include <sfx2/dispatch.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _SVX_RULER_HXX //autogen
|
|
|
|
#include <svx/ruler.hxx>
|
|
|
|
#endif
|
|
|
|
#ifndef _ZFORLIST_HXX //autogen
|
|
|
|
#include <svtools/zforlist.hxx>
|
|
|
|
#endif
|
2002-08-15 06:53:06 +00:00
|
|
|
#ifndef _SFXSTRITEM_HXX
|
|
|
|
#include <svtools/stritem.hxx>
|
|
|
|
#endif
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
#include "swtypes.hxx"
|
|
|
|
#include "cmdid.h"
|
|
|
|
#include "swmodule.hxx"
|
|
|
|
#include "wrtsh.hxx"
|
|
|
|
#include "view.hxx"
|
|
|
|
#include "calc.hxx"
|
|
|
|
#include "inputwin.hxx"
|
|
|
|
#include "fldbas.hxx"
|
|
|
|
#include "fldmgr.hxx"
|
|
|
|
#include "frmfmt.hxx"
|
|
|
|
#include "cellatr.hxx"
|
|
|
|
#include "edtwin.hxx"
|
|
|
|
#include "helpid.h"
|
|
|
|
|
|
|
|
// nur fuers UpdateRange - Box in dem der gestackte Cursor sthet loeschen
|
|
|
|
#include "pam.hxx"
|
|
|
|
|
|
|
|
#include "swundo.hxx"
|
|
|
|
#include "ribbar.hrc"
|
|
|
|
#include "inputwin.hrc"
|
|
|
|
|
2006-08-14 16:52:31 +00:00
|
|
|
#include <IDocumentContentOperations.hxx>
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
SFX_IMPL_POS_CHILDWINDOW( SwInputChild, FN_EDIT_FORMULA, SFX_OBJECTBAR_OBJECT )
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
2001-06-11 08:18:10 +00:00
|
|
|
SwInputWindow::SwInputWindow( Window* pParent, SfxBindings* pBind )
|
2000-09-18 16:15:01 +00:00
|
|
|
: ToolBox( pParent , SW_RES( RID_TBX_FORMULA )),
|
|
|
|
aEdit( this, WB_3DLOOK|WB_TABSTOP|WB_BORDER|WB_NOHIDESELECTION),
|
|
|
|
aPos( this, SW_RES(ED_POS)),
|
|
|
|
aPopMenu( SW_RES(MN_CALC_POPUP)),
|
|
|
|
pMgr(0),
|
|
|
|
pView(0),
|
|
|
|
pWrtShell(0),
|
2001-06-11 08:18:10 +00:00
|
|
|
pBindings(pBind),
|
2000-09-18 16:15:01 +00:00
|
|
|
aAktTableName(aEmptyStr)
|
|
|
|
{
|
|
|
|
bFirst = bDoesUndo = TRUE;
|
|
|
|
bActive = bIsTable = bDelSel = bResetUndo = bCallUndo = FALSE;
|
|
|
|
|
|
|
|
FreeResource();
|
2001-06-11 08:18:10 +00:00
|
|
|
|
2004-11-19 14:29:53 +00:00
|
|
|
SfxImageManager* pManager = SfxImageManager::GetImageManager( SW_MOD() );
|
2001-06-11 08:18:10 +00:00
|
|
|
pManager->RegisterToolBox(this);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
pView = ::GetActiveView();
|
|
|
|
pWrtShell = pView ? pView->GetWrtShellPtr() : 0;
|
|
|
|
|
|
|
|
InsertWindow( ED_POS, &aPos, 0, 0);
|
|
|
|
InsertSeparator ( 1 );
|
|
|
|
InsertSeparator ();
|
|
|
|
InsertWindow( ED_FORMULA, &aEdit);
|
|
|
|
SetHelpId(ED_FORMULA, HID_EDIT_FORMULA);
|
|
|
|
|
2006-08-04 12:07:04 +00:00
|
|
|
BOOL bDark = GetSettings().GetStyleSettings().GetFaceColor().IsDark();
|
|
|
|
SetItemImage( FN_FORMULA_CALC, pManager->GetImage(FN_FORMULA_CALC, bDark ));
|
|
|
|
SetItemImage( FN_FORMULA_CANCEL, pManager->GetImage(FN_FORMULA_CANCEL, bDark ));
|
|
|
|
SetItemImage( FN_FORMULA_APPLY, pManager->GetImage(FN_FORMULA_APPLY, bDark ));
|
2000-09-18 16:15:01 +00:00
|
|
|
|
2005-03-15 08:22:38 +00:00
|
|
|
SetItemBits( FN_FORMULA_CALC, GetItemBits( FN_FORMULA_CALC ) | TIB_DROPDOWNONLY );
|
|
|
|
SetDropdownClickHdl( LINK( this, SwInputWindow, DropdownClickHdl ));
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
Size aSizeTbx = CalcWindowSizePixel();
|
|
|
|
Size aSize = GetSizePixel();
|
|
|
|
aSize.Height() = aSizeTbx.Height();
|
|
|
|
SetSizePixel( aSize );
|
|
|
|
Size aPosSize = aPos.GetSizePixel();
|
|
|
|
Size aEditSize = aEdit.GetSizePixel();
|
|
|
|
aPosSize.Height() = aEditSize.Height() = GetItemRect(FN_FORMULA_CALC).GetHeight() - 2;
|
|
|
|
|
|
|
|
Point aPosPos = aPos.GetPosPixel();
|
|
|
|
Point aEditPos= aEdit.GetPosPixel();
|
|
|
|
aPosPos.Y() = aEditPos.Y() = GetItemRect( FN_FORMULA_CALC ).TopLeft().Y() + 1;
|
|
|
|
aPos.SetPosSizePixel( aPosPos, aPosSize );
|
|
|
|
aEdit.SetPosSizePixel( aEditPos, aEditSize );
|
|
|
|
|
|
|
|
aPopMenu.SetSelectHdl(LINK( this, SwInputWindow, MenuHdl ));
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
__EXPORT SwInputWindow::~SwInputWindow()
|
|
|
|
{
|
2004-11-19 14:29:53 +00:00
|
|
|
SfxImageManager::GetImageManager( SW_MOD() )->ReleaseToolBox(this);
|
2001-06-11 08:18:10 +00:00
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
//Lineale aufwecken
|
|
|
|
if(pView)
|
|
|
|
{
|
2002-03-07 08:35:13 +00:00
|
|
|
pView->GetHLineal().SetActive( TRUE );
|
|
|
|
pView->GetVLineal().SetActive( TRUE );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
if ( pMgr )
|
|
|
|
delete pMgr;
|
|
|
|
if(pWrtShell)
|
|
|
|
pWrtShell->EndSelTblCells();
|
|
|
|
|
|
|
|
if( bResetUndo )
|
|
|
|
{
|
|
|
|
DelBoxCntnt();
|
|
|
|
pWrtShell->DoUndo( bDoesUndo );
|
|
|
|
if(bCallUndo)
|
|
|
|
pWrtShell->Undo();
|
|
|
|
SwEditShell::SetUndoActionCount( nActionCnt );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
2006-08-04 12:07:04 +00:00
|
|
|
void SwInputWindow::DataChanged( const DataChangedEvent& rDCEvt )
|
|
|
|
{
|
|
|
|
if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) )
|
|
|
|
{
|
|
|
|
// update item images
|
|
|
|
SwModule *pMod = SW_MOD();
|
|
|
|
SfxImageManager *pImgMgr = SfxImageManager::GetImageManager( pMod );
|
|
|
|
//!! Don't use display-background to check for IsDark !!
|
|
|
|
BOOL bDark = GetSettings().GetStyleSettings().GetFaceColor().IsDark();
|
|
|
|
//
|
|
|
|
SetItemImage( FN_FORMULA_CALC, pImgMgr->GetImage(FN_FORMULA_CALC, bDark ));
|
|
|
|
SetItemImage( FN_FORMULA_CANCEL, pImgMgr->GetImage(FN_FORMULA_CANCEL, bDark ));
|
|
|
|
SetItemImage( FN_FORMULA_APPLY, pImgMgr->GetImage(FN_FORMULA_APPLY, bDark ));
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolBox::DataChanged( rDCEvt );
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
void __EXPORT SwInputWindow::Resize()
|
|
|
|
{
|
|
|
|
ToolBox::Resize();
|
|
|
|
|
|
|
|
long nWidth = GetSizePixel().Width();
|
|
|
|
long nLeft = aEdit.GetPosPixel().X();
|
|
|
|
Size aEditSize = aEdit.GetSizePixel();
|
|
|
|
|
|
|
|
aEditSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 );
|
|
|
|
aEdit.SetSizePixel( aEditSize );
|
|
|
|
aEdit.Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
void SwInputWindow::Show()
|
|
|
|
{
|
|
|
|
bIsTable = FALSE;
|
|
|
|
//Lineale anhalten
|
|
|
|
if(pView)
|
|
|
|
{
|
2002-03-07 08:35:13 +00:00
|
|
|
pView->GetHLineal().SetActive( FALSE );
|
|
|
|
pView->GetVLineal().SetActive( FALSE );
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
DBG_ASSERT(pWrtShell, "Keine WrtShell!")
|
|
|
|
// Cursor in Tabelle
|
|
|
|
bIsTable = pWrtShell->IsCrsrInTbl() ? TRUE : FALSE;
|
|
|
|
|
|
|
|
if( bFirst )
|
|
|
|
pWrtShell->SelTblCells( LINK( this, SwInputWindow,
|
|
|
|
SelTblCellsNotify) );
|
|
|
|
if( bIsTable )
|
|
|
|
{
|
|
|
|
const String& rPos = pWrtShell->GetBoxNms();
|
|
|
|
USHORT nPos = 0;
|
|
|
|
short nSrch = -1;
|
|
|
|
while( (nPos = rPos.Search( ':',nPos + 1 ) ) != STRING_NOTFOUND )
|
|
|
|
nSrch = (short) nPos;
|
|
|
|
aPos.SetText( rPos.Copy( ++nSrch ) );
|
|
|
|
aAktTableName = pWrtShell->GetTableFmt()->GetName();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aPos.SetText(SW_RESSTR(STR_FORMULA));
|
|
|
|
|
|
|
|
// Aktuelles Feld bearbeiten
|
|
|
|
ASSERT(pMgr == 0, FieldManager nicht geloescht.);
|
|
|
|
pMgr = new SwFldMgr;
|
|
|
|
|
|
|
|
// JP 13.01.97: Formel soll immer mit einem "=" beginnen, hier
|
|
|
|
// also setzen
|
|
|
|
String sEdit( '=' );
|
|
|
|
if( pMgr->GetCurFld() && TYP_FORMELFLD == pMgr->GetCurTypeId() )
|
|
|
|
{
|
|
|
|
sEdit += pMgr->GetCurFldPar2();
|
|
|
|
}
|
|
|
|
else if( bFirst )
|
|
|
|
{
|
|
|
|
if( bIsTable )
|
|
|
|
{
|
|
|
|
bResetUndo = TRUE;
|
|
|
|
nActionCnt = SwEditShell::GetUndoActionCount();
|
|
|
|
SwEditShell::SetUndoActionCount( nActionCnt + 1 );
|
|
|
|
|
|
|
|
bDoesUndo = pWrtShell->DoesUndo();
|
|
|
|
if( !bDoesUndo )
|
|
|
|
pWrtShell->DoUndo( TRUE );
|
|
|
|
|
|
|
|
if( !pWrtShell->SwCrsrShell::HasSelection() )
|
|
|
|
{
|
|
|
|
pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
|
|
|
|
pWrtShell->SetMark();
|
|
|
|
pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
|
|
|
|
}
|
|
|
|
if( pWrtShell->SwCrsrShell::HasSelection() )
|
|
|
|
{
|
|
|
|
pWrtShell->StartUndo( UNDO_DELETE );
|
|
|
|
pWrtShell->Delete();
|
|
|
|
if( 0 != pWrtShell->EndUndo( UNDO_DELETE ))
|
|
|
|
bCallUndo = TRUE;
|
|
|
|
}
|
|
|
|
pWrtShell->DoUndo( FALSE );
|
|
|
|
|
|
|
|
SfxItemSet aSet( pWrtShell->GetAttrPool(), RES_BOXATR_FORMULA, RES_BOXATR_FORMULA );
|
|
|
|
if( pWrtShell->GetTblBoxFormulaAttrs( aSet ))
|
|
|
|
sEdit += ((SwTblBoxFormula&)aSet.Get( RES_BOXATR_FORMULA )).GetFormula();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bFirst )
|
|
|
|
{
|
|
|
|
// WrtShell Flags richtig setzen
|
|
|
|
pWrtShell->SttSelect();
|
|
|
|
pWrtShell->EndSelect();
|
|
|
|
}
|
|
|
|
|
|
|
|
bFirst = FALSE;
|
|
|
|
|
|
|
|
aEdit.SetModifyHdl( LINK( this, SwInputWindow, ModifyHdl ));
|
|
|
|
|
|
|
|
aEdit.SetText( sEdit );
|
|
|
|
aEdit.SetSelection( Selection( sEdit.Len(), sEdit.Len() ) );
|
|
|
|
sOldFml = sEdit;
|
|
|
|
|
|
|
|
aEdit.Invalidate();
|
|
|
|
aEdit.Update();
|
|
|
|
aEdit.GrabFocus();
|
|
|
|
// UserInterface fuer die Eingabe abklemmen
|
|
|
|
|
|
|
|
pView->GetEditWin().LockKeyInput(TRUE);
|
|
|
|
pView->GetViewFrame()->GetDispatcher()->Lock(TRUE);
|
|
|
|
pWrtShell->Push();
|
|
|
|
}
|
|
|
|
ToolBox::Show();
|
|
|
|
}
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
IMPL_LINK( SwInputWindow, MenuHdl, Menu *, pMenu )
|
|
|
|
{
|
|
|
|
static const char * __READONLY_DATA aStrArr[] = {
|
|
|
|
sCalc_Phd,
|
|
|
|
sCalc_Sqrt,
|
|
|
|
sCalc_Or,
|
|
|
|
sCalc_Xor,
|
|
|
|
sCalc_And,
|
|
|
|
sCalc_Not,
|
|
|
|
sCalc_Eq,
|
|
|
|
sCalc_Neq,
|
|
|
|
sCalc_Leq,
|
|
|
|
sCalc_Geq,
|
|
|
|
sCalc_L,
|
|
|
|
sCalc_G,
|
|
|
|
sCalc_Sum,
|
|
|
|
sCalc_Mean,
|
|
|
|
sCalc_Min,
|
|
|
|
sCalc_Max,
|
|
|
|
sCalc_Sin,
|
|
|
|
sCalc_Cos,
|
|
|
|
sCalc_Tan,
|
|
|
|
sCalc_Asin,
|
|
|
|
sCalc_Acos,
|
|
|
|
sCalc_Atan,
|
|
|
|
sCalc_Pow,
|
|
|
|
"|",
|
|
|
|
sCalc_Round
|
|
|
|
};
|
|
|
|
|
|
|
|
USHORT nId = pMenu->GetCurItemId();
|
|
|
|
if ( nId <= MN_CALC_ROUND )
|
|
|
|
{
|
|
|
|
String aTmp( String::CreateFromAscii(aStrArr[nId - 1]) );
|
|
|
|
aTmp += ' ';
|
|
|
|
aEdit.ReplaceSelected( aTmp );
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-03-15 08:22:38 +00:00
|
|
|
IMPL_LINK( SwInputWindow, DropdownClickHdl, ToolBox*, pToolBox )
|
2000-09-18 16:15:01 +00:00
|
|
|
{
|
|
|
|
USHORT nCurID = GetCurItemId();
|
|
|
|
EndSelection(); // setzt CurItemId zurueck !
|
|
|
|
switch ( nCurID )
|
|
|
|
{
|
|
|
|
case FN_FORMULA_CALC :
|
|
|
|
{
|
2006-12-04 14:10:44 +00:00
|
|
|
aPopMenu.Execute( this, GetItemRect( FN_FORMULA_CALC ), POPUPMENU_NOMOUSEUPCLOSE );
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
2005-03-15 08:22:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
|
|
|
|
void __EXPORT SwInputWindow::Click( )
|
|
|
|
{
|
|
|
|
USHORT nCurID = GetCurItemId();
|
|
|
|
EndSelection(); // setzt CurItemId zurueck !
|
|
|
|
switch ( nCurID )
|
|
|
|
{
|
2000-09-18 16:15:01 +00:00
|
|
|
break;
|
|
|
|
case FN_FORMULA_CANCEL:
|
|
|
|
{
|
|
|
|
CancelFormula();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case FN_FORMULA_APPLY:
|
|
|
|
{
|
|
|
|
ApplyFormula();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
void SwInputWindow::ApplyFormula()
|
|
|
|
{
|
|
|
|
pView->GetViewFrame()->GetDispatcher()->Lock(FALSE);
|
|
|
|
pView->GetEditWin().LockKeyInput(FALSE);
|
|
|
|
if( bResetUndo )
|
|
|
|
{
|
|
|
|
DelBoxCntnt();
|
|
|
|
pWrtShell->DoUndo( bDoesUndo );
|
|
|
|
SwEditShell::SetUndoActionCount( nActionCnt );
|
|
|
|
if( bCallUndo )
|
|
|
|
pWrtShell->Undo();
|
|
|
|
bResetUndo = FALSE;
|
|
|
|
}
|
|
|
|
pWrtShell->Pop( FALSE );
|
|
|
|
|
|
|
|
// JP 13.01.97: Formel soll immer mit einem "=" beginnen, hier
|
|
|
|
// also wieder entfernen
|
|
|
|
String sEdit( aEdit.GetText() );
|
|
|
|
sEdit.EraseLeadingChars().EraseTrailingChars();
|
|
|
|
if( sEdit.Len() && '=' == sEdit.GetChar( 0 ) )
|
|
|
|
sEdit.Erase( 0, 1 );
|
2002-08-15 06:53:06 +00:00
|
|
|
SfxStringItem aParam(FN_EDIT_FORMULA, sEdit);
|
2000-09-18 16:15:01 +00:00
|
|
|
|
|
|
|
pWrtShell->EndSelTblCells();
|
|
|
|
pView->GetEditWin().GrabFocus();
|
2002-08-15 06:53:06 +00:00
|
|
|
const SfxPoolItem* aArgs[2];
|
|
|
|
aArgs[0] = &aParam;
|
|
|
|
aArgs[1] = 0;
|
2002-08-30 10:46:43 +00:00
|
|
|
pView->GetViewFrame()->GetBindings().Execute( FN_EDIT_FORMULA, aArgs, 0, SFX_CALLMODE_ASYNCHRON );
|
2000-09-18 16:15:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
void SwInputWindow::CancelFormula()
|
|
|
|
{
|
|
|
|
if(pView)
|
|
|
|
{
|
|
|
|
pView->GetViewFrame()->GetDispatcher()->Lock( FALSE );
|
|
|
|
pView->GetEditWin().LockKeyInput(FALSE);
|
|
|
|
if( bResetUndo )
|
|
|
|
{
|
|
|
|
DelBoxCntnt();
|
|
|
|
pWrtShell->DoUndo( bDoesUndo );
|
|
|
|
SwEditShell::SetUndoActionCount( nActionCnt );
|
|
|
|
if( bCallUndo )
|
|
|
|
pWrtShell->Undo();
|
|
|
|
bResetUndo = FALSE;
|
|
|
|
}
|
|
|
|
pWrtShell->Pop( FALSE );
|
|
|
|
|
|
|
|
if( bDelSel )
|
|
|
|
pWrtShell->EnterStdMode();
|
|
|
|
|
|
|
|
pWrtShell->EndSelTblCells();
|
|
|
|
|
|
|
|
pView->GetEditWin().GrabFocus();
|
|
|
|
}
|
|
|
|
pView->GetViewFrame()->GetDispatcher()->Execute( FN_EDIT_FORMULA, SFX_CALLMODE_ASYNCHRON);
|
|
|
|
}
|
|
|
|
//==================================================================
|
|
|
|
|
2003-04-17 09:16:06 +00:00
|
|
|
const xub_Unicode CH_LRE = 0x202a;
|
|
|
|
const xub_Unicode CH_PDF = 0x202c;
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
IMPL_LINK( SwInputWindow, SelTblCellsNotify, SwWrtShell *, pCaller )
|
|
|
|
{
|
|
|
|
if(bIsTable)
|
|
|
|
{
|
|
|
|
SwFrmFmt* pTblFmt = pCaller->GetTableFmt();
|
|
|
|
String sBoxNms( pCaller->GetBoxNms() );
|
|
|
|
String sTblNm;
|
|
|
|
if( pTblFmt && aAktTableName != pTblFmt->GetName() )
|
|
|
|
sTblNm = pTblFmt->GetName();
|
|
|
|
|
|
|
|
aEdit.UpdateRange( sBoxNms, sTblNm );
|
|
|
|
|
2003-04-17 09:16:06 +00:00
|
|
|
String sNew;
|
|
|
|
sNew += CH_LRE;
|
|
|
|
sNew += aEdit.GetText();
|
|
|
|
sNew += CH_PDF;
|
|
|
|
|
2000-09-18 16:15:01 +00:00
|
|
|
if( sNew != sOldFml )
|
|
|
|
{
|
|
|
|
// Die WrtShell ist in der Tabellen Selektion
|
|
|
|
// dann die Tabellen Selektion wieder aufheben, sonst steht der
|
|
|
|
// Cursor "im Wald" und das LiveUpdate funktioniert nicht!
|
|
|
|
pWrtShell->StartAllAction();
|
|
|
|
|
|
|
|
SwPaM aPam( *pWrtShell->GetStkCrsr()->GetPoint() );
|
|
|
|
aPam.Move( fnMoveBackward, fnGoSection );
|
|
|
|
aPam.SetMark();
|
|
|
|
aPam.Move( fnMoveForward, fnGoSection );
|
|
|
|
|
2006-08-14 16:52:31 +00:00
|
|
|
IDocumentContentOperations* pIDCO = pWrtShell->getIDocumentContentOperations();
|
|
|
|
pIDCO->Delete( aPam );
|
|
|
|
pIDCO->Insert( aPam, sNew, true );
|
2000-09-18 16:15:01 +00:00
|
|
|
pWrtShell->EndAllAction();
|
|
|
|
sOldFml = sNew;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aEdit.GrabFocus();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwInputWindow::SetFormula( const String& rFormula, BOOL bDelFlag )
|
|
|
|
{
|
|
|
|
String sEdit( '=' );
|
|
|
|
if( rFormula.Len() )
|
|
|
|
{
|
|
|
|
if( '=' == rFormula.GetChar( 0 ) )
|
|
|
|
sEdit = rFormula;
|
|
|
|
else
|
|
|
|
sEdit += rFormula;
|
|
|
|
}
|
|
|
|
aEdit.SetText( sEdit );
|
|
|
|
aEdit.SetSelection( Selection( sEdit.Len(), sEdit.Len() ) );
|
|
|
|
aEdit.Invalidate();
|
|
|
|
bDelSel = bDelFlag;
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( SwInputWindow, ModifyHdl, InputEdit*, EMPTYARG )
|
|
|
|
{
|
|
|
|
if( bIsTable && bResetUndo )
|
|
|
|
{
|
|
|
|
pWrtShell->StartAllAction();
|
|
|
|
DelBoxCntnt();
|
2003-04-17 09:16:06 +00:00
|
|
|
String sNew;
|
|
|
|
sNew += CH_LRE;
|
|
|
|
sNew += aEdit.GetText();
|
|
|
|
sNew += CH_PDF;
|
2000-09-18 16:15:01 +00:00
|
|
|
pWrtShell->SwEditShell::Insert( sNew );
|
|
|
|
pWrtShell->EndAllAction();
|
|
|
|
sOldFml = sNew;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void SwInputWindow::DelBoxCntnt()
|
|
|
|
{
|
|
|
|
if( bIsTable )
|
|
|
|
{
|
|
|
|
pWrtShell->StartAllAction();
|
|
|
|
pWrtShell->ClearMark();
|
|
|
|
pWrtShell->Pop( FALSE );
|
|
|
|
pWrtShell->Push();
|
|
|
|
pWrtShell->MoveSection( fnSectionCurr, fnSectionStart );
|
|
|
|
pWrtShell->SetMark();
|
|
|
|
pWrtShell->MoveSection( fnSectionCurr, fnSectionEnd );
|
|
|
|
pWrtShell->SwEditShell::Delete();
|
|
|
|
pWrtShell->EndAllAction();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
void __EXPORT InputEdit::KeyInput(const KeyEvent& rEvent)
|
|
|
|
{
|
|
|
|
const KeyCode aCode = rEvent.GetKeyCode();
|
|
|
|
if(aCode == KEY_RETURN || aCode == KEY_F2 )
|
|
|
|
((SwInputWindow*)GetParent())->ApplyFormula();
|
|
|
|
else if(aCode == KEY_ESCAPE )
|
|
|
|
((SwInputWindow*)GetParent())->CancelFormula();
|
|
|
|
else
|
|
|
|
Edit::KeyInput(rEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
void __EXPORT InputEdit::UpdateRange(const String& rBoxes,
|
|
|
|
const String& rName )
|
|
|
|
{
|
|
|
|
if( !rBoxes.Len() )
|
|
|
|
{
|
|
|
|
GrabFocus();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const sal_Unicode cOpen = '<', cClose = '>',
|
|
|
|
cOpenBracket = '(', cCloseBracket = ')';
|
|
|
|
String aPrefix = rName;
|
|
|
|
if(rName.Len())
|
|
|
|
aPrefix += '.';
|
|
|
|
String aBoxes = aPrefix;
|
|
|
|
aBoxes += rBoxes;
|
|
|
|
Selection aSelection(GetSelection());
|
|
|
|
USHORT nSel = (USHORT) aSelection.Len();
|
|
|
|
//OS: mit dem folgenden Ausdruck wird sichergestellt, dass im overwrite-Modus
|
|
|
|
//die selektierte schliessende Klammer nicht geloescht wird
|
|
|
|
if( nSel && ( nSel > 1 ||
|
|
|
|
GetText().GetChar( (USHORT)aSelection.Min() ) != cClose ) )
|
|
|
|
Cut();
|
|
|
|
else
|
|
|
|
aSelection.Max() = aSelection.Min();
|
|
|
|
String aActText(GetText());
|
|
|
|
const USHORT nLen = aActText.Len();
|
|
|
|
if( !nLen )
|
|
|
|
{
|
|
|
|
String aStr(cOpen);
|
|
|
|
aStr += aBoxes;
|
|
|
|
aStr += cClose;
|
|
|
|
SetText(aStr);
|
|
|
|
USHORT nPos = aStr.Search( cClose );
|
|
|
|
ASSERT(nPos < aStr.Len(), Delimiter nicht gefunden.);
|
|
|
|
++nPos;
|
|
|
|
SetSelection( Selection( nPos, nPos ));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
BOOL bFound = FALSE;
|
2002-09-04 11:02:43 +00:00
|
|
|
sal_Unicode cCh;
|
2000-09-18 16:15:01 +00:00
|
|
|
USHORT nPos, nEndPos, nStartPos = (USHORT) aSelection.Min();
|
|
|
|
if( nStartPos-- )
|
|
|
|
{
|
|
|
|
do {
|
|
|
|
if( cOpen == (cCh = aActText.GetChar( nStartPos ) ) ||
|
|
|
|
cOpenBracket == cCh )
|
|
|
|
{
|
|
|
|
bFound = cCh == cOpen;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while( nStartPos-- > 0 );
|
|
|
|
}
|
|
|
|
if( bFound )
|
|
|
|
{
|
|
|
|
bFound = FALSE;
|
|
|
|
nEndPos = nStartPos;
|
|
|
|
while( nEndPos < nLen )
|
|
|
|
{
|
|
|
|
if( cClose == (cCh = aActText.GetChar( nEndPos )) /*||
|
|
|
|
cCh == cCloseBracket*/ )
|
|
|
|
{
|
|
|
|
bFound = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
++nEndPos;
|
|
|
|
}
|
|
|
|
// nur wenn akt. Pos im Breich oder direkt dahinter liegt
|
|
|
|
if( bFound && !( nStartPos < (USHORT)aSelection.Max() &&
|
|
|
|
(USHORT)aSelection.Max() <= nEndPos + 1 ))
|
|
|
|
bFound = FALSE;
|
|
|
|
}
|
|
|
|
if( bFound )
|
|
|
|
{
|
|
|
|
nPos = ++nStartPos + 1; // wir wollen dahinter
|
|
|
|
aActText.Erase( nStartPos, nEndPos - nStartPos );
|
|
|
|
aActText.Insert( aBoxes, nStartPos );
|
|
|
|
nPos += aBoxes.Len();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
String aTmp( (char)cOpen );
|
|
|
|
aTmp += aBoxes;
|
|
|
|
aTmp += (char)cClose;
|
|
|
|
nPos = (USHORT)aSelection.Min();
|
|
|
|
aActText.Insert( aTmp, nPos );
|
|
|
|
nPos += aTmp.Len();
|
|
|
|
}
|
|
|
|
if( GetText() != aActText )
|
|
|
|
{
|
|
|
|
SetText( aActText );
|
|
|
|
SetSelection( Selection( nPos, nPos ) );
|
|
|
|
// GetModifyHdl().Call( this );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GrabFocus();
|
|
|
|
|
|
|
|
}
|
|
|
|
//==================================================================
|
|
|
|
|
|
|
|
|
|
|
|
SwInputChild::SwInputChild(Window* pParent,
|
|
|
|
USHORT nId,
|
2001-06-11 08:18:10 +00:00
|
|
|
SfxBindings* pBindings,
|
2000-09-18 16:15:01 +00:00
|
|
|
SfxChildWinInfo* ) :
|
|
|
|
SfxChildWindow( pParent, nId )
|
|
|
|
{
|
2001-06-11 08:18:10 +00:00
|
|
|
pDispatch = pBindings->GetDispatcher();
|
|
|
|
pWindow = new SwInputWindow( pParent, pBindings );
|
2000-09-18 16:15:01 +00:00
|
|
|
((SwInputWindow*)pWindow)->Show();
|
|
|
|
eChildAlignment = SFX_ALIGN_LOWESTTOP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
__EXPORT SwInputChild::~SwInputChild()
|
|
|
|
{
|
|
|
|
if(pDispatch)
|
|
|
|
pDispatch->Lock(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SfxChildWinInfo __EXPORT SwInputChild::GetInfo() const
|
|
|
|
{
|
|
|
|
SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); \
|
|
|
|
return aInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|