1*b3f79822SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b3f79822SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b3f79822SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b3f79822SAndrew Rist * distributed with this work for additional information 6*b3f79822SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b3f79822SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b3f79822SAndrew Rist * "License"); you may not use this file except in compliance 9*b3f79822SAndrew Rist * with the License. You may obtain a copy of the License at 10*b3f79822SAndrew Rist * 11*b3f79822SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*b3f79822SAndrew Rist * 13*b3f79822SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b3f79822SAndrew Rist * software distributed under the License is distributed on an 15*b3f79822SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b3f79822SAndrew Rist * KIND, either express or implied. See the License for the 17*b3f79822SAndrew Rist * specific language governing permissions and limitations 18*b3f79822SAndrew Rist * under the License. 19*b3f79822SAndrew Rist * 20*b3f79822SAndrew Rist *************************************************************/ 21*b3f79822SAndrew Rist 22*b3f79822SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sc.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include <algorithm> 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include "scitems.hxx" 30cdf0e10cSrcweir #include <editeng/eeitem.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include <sfx2/app.hxx> 33cdf0e10cSrcweir #include <editeng/adjitem.hxx> 34cdf0e10cSrcweir #include <editeng/editview.hxx> 35cdf0e10cSrcweir #include <editeng/editstat.hxx> 36cdf0e10cSrcweir #include <editeng/frmdiritem.hxx> 37cdf0e10cSrcweir #include <editeng/lspcitem.hxx> 38cdf0e10cSrcweir #include <sfx2/bindings.hxx> 39cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 40cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 41cdf0e10cSrcweir #include <sfx2/event.hxx> 42cdf0e10cSrcweir #include <sfx2/imgmgr.hxx> 43cdf0e10cSrcweir #include <stdlib.h> // qsort 44cdf0e10cSrcweir #include <editeng/scriptspaceitem.hxx> 45cdf0e10cSrcweir #include <editeng/scripttypeitem.hxx> 46cdf0e10cSrcweir #include <vcl/cursor.hxx> 47cdf0e10cSrcweir #include <vcl/help.hxx> 48cdf0e10cSrcweir #include <svl/stritem.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include "inputwin.hxx" 51cdf0e10cSrcweir #include "scmod.hxx" 52cdf0e10cSrcweir #include "uiitems.hxx" 53cdf0e10cSrcweir #include "global.hxx" 54cdf0e10cSrcweir #include "scresid.hxx" 55cdf0e10cSrcweir #include "sc.hrc" 56cdf0e10cSrcweir #include "globstr.hrc" 57cdf0e10cSrcweir #include "editutil.hxx" 58cdf0e10cSrcweir #include "inputhdl.hxx" 59cdf0e10cSrcweir #include "tabvwsh.hxx" 60cdf0e10cSrcweir #include "document.hxx" 61cdf0e10cSrcweir #include "docsh.hxx" 62cdf0e10cSrcweir #include "appoptio.hxx" 63cdf0e10cSrcweir #include "rangenam.hxx" 64cdf0e10cSrcweir #include <formula/compiler.hrc> 65cdf0e10cSrcweir #include "dbcolect.hxx" 66cdf0e10cSrcweir #include "rangeutl.hxx" 67cdf0e10cSrcweir #include "docfunc.hxx" 68cdf0e10cSrcweir #include "funcdesc.hxx" 69cdf0e10cSrcweir #include <editeng/fontitem.hxx> 70cdf0e10cSrcweir #include <com/sun/star/accessibility/XAccessible.hpp> 71cdf0e10cSrcweir #include "AccessibleEditObject.hxx" 72cdf0e10cSrcweir #include "AccessibleText.hxx" 73cdf0e10cSrcweir 74cdf0e10cSrcweir #define TEXT_STARTPOS 3 75cdf0e10cSrcweir #define THESIZE 1000000 //!!! langt... :-) 76cdf0e10cSrcweir #define TBX_WINDOW_HEIGHT 22 // in Pixeln - fuer alle Systeme gleich? 77cdf0e10cSrcweir 78cdf0e10cSrcweir enum ScNameInputType 79cdf0e10cSrcweir { 80cdf0e10cSrcweir SC_NAME_INPUT_CELL, 81cdf0e10cSrcweir SC_NAME_INPUT_RANGE, 82cdf0e10cSrcweir SC_NAME_INPUT_NAMEDRANGE, 83cdf0e10cSrcweir SC_NAME_INPUT_DATABASE, 84cdf0e10cSrcweir SC_NAME_INPUT_ROW, 85cdf0e10cSrcweir SC_NAME_INPUT_SHEET, 86cdf0e10cSrcweir SC_NAME_INPUT_DEFINE, 87cdf0e10cSrcweir SC_NAME_INPUT_BAD_NAME, 88cdf0e10cSrcweir SC_NAME_INPUT_BAD_SELECTION 89cdf0e10cSrcweir }; 90cdf0e10cSrcweir 91cdf0e10cSrcweir 92cdf0e10cSrcweir //================================================================== 93cdf0e10cSrcweir // class ScInputWindowWrapper 94cdf0e10cSrcweir //================================================================== 95cdf0e10cSrcweir 96cdf0e10cSrcweir SFX_IMPL_CHILDWINDOW(ScInputWindowWrapper,FID_INPUTLINE_STATUS) 97cdf0e10cSrcweir 98cdf0e10cSrcweir ScInputWindowWrapper::ScInputWindowWrapper( Window* pParentP, 99cdf0e10cSrcweir sal_uInt16 nId, 100cdf0e10cSrcweir SfxBindings* pBindings, 101cdf0e10cSrcweir SfxChildWinInfo* /* pInfo */ ) 102cdf0e10cSrcweir : SfxChildWindow( pParentP, nId ) 103cdf0e10cSrcweir { 104cdf0e10cSrcweir ScInputWindow* pWin=new ScInputWindow( pParentP, pBindings ); 105cdf0e10cSrcweir pWindow = pWin; 106cdf0e10cSrcweir 107cdf0e10cSrcweir pWin->Show(); 108cdf0e10cSrcweir 109cdf0e10cSrcweir pWin->SetSizePixel( pWin->CalcWindowSizePixel() ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_LOWESTTOP; 112cdf0e10cSrcweir pBindings->Invalidate( FID_TOGGLEINPUTLINE ); 113cdf0e10cSrcweir } 114cdf0e10cSrcweir 115cdf0e10cSrcweir // GetInfo fliegt wieder raus, wenn es ein SFX_IMPL_TOOLBOX gibt !!!! 116cdf0e10cSrcweir 117cdf0e10cSrcweir SfxChildWinInfo __EXPORT ScInputWindowWrapper::GetInfo() const 118cdf0e10cSrcweir { 119cdf0e10cSrcweir SfxChildWinInfo aInfo = SfxChildWindow::GetInfo(); 120cdf0e10cSrcweir return aInfo; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir 123cdf0e10cSrcweir //================================================================== 124cdf0e10cSrcweir 125cdf0e10cSrcweir #define IMAGE(id) pImgMgr->SeekImage(id, bHC) 126cdf0e10cSrcweir 127cdf0e10cSrcweir //================================================================== 128cdf0e10cSrcweir // class ScInputWindow 129cdf0e10cSrcweir //================================================================== 130cdf0e10cSrcweir 131cdf0e10cSrcweir ScInputWindow::ScInputWindow( Window* pParent, SfxBindings* pBind ) : 132cdf0e10cSrcweir #ifdef OS2 133cdf0e10cSrcweir // #37192# ohne WB_CLIPCHILDREN wg. os/2 Paintproblem 134cdf0e10cSrcweir ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK) ), 135cdf0e10cSrcweir #else 136cdf0e10cSrcweir // mit WB_CLIPCHILDREN, sonst Flicker 137cdf0e10cSrcweir ToolBox ( pParent, WinBits(WB_BORDER|WB_3DLOOK|WB_CLIPCHILDREN) ), 138cdf0e10cSrcweir #endif 139cdf0e10cSrcweir aWndPos ( this ), 140cdf0e10cSrcweir aTextWindow ( this ), 141cdf0e10cSrcweir pInputHdl ( NULL ), 142cdf0e10cSrcweir pBindings ( pBind ), 143cdf0e10cSrcweir aTextOk ( ScResId( SCSTR_QHELP_BTNOK ) ), // nicht immer neu aus Resource 144cdf0e10cSrcweir aTextCancel ( ScResId( SCSTR_QHELP_BTNCANCEL ) ), 145cdf0e10cSrcweir aTextSum ( ScResId( SCSTR_QHELP_BTNSUM ) ), 146cdf0e10cSrcweir aTextEqual ( ScResId( SCSTR_QHELP_BTNEQUAL ) ), 147cdf0e10cSrcweir bIsOkCancelMode ( sal_False ) 148cdf0e10cSrcweir { 149cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 150cdf0e10cSrcweir SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); 151cdf0e10cSrcweir 152cdf0e10cSrcweir // #i73615# don't rely on SfxViewShell::Current while constructing the input line 153cdf0e10cSrcweir // (also for GetInputHdl below) 154cdf0e10cSrcweir ScTabViewShell* pViewSh = NULL; 155cdf0e10cSrcweir SfxDispatcher* pDisp = pBind->GetDispatcher(); 156cdf0e10cSrcweir if ( pDisp ) 157cdf0e10cSrcweir { 158cdf0e10cSrcweir SfxViewFrame* pViewFrm = pDisp->GetFrame(); 159cdf0e10cSrcweir if ( pViewFrm ) 160cdf0e10cSrcweir pViewSh = PTR_CAST( ScTabViewShell, pViewFrm->GetViewShell() ); 161cdf0e10cSrcweir } 162cdf0e10cSrcweir DBG_ASSERT( pViewSh, "no view shell for input window" ); 163cdf0e10cSrcweir 164cdf0e10cSrcweir sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 165cdf0e10cSrcweir 166cdf0e10cSrcweir // Positionsfenster, 3 Buttons, Eingabefenster 167cdf0e10cSrcweir InsertWindow ( 1, &aWndPos, 0, 0 ); 168cdf0e10cSrcweir InsertSeparator ( 1 ); 169cdf0e10cSrcweir InsertItem ( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ), 0, 2 ); 170cdf0e10cSrcweir InsertItem ( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), 0, 3 ); 171cdf0e10cSrcweir InsertItem ( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), 0, 4 ); 172cdf0e10cSrcweir InsertSeparator ( 5 ); 173cdf0e10cSrcweir InsertWindow ( 7, &aTextWindow, 0, 6 ); 174cdf0e10cSrcweir 175cdf0e10cSrcweir aWndPos .SetQuickHelpText( ScResId( SCSTR_QHELP_POSWND ) ); 176cdf0e10cSrcweir aWndPos .SetHelpId ( HID_INSWIN_POS ); 177cdf0e10cSrcweir aTextWindow.SetQuickHelpText( ScResId( SCSTR_QHELP_INPUTWND ) ); 178cdf0e10cSrcweir aTextWindow.SetHelpId ( HID_INSWIN_INPUT ); 179cdf0e10cSrcweir 180cdf0e10cSrcweir // kein SetHelpText, die Hilfetexte kommen aus der Hilfe 181cdf0e10cSrcweir 182cdf0e10cSrcweir SetItemText ( SID_INPUT_FUNCTION, ScResId( SCSTR_QHELP_BTNCALC ) ); 183cdf0e10cSrcweir SetHelpId ( SID_INPUT_FUNCTION, HID_INSWIN_CALC ); 184cdf0e10cSrcweir 185cdf0e10cSrcweir SetItemText ( SID_INPUT_SUM, aTextSum ); 186cdf0e10cSrcweir SetHelpId ( SID_INPUT_SUM, HID_INSWIN_SUMME ); 187cdf0e10cSrcweir 188cdf0e10cSrcweir SetItemText ( SID_INPUT_EQUAL, aTextEqual ); 189cdf0e10cSrcweir SetHelpId ( SID_INPUT_EQUAL, HID_INSWIN_FUNC ); 190cdf0e10cSrcweir 191cdf0e10cSrcweir SetHelpId( HID_SC_INPUTWIN ); // fuer die ganze Eingabezeile 192cdf0e10cSrcweir 193cdf0e10cSrcweir aWndPos .Show(); 194cdf0e10cSrcweir aTextWindow .Show(); 195cdf0e10cSrcweir 196cdf0e10cSrcweir pInputHdl = SC_MOD()->GetInputHdl( pViewSh, sal_False ); // use own handler even if ref-handler is set 197cdf0e10cSrcweir if (pInputHdl) 198cdf0e10cSrcweir pInputHdl->SetInputWindow( this ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir if ( pInputHdl && pInputHdl->GetFormString().Len() ) 201cdf0e10cSrcweir { 202cdf0e10cSrcweir // Umschalten waehrend der Funktionsautopilot aktiv ist 203cdf0e10cSrcweir // -> Inhalt des Funktionsautopiloten wieder anzeigen 204cdf0e10cSrcweir //! auch Selektion (am InputHdl gemerkt) wieder anzeigen 205cdf0e10cSrcweir 206cdf0e10cSrcweir aTextWindow.SetTextString( pInputHdl->GetFormString() ); 207cdf0e10cSrcweir } 208cdf0e10cSrcweir else if ( pInputHdl && pInputHdl->IsInputMode() ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir // wenn waehrend des Editierens die Eingabezeile weg war 211cdf0e10cSrcweir // (Editieren einer Formel, dann umschalten zu fremdem Dokument/Hilfe), 212cdf0e10cSrcweir // wieder den gerade editierten Text aus dem InputHandler anzeigen 213cdf0e10cSrcweir 214cdf0e10cSrcweir aTextWindow.SetTextString( pInputHdl->GetEditString() ); // Text anzeigen 215cdf0e10cSrcweir if ( pInputHdl->IsTopMode() ) 216cdf0e10cSrcweir pInputHdl->SetMode( SC_INPUT_TABLE ); // Focus kommt eh nach unten 217cdf0e10cSrcweir } 218cdf0e10cSrcweir else if ( pViewSh ) 219cdf0e10cSrcweir pViewSh->UpdateInputHandler( sal_True ); // unbedingtes Update 220cdf0e10cSrcweir 221cdf0e10cSrcweir pImgMgr->RegisterToolBox( this ); 222cdf0e10cSrcweir SetAccessibleName(ScResId(STR_ACC_TOOLBAR_FORMULA)); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir __EXPORT ScInputWindow::~ScInputWindow() 226cdf0e10cSrcweir { 227cdf0e10cSrcweir sal_Bool bDown = ( ScGlobal::pSysLocale == NULL ); // after Clear? 228cdf0e10cSrcweir 229cdf0e10cSrcweir // if any view's input handler has a pointer to this input window, reset it 230cdf0e10cSrcweir // (may be several ones, #74522#) 231cdf0e10cSrcweir // member pInputHdl is not used here 232cdf0e10cSrcweir 233cdf0e10cSrcweir if ( !bDown ) 234cdf0e10cSrcweir { 235cdf0e10cSrcweir TypeId aScType = TYPE(ScTabViewShell); 236cdf0e10cSrcweir SfxViewShell* pSh = SfxViewShell::GetFirst( &aScType ); 237cdf0e10cSrcweir while ( pSh ) 238cdf0e10cSrcweir { 239cdf0e10cSrcweir ScInputHandler* pHdl = ((ScTabViewShell*)pSh)->GetInputHandler(); 240cdf0e10cSrcweir if ( pHdl && pHdl->GetInputWindow() == this ) 241cdf0e10cSrcweir { 242cdf0e10cSrcweir pHdl->SetInputWindow( NULL ); 243cdf0e10cSrcweir pHdl->StopInputWinEngine( sal_False ); // #125841# reset pTopView pointer 244cdf0e10cSrcweir } 245cdf0e10cSrcweir pSh = SfxViewShell::GetNext( *pSh, &aScType ); 246cdf0e10cSrcweir } 247cdf0e10cSrcweir } 248cdf0e10cSrcweir 249cdf0e10cSrcweir SfxImageManager::GetImageManager( SC_MOD() )->ReleaseToolBox( this ); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir void ScInputWindow::SetInputHandler( ScInputHandler* pNew ) 253cdf0e10cSrcweir { 254cdf0e10cSrcweir // wird im Activate der View gerufen... 255cdf0e10cSrcweir 256cdf0e10cSrcweir if ( pNew != pInputHdl ) 257cdf0e10cSrcweir { 258cdf0e10cSrcweir // Bei Reload (letzte Version) ist pInputHdl der Input-Handler der alten, 259cdf0e10cSrcweir // geloeschten ViewShell, darum hier auf keinen Fall anfassen! 260cdf0e10cSrcweir 261cdf0e10cSrcweir pInputHdl = pNew; 262cdf0e10cSrcweir if (pInputHdl) 263cdf0e10cSrcweir pInputHdl->SetInputWindow( this ); 264cdf0e10cSrcweir } 265cdf0e10cSrcweir } 266cdf0e10cSrcweir 267cdf0e10cSrcweir sal_Bool ScInputWindow::UseSubTotal(ScRangeList* pRangeList) const 268cdf0e10cSrcweir { 269cdf0e10cSrcweir sal_Bool bSubTotal(sal_False); 270cdf0e10cSrcweir ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); 271cdf0e10cSrcweir if ( pViewSh ) 272cdf0e10cSrcweir { 273cdf0e10cSrcweir ScDocument* pDoc = pViewSh->GetViewData()->GetDocument(); 274cdf0e10cSrcweir sal_Int32 nRangeCount (pRangeList->Count()); 275cdf0e10cSrcweir sal_Int32 nRangeIndex (0); 276cdf0e10cSrcweir while (!bSubTotal && nRangeIndex < nRangeCount) 277cdf0e10cSrcweir { 278cdf0e10cSrcweir const ScRange* pRange = pRangeList->GetObject( nRangeIndex ); 279cdf0e10cSrcweir if( pRange ) 280cdf0e10cSrcweir { 281cdf0e10cSrcweir SCTAB nTabEnd(pRange->aEnd.Tab()); 282cdf0e10cSrcweir SCTAB nTab(pRange->aStart.Tab()); 283cdf0e10cSrcweir while (!bSubTotal && nTab <= nTabEnd) 284cdf0e10cSrcweir { 285cdf0e10cSrcweir SCROW nRowEnd(pRange->aEnd.Row()); 286cdf0e10cSrcweir SCROW nRow(pRange->aStart.Row()); 287cdf0e10cSrcweir while (!bSubTotal && nRow <= nRowEnd) 288cdf0e10cSrcweir { 289cdf0e10cSrcweir if (pDoc->RowFiltered(nRow, nTab)) 290cdf0e10cSrcweir bSubTotal = sal_True; 291cdf0e10cSrcweir else 292cdf0e10cSrcweir ++nRow; 293cdf0e10cSrcweir } 294cdf0e10cSrcweir ++nTab; 295cdf0e10cSrcweir } 296cdf0e10cSrcweir } 297cdf0e10cSrcweir ++nRangeIndex; 298cdf0e10cSrcweir } 299cdf0e10cSrcweir 300cdf0e10cSrcweir ScDBCollection* pDBCollection = pDoc->GetDBCollection(); 301cdf0e10cSrcweir sal_uInt16 nDBCount (pDBCollection->GetCount()); 302cdf0e10cSrcweir sal_uInt16 nDBIndex (0); 303cdf0e10cSrcweir while (!bSubTotal && nDBIndex < nDBCount) 304cdf0e10cSrcweir { 305cdf0e10cSrcweir ScDBData* pDB = (*pDBCollection)[nDBIndex]; 306cdf0e10cSrcweir if (pDB && pDB->HasAutoFilter()) 307cdf0e10cSrcweir { 308cdf0e10cSrcweir nRangeIndex = 0; 309cdf0e10cSrcweir while (!bSubTotal && nRangeIndex < nRangeCount) 310cdf0e10cSrcweir { 311cdf0e10cSrcweir const ScRange* pRange = pRangeList->GetObject( nRangeIndex ); 312cdf0e10cSrcweir if( pRange ) 313cdf0e10cSrcweir { 314cdf0e10cSrcweir ScRange aDBArea; 315cdf0e10cSrcweir pDB->GetArea(aDBArea); 316cdf0e10cSrcweir if (aDBArea.Intersects(*pRange)) 317cdf0e10cSrcweir bSubTotal = sal_True; 318cdf0e10cSrcweir } 319cdf0e10cSrcweir ++nRangeIndex; 320cdf0e10cSrcweir } 321cdf0e10cSrcweir } 322cdf0e10cSrcweir ++nDBIndex; 323cdf0e10cSrcweir } 324cdf0e10cSrcweir } 325cdf0e10cSrcweir return bSubTotal; 326cdf0e10cSrcweir } 327cdf0e10cSrcweir 328cdf0e10cSrcweir void __EXPORT ScInputWindow::Select() 329cdf0e10cSrcweir { 330cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 331cdf0e10cSrcweir ToolBox::Select(); 332cdf0e10cSrcweir 333cdf0e10cSrcweir switch ( GetCurItemId() ) 334cdf0e10cSrcweir { 335cdf0e10cSrcweir case SID_INPUT_FUNCTION: 336cdf0e10cSrcweir { 337cdf0e10cSrcweir //! new method at ScModule to query if function autopilot is open 338cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 339cdf0e10cSrcweir if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ) 340cdf0e10cSrcweir { 341cdf0e10cSrcweir pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION, 342cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); 343cdf0e10cSrcweir 344cdf0e10cSrcweir // die Toolbox wird sowieso disabled, also braucht auch nicht umgeschaltet 345cdf0e10cSrcweir // zu werden, egal ob's geklappt hat oder nicht 346cdf0e10cSrcweir // SetOkCancelMode(); 347cdf0e10cSrcweir } 348cdf0e10cSrcweir } 349cdf0e10cSrcweir break; 350cdf0e10cSrcweir 351cdf0e10cSrcweir case SID_INPUT_CANCEL: 352cdf0e10cSrcweir pScMod->InputCancelHandler(); 353cdf0e10cSrcweir SetSumAssignMode(); 354cdf0e10cSrcweir break; 355cdf0e10cSrcweir 356cdf0e10cSrcweir case SID_INPUT_OK: 357cdf0e10cSrcweir pScMod->InputEnterHandler(); 358cdf0e10cSrcweir SetSumAssignMode(); 359cdf0e10cSrcweir aTextWindow.Invalidate(); // sonst bleibt Selektion stehen 360cdf0e10cSrcweir break; 361cdf0e10cSrcweir 362cdf0e10cSrcweir case SID_INPUT_SUM: 363cdf0e10cSrcweir { 364cdf0e10cSrcweir ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); 365cdf0e10cSrcweir if ( pViewSh ) 366cdf0e10cSrcweir { 367cdf0e10cSrcweir const ScMarkData& rMark = pViewSh->GetViewData()->GetMarkData(); 368cdf0e10cSrcweir if ( rMark.IsMarked() || rMark.IsMultiMarked() ) 369cdf0e10cSrcweir { 370cdf0e10cSrcweir ScRangeList aMarkRangeList; 371cdf0e10cSrcweir rMark.FillRangeListWithMarks( &aMarkRangeList, sal_False ); 372cdf0e10cSrcweir ScDocument* pDoc = pViewSh->GetViewData()->GetDocument(); 373cdf0e10cSrcweir 374cdf0e10cSrcweir // check if one of the marked ranges is empty 375cdf0e10cSrcweir bool bEmpty = false; 376cdf0e10cSrcweir const sal_uLong nCount = aMarkRangeList.Count(); 377cdf0e10cSrcweir for ( sal_uLong i = 0; i < nCount; ++i ) 378cdf0e10cSrcweir { 379cdf0e10cSrcweir const ScRange aRange( *aMarkRangeList.GetObject( i ) ); 380cdf0e10cSrcweir if ( pDoc->IsBlockEmpty( aRange.aStart.Tab(), 381cdf0e10cSrcweir aRange.aStart.Col(), aRange.aStart.Row(), 382cdf0e10cSrcweir aRange.aEnd.Col(), aRange.aEnd.Row() ) ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir bEmpty = true; 385cdf0e10cSrcweir break; 386cdf0e10cSrcweir } 387cdf0e10cSrcweir } 388cdf0e10cSrcweir 389cdf0e10cSrcweir if ( bEmpty ) 390cdf0e10cSrcweir { 391cdf0e10cSrcweir ScRangeList aRangeList; 392cdf0e10cSrcweir const sal_Bool bDataFound = pViewSh->GetAutoSumArea( aRangeList ); 393cdf0e10cSrcweir if ( bDataFound ) 394cdf0e10cSrcweir { 395cdf0e10cSrcweir const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) ); 396cdf0e10cSrcweir pViewSh->EnterAutoSum( aRangeList, bSubTotal ); // Block mit Summen fuellen 397cdf0e10cSrcweir } 398cdf0e10cSrcweir } 399cdf0e10cSrcweir else 400cdf0e10cSrcweir { 401cdf0e10cSrcweir const sal_Bool bSubTotal( UseSubTotal( &aMarkRangeList ) ); 402cdf0e10cSrcweir for ( sal_uLong i = 0; i < nCount; ++i ) 403cdf0e10cSrcweir { 404cdf0e10cSrcweir const ScRange aRange( *aMarkRangeList.GetObject( i ) ); 405cdf0e10cSrcweir const bool bSetCursor = ( i == nCount - 1 ? true : false ); 406cdf0e10cSrcweir const bool bContinue = ( i != 0 ? true : false ); 407cdf0e10cSrcweir if ( !pViewSh->AutoSum( aRange, bSubTotal, bSetCursor, bContinue ) ) 408cdf0e10cSrcweir { 409cdf0e10cSrcweir pViewSh->MarkRange( aRange, sal_False, sal_False ); 410cdf0e10cSrcweir pViewSh->SetCursor( aRange.aEnd.Col(), aRange.aEnd.Row() ); 411cdf0e10cSrcweir const ScRangeList aRangeList; 412cdf0e10cSrcweir const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal ); 413cdf0e10cSrcweir SetFuncString( aFormula ); 414cdf0e10cSrcweir break; 415cdf0e10cSrcweir } 416cdf0e10cSrcweir } 417cdf0e10cSrcweir } 418cdf0e10cSrcweir } 419cdf0e10cSrcweir else // nur in Eingabezeile einfuegen 420cdf0e10cSrcweir { 421cdf0e10cSrcweir ScRangeList aRangeList; 422cdf0e10cSrcweir const sal_Bool bDataFound = pViewSh->GetAutoSumArea( aRangeList ); 423cdf0e10cSrcweir const sal_Bool bSubTotal( UseSubTotal( &aRangeList ) ); 424cdf0e10cSrcweir const String aFormula = pViewSh->GetAutoSumFormula( aRangeList, bSubTotal ); 425cdf0e10cSrcweir SetFuncString( aFormula ); 426cdf0e10cSrcweir 427cdf0e10cSrcweir if ( bDataFound && pScMod->IsEditMode() ) 428cdf0e10cSrcweir { 429cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh ); 430cdf0e10cSrcweir if ( pHdl ) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir pHdl->InitRangeFinder( aFormula ); 433cdf0e10cSrcweir 434cdf0e10cSrcweir //! SetSelection am InputHandler ??? 435cdf0e10cSrcweir //! bSelIsRef setzen ??? 436cdf0e10cSrcweir const xub_StrLen nOpen = aFormula.Search('('); 437cdf0e10cSrcweir const xub_StrLen nLen = aFormula.Len(); 438cdf0e10cSrcweir if ( nOpen != STRING_NOTFOUND && nLen > nOpen ) 439cdf0e10cSrcweir { 440cdf0e10cSrcweir sal_uInt8 nAdd(1); 441cdf0e10cSrcweir if (bSubTotal) 442cdf0e10cSrcweir nAdd = 3; 443cdf0e10cSrcweir ESelection aSel(0,nOpen+nAdd,0,nLen-1); 444cdf0e10cSrcweir EditView* pTableView = pHdl->GetTableView(); 445cdf0e10cSrcweir if (pTableView) 446cdf0e10cSrcweir pTableView->SetSelection(aSel); 447cdf0e10cSrcweir EditView* pTopView = pHdl->GetTopView(); 448cdf0e10cSrcweir if (pTopView) 449cdf0e10cSrcweir pTopView->SetSelection(aSel); 450cdf0e10cSrcweir } 451cdf0e10cSrcweir } 452cdf0e10cSrcweir } 453cdf0e10cSrcweir } 454cdf0e10cSrcweir } 455cdf0e10cSrcweir } 456cdf0e10cSrcweir break; 457cdf0e10cSrcweir 458cdf0e10cSrcweir case SID_INPUT_EQUAL: 459cdf0e10cSrcweir { 460cdf0e10cSrcweir aTextWindow.StartEditEngine(); 461cdf0e10cSrcweir if ( pScMod->IsEditMode() ) // nicht, wenn z.B. geschuetzt 462cdf0e10cSrcweir { 463cdf0e10cSrcweir aTextWindow.GrabFocus(); 464cdf0e10cSrcweir aTextWindow.SetTextString( '=' ); 465cdf0e10cSrcweir 466cdf0e10cSrcweir EditView* pView = aTextWindow.GetEditView(); 467cdf0e10cSrcweir if (pView) 468cdf0e10cSrcweir { 469cdf0e10cSrcweir pView->SetSelection( ESelection(0,1, 0,1) ); 470cdf0e10cSrcweir pScMod->InputChanged(pView); 471cdf0e10cSrcweir SetOkCancelMode(); 472cdf0e10cSrcweir pView->SetEditEngineUpdateMode(sal_True); 473cdf0e10cSrcweir } 474cdf0e10cSrcweir } 475cdf0e10cSrcweir break; 476cdf0e10cSrcweir } 477cdf0e10cSrcweir } 478cdf0e10cSrcweir } 479cdf0e10cSrcweir 480cdf0e10cSrcweir void __EXPORT ScInputWindow::Resize() 481cdf0e10cSrcweir { 482cdf0e10cSrcweir ToolBox::Resize(); 483cdf0e10cSrcweir 484cdf0e10cSrcweir long nWidth = GetSizePixel().Width(); 485cdf0e10cSrcweir long nLeft = aTextWindow.GetPosPixel().X(); 486cdf0e10cSrcweir Size aSize = aTextWindow.GetSizePixel(); 487cdf0e10cSrcweir 488cdf0e10cSrcweir aSize.Width() = Max( ((long)(nWidth - nLeft - 5)), (long)0 ); 489cdf0e10cSrcweir aTextWindow.SetSizePixel( aSize ); 490cdf0e10cSrcweir aTextWindow.Invalidate(); 491cdf0e10cSrcweir } 492cdf0e10cSrcweir 493cdf0e10cSrcweir void ScInputWindow::SetFuncString( const String& rString, sal_Bool bDoEdit ) 494cdf0e10cSrcweir { 495cdf0e10cSrcweir //! new method at ScModule to query if function autopilot is open 496cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 497cdf0e10cSrcweir EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); 498cdf0e10cSrcweir aTextWindow.StartEditEngine(); 499cdf0e10cSrcweir 500cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 501cdf0e10cSrcweir if ( pScMod->IsEditMode() ) 502cdf0e10cSrcweir { 503cdf0e10cSrcweir if ( bDoEdit ) 504cdf0e10cSrcweir aTextWindow.GrabFocus(); 505cdf0e10cSrcweir aTextWindow.SetTextString( rString ); 506cdf0e10cSrcweir EditView* pView = aTextWindow.GetEditView(); 507cdf0e10cSrcweir if (pView) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir xub_StrLen nLen = rString.Len(); 510cdf0e10cSrcweir 511cdf0e10cSrcweir if ( nLen > 0 ) 512cdf0e10cSrcweir { 513cdf0e10cSrcweir nLen--; 514cdf0e10cSrcweir pView->SetSelection( ESelection( 0, nLen, 0, nLen ) ); 515cdf0e10cSrcweir } 516cdf0e10cSrcweir 517cdf0e10cSrcweir pScMod->InputChanged(pView); 518cdf0e10cSrcweir if ( bDoEdit ) 519cdf0e10cSrcweir SetOkCancelMode(); // nicht, wenn gleich hinterher Enter/Cancel 520cdf0e10cSrcweir 521cdf0e10cSrcweir pView->SetEditEngineUpdateMode(sal_True); 522cdf0e10cSrcweir } 523cdf0e10cSrcweir } 524cdf0e10cSrcweir } 525cdf0e10cSrcweir 526cdf0e10cSrcweir void ScInputWindow::SetPosString( const String& rStr ) 527cdf0e10cSrcweir { 528cdf0e10cSrcweir aWndPos.SetPos( rStr ); 529cdf0e10cSrcweir } 530cdf0e10cSrcweir 531cdf0e10cSrcweir void ScInputWindow::SetTextString( const String& rString ) 532cdf0e10cSrcweir { 533cdf0e10cSrcweir if (rString.Len() <= 32767) 534cdf0e10cSrcweir aTextWindow.SetTextString(rString); 535cdf0e10cSrcweir else 536cdf0e10cSrcweir { 537cdf0e10cSrcweir String aNew = rString; 538cdf0e10cSrcweir aNew.Erase(32767); 539cdf0e10cSrcweir aTextWindow.SetTextString(aNew); 540cdf0e10cSrcweir } 541cdf0e10cSrcweir } 542cdf0e10cSrcweir 543cdf0e10cSrcweir void ScInputWindow::SetOkCancelMode() 544cdf0e10cSrcweir { 545cdf0e10cSrcweir //! new method at ScModule to query if function autopilot is open 546cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 547cdf0e10cSrcweir EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); 548cdf0e10cSrcweir 549cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 550cdf0e10cSrcweir SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); 551cdf0e10cSrcweir if (!bIsOkCancelMode) 552cdf0e10cSrcweir { 553cdf0e10cSrcweir sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 554cdf0e10cSrcweir 555cdf0e10cSrcweir RemoveItem( 3 ); // SID_INPUT_SUM und SID_INPUT_EQUAL entfernen 556cdf0e10cSrcweir RemoveItem( 3 ); 557cdf0e10cSrcweir InsertItem( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ), 0, 3 ); 558cdf0e10cSrcweir InsertItem( SID_INPUT_OK, IMAGE( SID_INPUT_OK ), 0, 4 ); 559cdf0e10cSrcweir SetItemText ( SID_INPUT_CANCEL, aTextCancel ); 560cdf0e10cSrcweir SetHelpId ( SID_INPUT_CANCEL, HID_INSWIN_CANCEL ); 561cdf0e10cSrcweir SetItemText ( SID_INPUT_OK, aTextOk ); 562cdf0e10cSrcweir SetHelpId ( SID_INPUT_OK, HID_INSWIN_OK ); 563cdf0e10cSrcweir bIsOkCancelMode = sal_True; 564cdf0e10cSrcweir } 565cdf0e10cSrcweir } 566cdf0e10cSrcweir 567cdf0e10cSrcweir void ScInputWindow::SetSumAssignMode() 568cdf0e10cSrcweir { 569cdf0e10cSrcweir //! new method at ScModule to query if function autopilot is open 570cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 571cdf0e10cSrcweir EnableButtons( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ); 572cdf0e10cSrcweir 573cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 574cdf0e10cSrcweir SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); 575cdf0e10cSrcweir if (bIsOkCancelMode) 576cdf0e10cSrcweir { 577cdf0e10cSrcweir sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 578cdf0e10cSrcweir 579cdf0e10cSrcweir // SID_INPUT_CANCEL, und SID_INPUT_OK entfernen 580cdf0e10cSrcweir RemoveItem( 3 ); 581cdf0e10cSrcweir RemoveItem( 3 ); 582cdf0e10cSrcweir InsertItem( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ), 0, 3 ); 583cdf0e10cSrcweir InsertItem( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ), 0, 4 ); 584cdf0e10cSrcweir SetItemText ( SID_INPUT_SUM, aTextSum ); 585cdf0e10cSrcweir SetHelpId ( SID_INPUT_SUM, HID_INSWIN_SUMME ); 586cdf0e10cSrcweir SetItemText ( SID_INPUT_EQUAL, aTextEqual ); 587cdf0e10cSrcweir SetHelpId ( SID_INPUT_EQUAL, HID_INSWIN_FUNC ); 588cdf0e10cSrcweir bIsOkCancelMode = sal_False; 589cdf0e10cSrcweir 590cdf0e10cSrcweir SetFormulaMode(sal_False); // kein editieren -> keine Formel 591cdf0e10cSrcweir } 592cdf0e10cSrcweir } 593cdf0e10cSrcweir 594cdf0e10cSrcweir void ScInputWindow::SetFormulaMode( sal_Bool bSet ) 595cdf0e10cSrcweir { 596cdf0e10cSrcweir aWndPos.SetFormulaMode(bSet); 597cdf0e10cSrcweir aTextWindow.SetFormulaMode(bSet); 598cdf0e10cSrcweir } 599cdf0e10cSrcweir 600cdf0e10cSrcweir void __EXPORT ScInputWindow::SetText( const String& rString ) 601cdf0e10cSrcweir { 602cdf0e10cSrcweir ToolBox::SetText(rString); 603cdf0e10cSrcweir } 604cdf0e10cSrcweir 605cdf0e10cSrcweir String __EXPORT ScInputWindow::GetText() const 606cdf0e10cSrcweir { 607cdf0e10cSrcweir return ToolBox::GetText(); 608cdf0e10cSrcweir } 609cdf0e10cSrcweir 610cdf0e10cSrcweir 611cdf0e10cSrcweir //UNUSED2008-05 EditView* ScInputWindow::ActivateEdit( const String& rText, 612cdf0e10cSrcweir //UNUSED2008-05 const ESelection& rSel ) 613cdf0e10cSrcweir //UNUSED2008-05 { 614cdf0e10cSrcweir //UNUSED2008-05 if ( !aTextWindow.IsInputActive() ) 615cdf0e10cSrcweir //UNUSED2008-05 { 616cdf0e10cSrcweir //UNUSED2008-05 aTextWindow.StartEditEngine(); 617cdf0e10cSrcweir //UNUSED2008-05 aTextWindow.GrabFocus(); 618cdf0e10cSrcweir //UNUSED2008-05 aTextWindow.SetTextString( rText ); 619cdf0e10cSrcweir //UNUSED2008-05 aTextWindow.GetEditView()->SetSelection( rSel ); 620cdf0e10cSrcweir //UNUSED2008-05 } 621cdf0e10cSrcweir //UNUSED2008-05 622cdf0e10cSrcweir //UNUSED2008-05 return aTextWindow.GetEditView(); 623cdf0e10cSrcweir //UNUSED2008-05 } 624cdf0e10cSrcweir 625cdf0e10cSrcweir sal_Bool ScInputWindow::IsInputActive() 626cdf0e10cSrcweir { 627cdf0e10cSrcweir return aTextWindow.IsInputActive(); 628cdf0e10cSrcweir } 629cdf0e10cSrcweir 630cdf0e10cSrcweir EditView* ScInputWindow::GetEditView() 631cdf0e10cSrcweir { 632cdf0e10cSrcweir return aTextWindow.GetEditView(); 633cdf0e10cSrcweir } 634cdf0e10cSrcweir 635cdf0e10cSrcweir void ScInputWindow::MakeDialogEditView() 636cdf0e10cSrcweir { 637cdf0e10cSrcweir aTextWindow.MakeDialogEditView(); 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir void ScInputWindow::StopEditEngine( sal_Bool bAll ) 641cdf0e10cSrcweir { 642cdf0e10cSrcweir aTextWindow.StopEditEngine( bAll ); 643cdf0e10cSrcweir } 644cdf0e10cSrcweir 645cdf0e10cSrcweir void ScInputWindow::TextGrabFocus() 646cdf0e10cSrcweir { 647cdf0e10cSrcweir aTextWindow.GrabFocus(); 648cdf0e10cSrcweir } 649cdf0e10cSrcweir 650cdf0e10cSrcweir void ScInputWindow::TextInvalidate() 651cdf0e10cSrcweir { 652cdf0e10cSrcweir aTextWindow.Invalidate(); 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir void ScInputWindow::SwitchToTextWin() 656cdf0e10cSrcweir { 657cdf0e10cSrcweir // used for shift-ctrl-F2 658cdf0e10cSrcweir 659cdf0e10cSrcweir aTextWindow.StartEditEngine(); 660cdf0e10cSrcweir if ( SC_MOD()->IsEditMode() ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir aTextWindow.GrabFocus(); 663cdf0e10cSrcweir EditView* pView = aTextWindow.GetEditView(); 664cdf0e10cSrcweir if (pView) 665cdf0e10cSrcweir { 666cdf0e10cSrcweir xub_StrLen nLen = pView->GetEditEngine()->GetTextLen(0); 667cdf0e10cSrcweir ESelection aSel( 0, nLen, 0, nLen ); 668cdf0e10cSrcweir pView->SetSelection( aSel ); // set cursor to end of text 669cdf0e10cSrcweir } 670cdf0e10cSrcweir } 671cdf0e10cSrcweir } 672cdf0e10cSrcweir 673cdf0e10cSrcweir void ScInputWindow::PosGrabFocus() 674cdf0e10cSrcweir { 675cdf0e10cSrcweir aWndPos.GrabFocus(); 676cdf0e10cSrcweir } 677cdf0e10cSrcweir 678cdf0e10cSrcweir void ScInputWindow::EnableButtons( sal_Bool bEnable ) 679cdf0e10cSrcweir { 680cdf0e10cSrcweir // when enabling buttons, always also enable the input window itself 681cdf0e10cSrcweir if ( bEnable && !IsEnabled() ) 682cdf0e10cSrcweir Enable(); 683cdf0e10cSrcweir 684cdf0e10cSrcweir EnableItem( SID_INPUT_FUNCTION, bEnable ); 685cdf0e10cSrcweir EnableItem( bIsOkCancelMode ? SID_INPUT_CANCEL : SID_INPUT_SUM, bEnable ); 686cdf0e10cSrcweir EnableItem( bIsOkCancelMode ? SID_INPUT_OK : SID_INPUT_EQUAL, bEnable ); 687cdf0e10cSrcweir // Invalidate(); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir 690cdf0e10cSrcweir void ScInputWindow::StateChanged( StateChangedType nType ) 691cdf0e10cSrcweir { 692cdf0e10cSrcweir ToolBox::StateChanged( nType ); 693cdf0e10cSrcweir 694cdf0e10cSrcweir if ( nType == STATE_CHANGE_INITSHOW ) Resize(); 695cdf0e10cSrcweir } 696cdf0e10cSrcweir 697cdf0e10cSrcweir void ScInputWindow::DataChanged( const DataChangedEvent& rDCEvt ) 698cdf0e10cSrcweir { 699cdf0e10cSrcweir if ( rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 700cdf0e10cSrcweir { 701cdf0e10cSrcweir // update item images 702cdf0e10cSrcweir 703cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 704cdf0e10cSrcweir SfxImageManager* pImgMgr = SfxImageManager::GetImageManager( pScMod ); 705cdf0e10cSrcweir sal_Bool bHC = GetSettings().GetStyleSettings().GetHighContrastMode(); 706cdf0e10cSrcweir // IMAGE macro uses pScMod, pImgMgr, bHC 707cdf0e10cSrcweir 708cdf0e10cSrcweir SetItemImage( SID_INPUT_FUNCTION, IMAGE( SID_INPUT_FUNCTION ) ); 709cdf0e10cSrcweir if ( bIsOkCancelMode ) 710cdf0e10cSrcweir { 711cdf0e10cSrcweir SetItemImage( SID_INPUT_CANCEL, IMAGE( SID_INPUT_CANCEL ) ); 712cdf0e10cSrcweir SetItemImage( SID_INPUT_OK, IMAGE( SID_INPUT_OK ) ); 713cdf0e10cSrcweir } 714cdf0e10cSrcweir else 715cdf0e10cSrcweir { 716cdf0e10cSrcweir SetItemImage( SID_INPUT_SUM, IMAGE( SID_INPUT_SUM ) ); 717cdf0e10cSrcweir SetItemImage( SID_INPUT_EQUAL, IMAGE( SID_INPUT_EQUAL ) ); 718cdf0e10cSrcweir } 719cdf0e10cSrcweir } 720cdf0e10cSrcweir 721cdf0e10cSrcweir ToolBox::DataChanged( rDCEvt ); 722cdf0e10cSrcweir } 723cdf0e10cSrcweir 724cdf0e10cSrcweir //======================================================================== 725cdf0e10cSrcweir // Eingabefenster 726cdf0e10cSrcweir //======================================================================== 727cdf0e10cSrcweir 728cdf0e10cSrcweir ScTextWnd::ScTextWnd( Window* pParent ) 729cdf0e10cSrcweir : Window ( pParent, WinBits(WB_HIDE | WB_BORDER) ), 730cdf0e10cSrcweir DragSourceHelper( this ), 731cdf0e10cSrcweir pEditEngine ( NULL ), 732cdf0e10cSrcweir pEditView ( NULL ), 733cdf0e10cSrcweir bIsInsertMode( sal_True ), 734cdf0e10cSrcweir bFormulaMode ( sal_False ), 735cdf0e10cSrcweir bInputMode ( sal_False ) 736cdf0e10cSrcweir { 737cdf0e10cSrcweir EnableRTL( sal_False ); // #106269# EditEngine can't be used with VCL EnableRTL 738cdf0e10cSrcweir 739cdf0e10cSrcweir bIsRTL = GetSettings().GetLayoutRTL(); 740cdf0e10cSrcweir 741cdf0e10cSrcweir // #79096# always use application font, so a font with cjk chars can be installed 742cdf0e10cSrcweir Font aAppFont = GetFont(); 743cdf0e10cSrcweir aTextFont = aAppFont; 744cdf0e10cSrcweir aTextFont.SetSize( PixelToLogic( aAppFont.GetSize(), MAP_TWIP ) ); // AppFont ist in Pixeln 745cdf0e10cSrcweir 746cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 747cdf0e10cSrcweir 748cdf0e10cSrcweir Color aBgColor= rStyleSettings.GetWindowColor(); 749cdf0e10cSrcweir Color aTxtColor= rStyleSettings.GetWindowTextColor(); 750cdf0e10cSrcweir 751cdf0e10cSrcweir aTextFont.SetTransparent ( sal_True ); 752cdf0e10cSrcweir aTextFont.SetFillColor ( aBgColor ); 753cdf0e10cSrcweir //aTextFont.SetColor ( COL_FIELDTEXT ); 754cdf0e10cSrcweir aTextFont.SetColor (aTxtColor); 755cdf0e10cSrcweir aTextFont.SetWeight ( WEIGHT_NORMAL ); 756cdf0e10cSrcweir 757cdf0e10cSrcweir Size aSize(1,TBX_WINDOW_HEIGHT); 758cdf0e10cSrcweir Size aMinEditSize( Edit::GetMinimumEditSize() ); 759cdf0e10cSrcweir if( aMinEditSize.Height() > aSize.Height() ) 760cdf0e10cSrcweir aSize.Height() = aMinEditSize.Height(); 761cdf0e10cSrcweir SetSizePixel ( aSize ); 762cdf0e10cSrcweir SetBackground ( aBgColor ); 763cdf0e10cSrcweir SetLineColor ( COL_BLACK ); 764cdf0e10cSrcweir SetMapMode ( MAP_TWIP ); 765cdf0e10cSrcweir SetPointer ( POINTER_TEXT ); 766cdf0e10cSrcweir } 767cdf0e10cSrcweir 768cdf0e10cSrcweir __EXPORT ScTextWnd::~ScTextWnd() 769cdf0e10cSrcweir { 770cdf0e10cSrcweir while (!maAccTextDatas.empty()) { 771cdf0e10cSrcweir maAccTextDatas.back()->Dispose(); 772cdf0e10cSrcweir } 773cdf0e10cSrcweir delete pEditView; 774cdf0e10cSrcweir delete pEditEngine; 775cdf0e10cSrcweir } 776cdf0e10cSrcweir 777cdf0e10cSrcweir void __EXPORT ScTextWnd::Paint( const Rectangle& rRec ) 778cdf0e10cSrcweir { 779cdf0e10cSrcweir if (pEditView) 780cdf0e10cSrcweir pEditView->Paint( rRec ); 781cdf0e10cSrcweir else 782cdf0e10cSrcweir { 783cdf0e10cSrcweir SetFont( aTextFont ); 784cdf0e10cSrcweir 785cdf0e10cSrcweir long nDiff = GetOutputSizePixel().Height() 786cdf0e10cSrcweir - LogicToPixel( Size( 0, GetTextHeight() ) ).Height(); 787cdf0e10cSrcweir // if (nDiff<2) nDiff=2; // mind. 1 Pixel 788cdf0e10cSrcweir 789cdf0e10cSrcweir long nStartPos = TEXT_STARTPOS; 790cdf0e10cSrcweir if ( bIsRTL ) 791cdf0e10cSrcweir { 792cdf0e10cSrcweir // right-align 793cdf0e10cSrcweir nStartPos += GetOutputSizePixel().Width() - 2*TEXT_STARTPOS - 794cdf0e10cSrcweir LogicToPixel( Size( GetTextWidth( aString ), 0 ) ).Width(); 795cdf0e10cSrcweir 796cdf0e10cSrcweir // LayoutMode isn't changed as long as ModifyRTLDefaults doesn't include SvxFrameDirectionItem 797cdf0e10cSrcweir } 798cdf0e10cSrcweir 799cdf0e10cSrcweir DrawText( PixelToLogic( Point( nStartPos, nDiff/2 ) ), aString ); 800cdf0e10cSrcweir } 801cdf0e10cSrcweir } 802cdf0e10cSrcweir 803cdf0e10cSrcweir void __EXPORT ScTextWnd::Resize() 804cdf0e10cSrcweir { 805cdf0e10cSrcweir if (pEditView) 806cdf0e10cSrcweir { 807cdf0e10cSrcweir Size aSize = GetOutputSizePixel(); 808cdf0e10cSrcweir long nDiff = aSize.Height() 809cdf0e10cSrcweir - LogicToPixel( Size( 0, GetTextHeight() ) ).Height(); 810cdf0e10cSrcweir 811cdf0e10cSrcweir #ifdef OS2_DOCH_NICHT 812cdf0e10cSrcweir nDiff-=2; // wird durch 2 geteilt 813cdf0e10cSrcweir // passt sonst nicht zur normalen Textausgabe 814cdf0e10cSrcweir #endif 815cdf0e10cSrcweir 816cdf0e10cSrcweir aSize.Width() -= 2 * TEXT_STARTPOS - 1; 817cdf0e10cSrcweir 818cdf0e10cSrcweir pEditView->SetOutputArea( 819cdf0e10cSrcweir PixelToLogic( Rectangle( Point( TEXT_STARTPOS, (nDiff > 0) ? nDiff/2 : 1 ), 820cdf0e10cSrcweir aSize ) ) ); 821cdf0e10cSrcweir } 822cdf0e10cSrcweir } 823cdf0e10cSrcweir 824cdf0e10cSrcweir void __EXPORT ScTextWnd::MouseMove( const MouseEvent& rMEvt ) 825cdf0e10cSrcweir { 826cdf0e10cSrcweir if (pEditView) 827cdf0e10cSrcweir pEditView->MouseMove( rMEvt ); 828cdf0e10cSrcweir } 829cdf0e10cSrcweir 830cdf0e10cSrcweir void __EXPORT ScTextWnd::MouseButtonDown( const MouseEvent& rMEvt ) 831cdf0e10cSrcweir { 832cdf0e10cSrcweir if (!HasFocus()) 833cdf0e10cSrcweir { 834cdf0e10cSrcweir StartEditEngine(); 835cdf0e10cSrcweir if ( SC_MOD()->IsEditMode() ) 836cdf0e10cSrcweir GrabFocus(); 837cdf0e10cSrcweir } 838cdf0e10cSrcweir 839cdf0e10cSrcweir if (pEditView) 840cdf0e10cSrcweir { 841cdf0e10cSrcweir pEditView->SetEditEngineUpdateMode( sal_True ); 842cdf0e10cSrcweir pEditView->MouseButtonDown( rMEvt ); 843cdf0e10cSrcweir } 844cdf0e10cSrcweir } 845cdf0e10cSrcweir 846cdf0e10cSrcweir void __EXPORT ScTextWnd::MouseButtonUp( const MouseEvent& rMEvt ) 847cdf0e10cSrcweir { 848cdf0e10cSrcweir if (pEditView) 849cdf0e10cSrcweir if (pEditView->MouseButtonUp( rMEvt )) 850cdf0e10cSrcweir { 851cdf0e10cSrcweir if ( rMEvt.IsMiddle() && 852cdf0e10cSrcweir GetSettings().GetMouseSettings().GetMiddleButtonAction() == MOUSE_MIDDLE_PASTESELECTION ) 853cdf0e10cSrcweir { 854cdf0e10cSrcweir // EditView may have pasted from selection 855cdf0e10cSrcweir SC_MOD()->InputChanged( pEditView ); 856cdf0e10cSrcweir } 857cdf0e10cSrcweir else 858cdf0e10cSrcweir SC_MOD()->InputSelection( pEditView ); 859cdf0e10cSrcweir } 860cdf0e10cSrcweir } 861cdf0e10cSrcweir 862cdf0e10cSrcweir void __EXPORT ScTextWnd::Command( const CommandEvent& rCEvt ) 863cdf0e10cSrcweir { 864cdf0e10cSrcweir bInputMode = sal_True; 865cdf0e10cSrcweir sal_uInt16 nCommand = rCEvt.GetCommand(); 866cdf0e10cSrcweir if ( pEditView /* && ( nCommand == COMMAND_STARTDRAG || nCommand == COMMAND_VOICE ) */ ) 867cdf0e10cSrcweir { 868cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 869cdf0e10cSrcweir ScTabViewShell* pStartViewSh = ScTabViewShell::GetActiveViewShell(); 870cdf0e10cSrcweir 871cdf0e10cSrcweir // #109441# don't modify the font defaults here - the right defaults are 872cdf0e10cSrcweir // already set in StartEditEngine when the EditEngine is created 873cdf0e10cSrcweir 874cdf0e10cSrcweir // #63263# verhindern, dass die EditView beim View-Umschalten wegkommt 875cdf0e10cSrcweir pScMod->SetInEditCommand( sal_True ); 876cdf0e10cSrcweir pEditView->Command( rCEvt ); 877cdf0e10cSrcweir pScMod->SetInEditCommand( sal_False ); 878cdf0e10cSrcweir 879cdf0e10cSrcweir // #48929# COMMAND_STARTDRAG heiss noch lange nicht, dass der Inhalt geaendert wurde 880cdf0e10cSrcweir // darum in dem Fall kein InputChanged 881cdf0e10cSrcweir //! erkennen, ob mit Move gedraggt wurde, oder Drag&Move irgendwie verbieten 882cdf0e10cSrcweir 883cdf0e10cSrcweir if ( nCommand == COMMAND_STARTDRAG ) 884cdf0e10cSrcweir { 885cdf0e10cSrcweir // ist auf eine andere View gedraggt worden? 886cdf0e10cSrcweir ScTabViewShell* pEndViewSh = ScTabViewShell::GetActiveViewShell(); 887cdf0e10cSrcweir if ( pEndViewSh != pStartViewSh && pStartViewSh != NULL ) 888cdf0e10cSrcweir { 889cdf0e10cSrcweir ScViewData* pViewData = pStartViewSh->GetViewData(); 890cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl( pStartViewSh ); 891cdf0e10cSrcweir if ( pHdl && pViewData->HasEditView( pViewData->GetActivePart() ) ) 892cdf0e10cSrcweir { 893cdf0e10cSrcweir pHdl->CancelHandler(); 894cdf0e10cSrcweir pViewData->GetView()->ShowCursor(); // fehlt bei KillEditView, weil nicht aktiv 895cdf0e10cSrcweir } 896cdf0e10cSrcweir } 897cdf0e10cSrcweir } 898cdf0e10cSrcweir else if ( nCommand == COMMAND_CURSORPOS ) 899cdf0e10cSrcweir { 900cdf0e10cSrcweir // don't call InputChanged for COMMAND_CURSORPOS 901cdf0e10cSrcweir } 902cdf0e10cSrcweir else if ( nCommand == COMMAND_INPUTLANGUAGECHANGE ) 903cdf0e10cSrcweir { 904cdf0e10cSrcweir // #i55929# Font and font size state depends on input language if nothing is selected, 905cdf0e10cSrcweir // so the slots have to be invalidated when the input language is changed. 906cdf0e10cSrcweir 907cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 908cdf0e10cSrcweir if (pViewFrm) 909cdf0e10cSrcweir { 910cdf0e10cSrcweir SfxBindings& rBindings = pViewFrm->GetBindings(); 911cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_CHAR_FONT ); 912cdf0e10cSrcweir rBindings.Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 913cdf0e10cSrcweir } 914cdf0e10cSrcweir } 915cdf0e10cSrcweir else 916cdf0e10cSrcweir SC_MOD()->InputChanged( pEditView ); 917cdf0e10cSrcweir } 918cdf0e10cSrcweir else 919cdf0e10cSrcweir Window::Command(rCEvt); // sonst soll sich die Basisklasse drum kuemmern... 920cdf0e10cSrcweir 921cdf0e10cSrcweir bInputMode = sal_False; 922cdf0e10cSrcweir } 923cdf0e10cSrcweir 924cdf0e10cSrcweir void ScTextWnd::StartDrag( sal_Int8 /* nAction */, const Point& rPosPixel ) 925cdf0e10cSrcweir { 926cdf0e10cSrcweir if ( pEditView ) 927cdf0e10cSrcweir { 928cdf0e10cSrcweir CommandEvent aDragEvent( rPosPixel, COMMAND_STARTDRAG, sal_True ); 929cdf0e10cSrcweir pEditView->Command( aDragEvent ); 930cdf0e10cSrcweir 931cdf0e10cSrcweir // handling of d&d to different view (CancelHandler) can't be done here, 932cdf0e10cSrcweir // because the call returns before d&d is complete. 933cdf0e10cSrcweir } 934cdf0e10cSrcweir } 935cdf0e10cSrcweir 936cdf0e10cSrcweir void __EXPORT ScTextWnd::KeyInput(const KeyEvent& rKEvt) 937cdf0e10cSrcweir { 938cdf0e10cSrcweir bInputMode = sal_True; 939cdf0e10cSrcweir if (!SC_MOD()->InputKeyEvent( rKEvt )) 940cdf0e10cSrcweir { 941cdf0e10cSrcweir sal_Bool bUsed = sal_False; 942cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 943cdf0e10cSrcweir if ( pViewSh ) 944cdf0e10cSrcweir bUsed = pViewSh->SfxKeyInput(rKEvt); // nur Acceleratoren, keine Eingabe 945cdf0e10cSrcweir if (!bUsed) 946cdf0e10cSrcweir Window::KeyInput( rKEvt ); 947cdf0e10cSrcweir } 948cdf0e10cSrcweir bInputMode = sal_False; 949cdf0e10cSrcweir } 950cdf0e10cSrcweir 951cdf0e10cSrcweir void __EXPORT ScTextWnd::GetFocus() 952cdf0e10cSrcweir { 953cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 954cdf0e10cSrcweir if ( pViewSh ) 955cdf0e10cSrcweir pViewSh->SetFormShellAtTop( sal_False ); // focus in input line -> FormShell no longer on top 956cdf0e10cSrcweir } 957cdf0e10cSrcweir 958cdf0e10cSrcweir void __EXPORT ScTextWnd::LoseFocus() 959cdf0e10cSrcweir { 960cdf0e10cSrcweir } 961cdf0e10cSrcweir 962cdf0e10cSrcweir String __EXPORT ScTextWnd::GetText() const 963cdf0e10cSrcweir { 964cdf0e10cSrcweir // ueberladen, um per Testtool an den Text heranzukommen 965cdf0e10cSrcweir 966cdf0e10cSrcweir if ( pEditEngine ) 967cdf0e10cSrcweir return pEditEngine->GetText(); 968cdf0e10cSrcweir else 969cdf0e10cSrcweir return GetTextString(); 970cdf0e10cSrcweir } 971cdf0e10cSrcweir 972cdf0e10cSrcweir void ScTextWnd::SetFormulaMode( sal_Bool bSet ) 973cdf0e10cSrcweir { 974cdf0e10cSrcweir if ( bSet != bFormulaMode ) 975cdf0e10cSrcweir { 976cdf0e10cSrcweir bFormulaMode = bSet; 977cdf0e10cSrcweir UpdateAutoCorrFlag(); 978cdf0e10cSrcweir } 979cdf0e10cSrcweir } 980cdf0e10cSrcweir 981cdf0e10cSrcweir void ScTextWnd::UpdateAutoCorrFlag() 982cdf0e10cSrcweir { 983cdf0e10cSrcweir if ( pEditEngine ) 984cdf0e10cSrcweir { 985cdf0e10cSrcweir sal_uLong nControl = pEditEngine->GetControlWord(); 986cdf0e10cSrcweir sal_uLong nOld = nControl; 987cdf0e10cSrcweir if ( bFormulaMode ) 988cdf0e10cSrcweir nControl &= ~EE_CNTRL_AUTOCORRECT; // keine Autokorrektur in Formeln 989cdf0e10cSrcweir else 990cdf0e10cSrcweir nControl |= EE_CNTRL_AUTOCORRECT; // sonst schon 991cdf0e10cSrcweir if ( nControl != nOld ) 992cdf0e10cSrcweir pEditEngine->SetControlWord( nControl ); 993cdf0e10cSrcweir } 994cdf0e10cSrcweir } 995cdf0e10cSrcweir 996cdf0e10cSrcweir void lcl_ExtendEditFontAttribs( SfxItemSet& rSet ) 997cdf0e10cSrcweir { 998cdf0e10cSrcweir const SfxPoolItem& rFontItem = rSet.Get( EE_CHAR_FONTINFO ); 999cdf0e10cSrcweir rSet.Put( rFontItem, EE_CHAR_FONTINFO_CJK ); 1000cdf0e10cSrcweir rSet.Put( rFontItem, EE_CHAR_FONTINFO_CTL ); 1001cdf0e10cSrcweir const SfxPoolItem& rHeightItem = rSet.Get( EE_CHAR_FONTHEIGHT ); 1002cdf0e10cSrcweir rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CJK ); 1003cdf0e10cSrcweir rSet.Put( rHeightItem, EE_CHAR_FONTHEIGHT_CTL ); 1004cdf0e10cSrcweir const SfxPoolItem& rWeightItem = rSet.Get( EE_CHAR_WEIGHT ); 1005cdf0e10cSrcweir rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CJK ); 1006cdf0e10cSrcweir rSet.Put( rWeightItem, EE_CHAR_WEIGHT_CTL ); 1007cdf0e10cSrcweir const SfxPoolItem& rItalicItem = rSet.Get( EE_CHAR_ITALIC ); 1008cdf0e10cSrcweir rSet.Put( rItalicItem, EE_CHAR_ITALIC_CJK ); 1009cdf0e10cSrcweir rSet.Put( rItalicItem, EE_CHAR_ITALIC_CTL ); 1010cdf0e10cSrcweir const SfxPoolItem& rLangItem = rSet.Get( EE_CHAR_LANGUAGE ); 1011cdf0e10cSrcweir rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CJK ); 1012cdf0e10cSrcweir rSet.Put( rLangItem, EE_CHAR_LANGUAGE_CTL ); 1013cdf0e10cSrcweir } 1014cdf0e10cSrcweir 1015cdf0e10cSrcweir void lcl_ModifyRTLDefaults( SfxItemSet& rSet ) 1016cdf0e10cSrcweir { 1017cdf0e10cSrcweir rSet.Put( SvxAdjustItem( SVX_ADJUST_RIGHT, EE_PARA_JUST ) ); 1018cdf0e10cSrcweir 1019cdf0e10cSrcweir // always using rtl writing direction would break formulas 1020cdf0e10cSrcweir //rSet.Put( SvxFrameDirectionItem( FRMDIR_HORI_RIGHT_TOP, EE_PARA_WRITINGDIR ) ); 1021cdf0e10cSrcweir 1022cdf0e10cSrcweir // PaperSize width is limited to USHRT_MAX in RTL mode (because of EditEngine's 1023cdf0e10cSrcweir // sal_uInt16 values in EditLine), so the text may be wrapped and line spacing must be 1024cdf0e10cSrcweir // increased to not see the beginning of the next line. 1025cdf0e10cSrcweir SvxLineSpacingItem aItem( SVX_LINESPACE_TWO_LINES, EE_PARA_SBL ); 1026cdf0e10cSrcweir aItem.SetPropLineSpace( 200 ); 1027cdf0e10cSrcweir rSet.Put( aItem ); 1028cdf0e10cSrcweir } 1029cdf0e10cSrcweir 1030cdf0e10cSrcweir void lcl_ModifyRTLVisArea( EditView* pEditView ) 1031cdf0e10cSrcweir { 1032cdf0e10cSrcweir Rectangle aVisArea = pEditView->GetVisArea(); 1033cdf0e10cSrcweir Size aPaper = pEditView->GetEditEngine()->GetPaperSize(); 1034cdf0e10cSrcweir long nDiff = aPaper.Width() - aVisArea.Right(); 1035cdf0e10cSrcweir aVisArea.Left() += nDiff; 1036cdf0e10cSrcweir aVisArea.Right() += nDiff; 1037cdf0e10cSrcweir pEditView->SetVisArea(aVisArea); 1038cdf0e10cSrcweir } 1039cdf0e10cSrcweir 1040cdf0e10cSrcweir void ScTextWnd::StartEditEngine() 1041cdf0e10cSrcweir { 1042cdf0e10cSrcweir // #31147# Bei "eigener Modalitaet" (Doc-modale Dialoge) nicht aktivieren 1043cdf0e10cSrcweir SfxObjectShell* pObjSh = SfxObjectShell::Current(); 1044cdf0e10cSrcweir if ( pObjSh && pObjSh->IsInModalMode() ) 1045cdf0e10cSrcweir return; 1046cdf0e10cSrcweir 1047cdf0e10cSrcweir if ( !pEditView || !pEditEngine ) 1048cdf0e10cSrcweir { 1049cdf0e10cSrcweir ScFieldEditEngine* pNew; 1050cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 1051cdf0e10cSrcweir if ( pViewSh ) 1052cdf0e10cSrcweir { 1053cdf0e10cSrcweir const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument(); 1054cdf0e10cSrcweir pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() ); 1055cdf0e10cSrcweir } 1056cdf0e10cSrcweir else 1057cdf0e10cSrcweir pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, sal_True ); 1058cdf0e10cSrcweir pNew->SetExecuteURL( sal_False ); 1059cdf0e10cSrcweir pEditEngine = pNew; 1060cdf0e10cSrcweir 1061cdf0e10cSrcweir pEditEngine->SetUpdateMode( sal_False ); 1062cdf0e10cSrcweir pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) ); 1063cdf0e10cSrcweir pEditEngine->SetWordDelimiters( 1064cdf0e10cSrcweir ScEditUtil::ModifyDelimiters( pEditEngine->GetWordDelimiters() ) ); 1065cdf0e10cSrcweir 1066cdf0e10cSrcweir UpdateAutoCorrFlag(); 1067cdf0e10cSrcweir 1068cdf0e10cSrcweir { 1069cdf0e10cSrcweir SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() ); 1070cdf0e10cSrcweir pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont ); 1071cdf0e10cSrcweir lcl_ExtendEditFontAttribs( *pSet ); 1072cdf0e10cSrcweir // turn off script spacing to match DrawText output 1073cdf0e10cSrcweir pSet->Put( SvxScriptSpaceItem( sal_False, EE_PARA_ASIANCJKSPACING ) ); 1074cdf0e10cSrcweir if ( bIsRTL ) 1075cdf0e10cSrcweir lcl_ModifyRTLDefaults( *pSet ); 1076cdf0e10cSrcweir pEditEngine->SetDefaults( pSet ); 1077cdf0e10cSrcweir } 1078cdf0e10cSrcweir 1079cdf0e10cSrcweir // #57254# Wenn in der Zelle URL-Felder enthalten sind, muessen die auch in 1080cdf0e10cSrcweir // die Eingabezeile uebernommen werden, weil sonst die Positionen nicht stimmen. 1081cdf0e10cSrcweir 1082cdf0e10cSrcweir sal_Bool bFilled = sal_False; 1083cdf0e10cSrcweir ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); 1084cdf0e10cSrcweir if ( pHdl ) //! Testen, ob's der richtige InputHdl ist? 1085cdf0e10cSrcweir bFilled = pHdl->GetTextAndFields( *pEditEngine ); 1086cdf0e10cSrcweir 1087cdf0e10cSrcweir pEditEngine->SetUpdateMode( sal_True ); 1088cdf0e10cSrcweir 1089cdf0e10cSrcweir // aString ist die Wahrheit... 1090cdf0e10cSrcweir if ( bFilled && pEditEngine->GetText() == aString ) 1091cdf0e10cSrcweir Invalidate(); // Repaint fuer (hinterlegte) Felder 1092cdf0e10cSrcweir else 1093cdf0e10cSrcweir pEditEngine->SetText(aString); // dann wenigstens den richtigen Text 1094cdf0e10cSrcweir 1095cdf0e10cSrcweir pEditView = new EditView( pEditEngine, this ); 1096cdf0e10cSrcweir pEditView->SetInsertMode(bIsInsertMode); 1097cdf0e10cSrcweir 1098cdf0e10cSrcweir // Text aus Clipboard wird als ASCII einzeilig uebernommen 1099cdf0e10cSrcweir sal_uLong n = pEditView->GetControlWord(); 1100cdf0e10cSrcweir pEditView->SetControlWord( n | EV_CNTRL_SINGLELINEPASTE ); 1101cdf0e10cSrcweir 1102cdf0e10cSrcweir pEditEngine->InsertView( pEditView, EE_APPEND ); 1103cdf0e10cSrcweir 1104cdf0e10cSrcweir Resize(); 1105cdf0e10cSrcweir 1106cdf0e10cSrcweir if ( bIsRTL ) 1107cdf0e10cSrcweir lcl_ModifyRTLVisArea( pEditView ); 1108cdf0e10cSrcweir 1109cdf0e10cSrcweir pEditEngine->SetModifyHdl(LINK(this, ScTextWnd, NotifyHdl)); 1110cdf0e10cSrcweir 1111cdf0e10cSrcweir if (!maAccTextDatas.empty()) 1112cdf0e10cSrcweir maAccTextDatas.back()->StartEdit(); 1113cdf0e10cSrcweir 1114cdf0e10cSrcweir // as long as EditEngine and DrawText sometimes differ for CTL text, 1115cdf0e10cSrcweir // repaint now to have the EditEngine's version visible 1116cdf0e10cSrcweir // SfxObjectShell* pObjSh = SfxObjectShell::Current(); 1117cdf0e10cSrcweir if ( pObjSh && pObjSh->ISA(ScDocShell) ) 1118cdf0e10cSrcweir { 1119cdf0e10cSrcweir ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); // any document 1120cdf0e10cSrcweir sal_uInt8 nScript = pDoc->GetStringScriptType( aString ); 1121cdf0e10cSrcweir if ( nScript & SCRIPTTYPE_COMPLEX ) 1122cdf0e10cSrcweir Invalidate(); 1123cdf0e10cSrcweir } 1124cdf0e10cSrcweir } 1125cdf0e10cSrcweir 1126cdf0e10cSrcweir SC_MOD()->SetInputMode( SC_INPUT_TOP ); 1127cdf0e10cSrcweir 1128cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 1129cdf0e10cSrcweir if (pViewFrm) 1130cdf0e10cSrcweir pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT ); 1131cdf0e10cSrcweir } 1132cdf0e10cSrcweir 1133cdf0e10cSrcweir IMPL_LINK(ScTextWnd, NotifyHdl, EENotify*, EMPTYARG) 1134cdf0e10cSrcweir { 1135cdf0e10cSrcweir if (pEditView && !bInputMode) 1136cdf0e10cSrcweir { 1137cdf0e10cSrcweir ScInputHandler* pHdl = SC_MOD()->GetInputHdl(); 1138cdf0e10cSrcweir 1139cdf0e10cSrcweir // #105354# Use the InputHandler's InOwnChange flag to prevent calling InputChanged 1140cdf0e10cSrcweir // while an InputHandler method is modifying the EditEngine content 1141cdf0e10cSrcweir 1142cdf0e10cSrcweir if ( pHdl && !pHdl->IsInOwnChange() ) 1143cdf0e10cSrcweir pHdl->InputChanged( pEditView, sal_True ); // #i20282# InputChanged must know if called from modify handler 1144cdf0e10cSrcweir } 1145cdf0e10cSrcweir 1146cdf0e10cSrcweir return 0; 1147cdf0e10cSrcweir } 1148cdf0e10cSrcweir 1149cdf0e10cSrcweir void ScTextWnd::StopEditEngine( sal_Bool bAll ) 1150cdf0e10cSrcweir { 1151cdf0e10cSrcweir if (pEditView) 1152cdf0e10cSrcweir { 1153cdf0e10cSrcweir if (!maAccTextDatas.empty()) 1154cdf0e10cSrcweir maAccTextDatas.back()->EndEdit(); 1155cdf0e10cSrcweir 1156cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 1157cdf0e10cSrcweir 1158cdf0e10cSrcweir if (!bAll) 1159cdf0e10cSrcweir pScMod->InputSelection( pEditView ); 1160cdf0e10cSrcweir aString = pEditEngine->GetText(); 1161cdf0e10cSrcweir bIsInsertMode = pEditView->IsInsertMode(); 1162cdf0e10cSrcweir sal_Bool bSelection = pEditView->HasSelection(); 1163cdf0e10cSrcweir pEditEngine->SetModifyHdl(Link()); 1164cdf0e10cSrcweir DELETEZ(pEditView); 1165cdf0e10cSrcweir DELETEZ(pEditEngine); 1166cdf0e10cSrcweir 1167cdf0e10cSrcweir if ( pScMod->IsEditMode() && !bAll ) 1168cdf0e10cSrcweir pScMod->SetInputMode(SC_INPUT_TABLE); 1169cdf0e10cSrcweir 1170cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 1171cdf0e10cSrcweir if (pViewFrm) 1172cdf0e10cSrcweir pViewFrm->GetBindings().Invalidate( SID_ATTR_INSERT ); 1173cdf0e10cSrcweir 1174cdf0e10cSrcweir if (bSelection) 1175cdf0e10cSrcweir Invalidate(); // damit Selektion nicht stehenbleibt 1176cdf0e10cSrcweir } 1177cdf0e10cSrcweir } 1178cdf0e10cSrcweir 1179cdf0e10cSrcweir void ScTextWnd::SetTextString( const String& rNewString ) 1180cdf0e10cSrcweir { 1181cdf0e10cSrcweir if ( rNewString != aString ) 1182cdf0e10cSrcweir { 1183cdf0e10cSrcweir bInputMode = sal_True; 1184cdf0e10cSrcweir 1185cdf0e10cSrcweir // Position der Aenderung suchen, nur Rest painten 1186cdf0e10cSrcweir 1187cdf0e10cSrcweir long nInvPos = 0; 1188cdf0e10cSrcweir long nStartPos = 0; 1189cdf0e10cSrcweir long nTextSize = 0; 1190cdf0e10cSrcweir 1191cdf0e10cSrcweir if (!pEditEngine) 1192cdf0e10cSrcweir { 1193cdf0e10cSrcweir sal_Bool bPaintAll; 1194cdf0e10cSrcweir if ( bIsRTL ) 1195cdf0e10cSrcweir bPaintAll = sal_True; 1196cdf0e10cSrcweir else 1197cdf0e10cSrcweir { 1198cdf0e10cSrcweir // test if CTL script type is involved 1199cdf0e10cSrcweir sal_uInt8 nOldScript = 0; 1200cdf0e10cSrcweir sal_uInt8 nNewScript = 0; 1201cdf0e10cSrcweir SfxObjectShell* pObjSh = SfxObjectShell::Current(); 1202cdf0e10cSrcweir if ( pObjSh && pObjSh->ISA(ScDocShell) ) 1203cdf0e10cSrcweir { 1204cdf0e10cSrcweir // any document can be used (used only for its break iterator) 1205cdf0e10cSrcweir ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); 1206cdf0e10cSrcweir nOldScript = pDoc->GetStringScriptType( aString ); 1207cdf0e10cSrcweir nNewScript = pDoc->GetStringScriptType( rNewString ); 1208cdf0e10cSrcweir } 1209cdf0e10cSrcweir bPaintAll = ( nOldScript & SCRIPTTYPE_COMPLEX ) || ( nNewScript & SCRIPTTYPE_COMPLEX ); 1210cdf0e10cSrcweir } 1211cdf0e10cSrcweir 1212cdf0e10cSrcweir if ( bPaintAll ) 1213cdf0e10cSrcweir { 1214cdf0e10cSrcweir // if CTL is involved, the whole text has to be redrawn 1215cdf0e10cSrcweir Invalidate(); 1216cdf0e10cSrcweir } 1217cdf0e10cSrcweir else 1218cdf0e10cSrcweir { 1219cdf0e10cSrcweir xub_StrLen nDifPos; 1220cdf0e10cSrcweir if (rNewString.Len() > aString.Len()) 1221cdf0e10cSrcweir nDifPos = rNewString.Match(aString); 1222cdf0e10cSrcweir else 1223cdf0e10cSrcweir nDifPos = aString.Match(rNewString); 1224cdf0e10cSrcweir 1225cdf0e10cSrcweir long nSize1 = GetTextWidth(aString); 1226cdf0e10cSrcweir long nSize2 = GetTextWidth(rNewString); 1227cdf0e10cSrcweir if ( nSize1>0 && nSize2>0 ) 1228cdf0e10cSrcweir nTextSize = Max( nSize1, nSize2 ); 1229cdf0e10cSrcweir else 1230cdf0e10cSrcweir nTextSize = GetOutputSize().Width(); // Ueberlauf 1231cdf0e10cSrcweir 1232cdf0e10cSrcweir if (nDifPos == STRING_MATCH) 1233cdf0e10cSrcweir nDifPos = 0; 1234cdf0e10cSrcweir 1235cdf0e10cSrcweir // -1 wegen Rundung und "A" 1236cdf0e10cSrcweir Point aLogicStart = PixelToLogic(Point(TEXT_STARTPOS-1,0)); 1237cdf0e10cSrcweir nStartPos = aLogicStart.X(); 1238cdf0e10cSrcweir nInvPos = nStartPos; 1239cdf0e10cSrcweir if (nDifPos) 1240cdf0e10cSrcweir nInvPos += GetTextWidth(aString,0,nDifPos); 1241cdf0e10cSrcweir 1242cdf0e10cSrcweir sal_uInt16 nFlags = 0; 1243cdf0e10cSrcweir if ( nDifPos == aString.Len() ) // only new characters appended 1244cdf0e10cSrcweir nFlags = INVALIDATE_NOERASE; // then background is already clear 1245cdf0e10cSrcweir 1246cdf0e10cSrcweir Invalidate( Rectangle( nInvPos, 0, 1247cdf0e10cSrcweir nStartPos+nTextSize, GetOutputSize().Height()-1 ), 1248cdf0e10cSrcweir nFlags ); 1249cdf0e10cSrcweir } 1250cdf0e10cSrcweir } 1251cdf0e10cSrcweir else 1252cdf0e10cSrcweir { 1253cdf0e10cSrcweir pEditEngine->SetText(rNewString); 1254cdf0e10cSrcweir } 1255cdf0e10cSrcweir 1256cdf0e10cSrcweir aString = rNewString; 1257cdf0e10cSrcweir 1258cdf0e10cSrcweir if (!maAccTextDatas.empty()) 1259cdf0e10cSrcweir maAccTextDatas.back()->TextChanged(); 1260cdf0e10cSrcweir 1261cdf0e10cSrcweir bInputMode = sal_False; 1262cdf0e10cSrcweir } 1263cdf0e10cSrcweir } 1264cdf0e10cSrcweir 1265cdf0e10cSrcweir const String& ScTextWnd::GetTextString() const 1266cdf0e10cSrcweir { 1267cdf0e10cSrcweir return aString; 1268cdf0e10cSrcweir } 1269cdf0e10cSrcweir 1270cdf0e10cSrcweir sal_Bool ScTextWnd::IsInputActive() 1271cdf0e10cSrcweir { 1272cdf0e10cSrcweir return HasFocus(); 1273cdf0e10cSrcweir } 1274cdf0e10cSrcweir 1275cdf0e10cSrcweir EditView* ScTextWnd::GetEditView() 1276cdf0e10cSrcweir { 1277cdf0e10cSrcweir return pEditView; 1278cdf0e10cSrcweir } 1279cdf0e10cSrcweir 1280cdf0e10cSrcweir void ScTextWnd::MakeDialogEditView() 1281cdf0e10cSrcweir { 1282cdf0e10cSrcweir if ( pEditView ) return; 1283cdf0e10cSrcweir 1284cdf0e10cSrcweir ScFieldEditEngine* pNew; 1285cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 1286cdf0e10cSrcweir if ( pViewSh ) 1287cdf0e10cSrcweir { 1288cdf0e10cSrcweir const ScDocument* pDoc = pViewSh->GetViewData()->GetDocument(); 1289cdf0e10cSrcweir pNew = new ScFieldEditEngine( pDoc->GetEnginePool(), pDoc->GetEditPool() ); 1290cdf0e10cSrcweir } 1291cdf0e10cSrcweir else 1292cdf0e10cSrcweir pNew = new ScFieldEditEngine( EditEngine::CreatePool(), NULL, sal_True ); 1293cdf0e10cSrcweir pNew->SetExecuteURL( sal_False ); 1294cdf0e10cSrcweir pEditEngine = pNew; 1295cdf0e10cSrcweir 1296cdf0e10cSrcweir pEditEngine->SetUpdateMode( sal_False ); 1297cdf0e10cSrcweir pEditEngine->SetWordDelimiters( pEditEngine->GetWordDelimiters() += '=' ); 1298cdf0e10cSrcweir pEditEngine->SetPaperSize( Size( bIsRTL ? USHRT_MAX : THESIZE, 300 ) ); 1299cdf0e10cSrcweir 1300cdf0e10cSrcweir SfxItemSet* pSet = new SfxItemSet( pEditEngine->GetEmptyItemSet() ); 1301cdf0e10cSrcweir pEditEngine->SetFontInfoInItemSet( *pSet, aTextFont ); 1302cdf0e10cSrcweir lcl_ExtendEditFontAttribs( *pSet ); 1303cdf0e10cSrcweir if ( bIsRTL ) 1304cdf0e10cSrcweir lcl_ModifyRTLDefaults( *pSet ); 1305cdf0e10cSrcweir pEditEngine->SetDefaults( pSet ); 1306cdf0e10cSrcweir pEditEngine->SetUpdateMode( sal_True ); 1307cdf0e10cSrcweir 1308cdf0e10cSrcweir pEditView = new EditView( pEditEngine, this ); 1309cdf0e10cSrcweir pEditEngine->InsertView( pEditView, EE_APPEND ); 1310cdf0e10cSrcweir 1311cdf0e10cSrcweir Resize(); 1312cdf0e10cSrcweir 1313cdf0e10cSrcweir if ( bIsRTL ) 1314cdf0e10cSrcweir lcl_ModifyRTLVisArea( pEditView ); 1315cdf0e10cSrcweir 1316cdf0e10cSrcweir if (!maAccTextDatas.empty()) 1317cdf0e10cSrcweir maAccTextDatas.back()->StartEdit(); 1318cdf0e10cSrcweir } 1319cdf0e10cSrcweir 1320cdf0e10cSrcweir void ScTextWnd::ImplInitSettings() 1321cdf0e10cSrcweir { 1322cdf0e10cSrcweir bIsRTL = GetSettings().GetLayoutRTL(); 1323cdf0e10cSrcweir 1324cdf0e10cSrcweir const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 1325cdf0e10cSrcweir 1326cdf0e10cSrcweir Color aBgColor= rStyleSettings.GetWindowColor(); 1327cdf0e10cSrcweir Color aTxtColor= rStyleSettings.GetWindowTextColor(); 1328cdf0e10cSrcweir 1329cdf0e10cSrcweir aTextFont.SetFillColor ( aBgColor ); 1330cdf0e10cSrcweir aTextFont.SetColor (aTxtColor); 1331cdf0e10cSrcweir SetBackground ( aBgColor ); 1332cdf0e10cSrcweir Invalidate(); 1333cdf0e10cSrcweir } 1334cdf0e10cSrcweir 1335cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > ScTextWnd::CreateAccessible() 1336cdf0e10cSrcweir { 1337cdf0e10cSrcweir return new ScAccessibleEditObject(GetAccessibleParentWindow()->GetAccessible(), NULL, this, 1338cdf0e10cSrcweir rtl::OUString(String(ScResId(STR_ACC_EDITLINE_NAME))), 1339cdf0e10cSrcweir rtl::OUString(String(ScResId(STR_ACC_EDITLINE_DESCR))), EditLine); 1340cdf0e10cSrcweir } 1341cdf0e10cSrcweir 1342cdf0e10cSrcweir void ScTextWnd::InsertAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) 1343cdf0e10cSrcweir { 1344cdf0e10cSrcweir OSL_ENSURE( ::std::find( maAccTextDatas.begin(), maAccTextDatas.end(), &rTextData ) == maAccTextDatas.end(), 1345cdf0e10cSrcweir "ScTextWnd::InsertAccessibleTextData - passed object already registered" ); 1346cdf0e10cSrcweir maAccTextDatas.push_back( &rTextData ); 1347cdf0e10cSrcweir } 1348cdf0e10cSrcweir 1349cdf0e10cSrcweir void ScTextWnd::RemoveAccessibleTextData( ScAccessibleEditLineTextData& rTextData ) 1350cdf0e10cSrcweir { 1351cdf0e10cSrcweir AccTextDataVector::iterator aEnd = maAccTextDatas.end(); 1352cdf0e10cSrcweir AccTextDataVector::iterator aIt = ::std::find( maAccTextDatas.begin(), aEnd, &rTextData ); 1353cdf0e10cSrcweir OSL_ENSURE( aIt != aEnd, "ScTextWnd::RemoveAccessibleTextData - passed object not registered" ); 1354cdf0e10cSrcweir if( aIt != aEnd ) 1355cdf0e10cSrcweir maAccTextDatas.erase( aIt ); 1356cdf0e10cSrcweir } 1357cdf0e10cSrcweir 1358cdf0e10cSrcweir // ----------------------------------------------------------------------- 1359cdf0e10cSrcweir 1360cdf0e10cSrcweir void ScTextWnd::DataChanged( const DataChangedEvent& rDCEvt ) 1361cdf0e10cSrcweir { 1362cdf0e10cSrcweir if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 1363cdf0e10cSrcweir (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1364cdf0e10cSrcweir { 1365cdf0e10cSrcweir ImplInitSettings(); 1366cdf0e10cSrcweir Invalidate(); 1367cdf0e10cSrcweir } 1368cdf0e10cSrcweir else 1369cdf0e10cSrcweir Window::DataChanged( rDCEvt ); 1370cdf0e10cSrcweir } 1371cdf0e10cSrcweir 1372cdf0e10cSrcweir 1373cdf0e10cSrcweir //======================================================================== 1374cdf0e10cSrcweir // Positionsfenster 1375cdf0e10cSrcweir //======================================================================== 1376cdf0e10cSrcweir 1377cdf0e10cSrcweir ScPosWnd::ScPosWnd( Window* pParent ) : 1378cdf0e10cSrcweir ComboBox ( pParent, WinBits(WB_HIDE | WB_DROPDOWN) ), 1379cdf0e10cSrcweir pAccel ( NULL ), 1380cdf0e10cSrcweir nTipVisible ( 0 ), 1381cdf0e10cSrcweir bFormulaMode( sal_False ) 1382cdf0e10cSrcweir { 1383cdf0e10cSrcweir Size aSize( GetTextWidth( String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("GW99999:GW99999")) ), 1384cdf0e10cSrcweir GetTextHeight() ); 1385cdf0e10cSrcweir aSize.Width() += 25; // ?? 1386cdf0e10cSrcweir aSize.Height() = CalcWindowSizePixel(11); // Funktionen: 10 MRU + "andere..." 1387cdf0e10cSrcweir SetSizePixel( aSize ); 1388cdf0e10cSrcweir 1389cdf0e10cSrcweir FillRangeNames(); 1390cdf0e10cSrcweir 1391cdf0e10cSrcweir StartListening( *SFX_APP() ); // fuer Navigator-Bereichsnamen-Updates 1392cdf0e10cSrcweir } 1393cdf0e10cSrcweir 1394cdf0e10cSrcweir __EXPORT ScPosWnd::~ScPosWnd() 1395cdf0e10cSrcweir { 1396cdf0e10cSrcweir EndListening( *SFX_APP() ); 1397cdf0e10cSrcweir 1398cdf0e10cSrcweir HideTip(); 1399cdf0e10cSrcweir 1400cdf0e10cSrcweir delete pAccel; 1401cdf0e10cSrcweir } 1402cdf0e10cSrcweir 1403cdf0e10cSrcweir void ScPosWnd::SetFormulaMode( sal_Bool bSet ) 1404cdf0e10cSrcweir { 1405cdf0e10cSrcweir if ( bSet != bFormulaMode ) 1406cdf0e10cSrcweir { 1407cdf0e10cSrcweir bFormulaMode = bSet; 1408cdf0e10cSrcweir 1409cdf0e10cSrcweir if ( bSet ) 1410cdf0e10cSrcweir FillFunctions(); 1411cdf0e10cSrcweir else 1412cdf0e10cSrcweir FillRangeNames(); 1413cdf0e10cSrcweir 1414cdf0e10cSrcweir HideTip(); 1415cdf0e10cSrcweir } 1416cdf0e10cSrcweir } 1417cdf0e10cSrcweir 1418cdf0e10cSrcweir void ScPosWnd::SetPos( const String& rPosStr ) 1419cdf0e10cSrcweir { 1420cdf0e10cSrcweir if ( aPosStr != rPosStr ) 1421cdf0e10cSrcweir { 1422cdf0e10cSrcweir aPosStr = rPosStr; 1423cdf0e10cSrcweir SetText(aPosStr); 1424cdf0e10cSrcweir } 1425cdf0e10cSrcweir } 1426cdf0e10cSrcweir 1427cdf0e10cSrcweir void ScPosWnd::FillRangeNames() 1428cdf0e10cSrcweir { 1429cdf0e10cSrcweir Clear(); 1430cdf0e10cSrcweir 1431cdf0e10cSrcweir SfxObjectShell* pObjSh = SfxObjectShell::Current(); 1432cdf0e10cSrcweir if ( pObjSh && pObjSh->ISA(ScDocShell) ) 1433cdf0e10cSrcweir { 1434cdf0e10cSrcweir ScDocument* pDoc = ((ScDocShell*)pObjSh)->GetDocument(); 1435cdf0e10cSrcweir 1436cdf0e10cSrcweir // per Hand sortieren, weil Funktionen nicht sortiert werden: 1437cdf0e10cSrcweir 1438cdf0e10cSrcweir ScRangeName* pRangeNames = pDoc->GetRangeName(); 1439cdf0e10cSrcweir sal_uInt16 nCount = pRangeNames->GetCount(); 1440cdf0e10cSrcweir if ( nCount > 0 ) 1441cdf0e10cSrcweir { 1442cdf0e10cSrcweir sal_uInt16 nValidCount = 0; 1443cdf0e10cSrcweir ScRange aDummy; 1444cdf0e10cSrcweir sal_uInt16 i; 1445cdf0e10cSrcweir for ( i=0; i<nCount; i++ ) 1446cdf0e10cSrcweir { 1447cdf0e10cSrcweir ScRangeData* pData = (*pRangeNames)[i]; 1448cdf0e10cSrcweir if (pData->IsValidReference(aDummy)) 1449cdf0e10cSrcweir nValidCount++; 1450cdf0e10cSrcweir } 1451cdf0e10cSrcweir if ( nValidCount ) 1452cdf0e10cSrcweir { 1453cdf0e10cSrcweir ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ]; 1454cdf0e10cSrcweir sal_uInt16 j; 1455cdf0e10cSrcweir for ( i=0, j=0; i<nCount; i++ ) 1456cdf0e10cSrcweir { 1457cdf0e10cSrcweir ScRangeData* pData = (*pRangeNames)[i]; 1458cdf0e10cSrcweir if (pData->IsValidReference(aDummy)) 1459cdf0e10cSrcweir ppSortArray[j++] = pData; 1460cdf0e10cSrcweir } 1461cdf0e10cSrcweir #ifndef ICC 1462cdf0e10cSrcweir qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*), 1463cdf0e10cSrcweir &ScRangeData_QsortNameCompare ); 1464cdf0e10cSrcweir #else 1465cdf0e10cSrcweir qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*), 1466cdf0e10cSrcweir ICCQsortNameCompare ); 1467cdf0e10cSrcweir #endif 1468cdf0e10cSrcweir for ( j=0; j<nValidCount; j++ ) 1469cdf0e10cSrcweir InsertEntry( ppSortArray[j]->GetName() ); 1470cdf0e10cSrcweir delete [] ppSortArray; 1471cdf0e10cSrcweir } 1472cdf0e10cSrcweir } 1473cdf0e10cSrcweir } 1474cdf0e10cSrcweir SetText(aPosStr); 1475cdf0e10cSrcweir } 1476cdf0e10cSrcweir 1477cdf0e10cSrcweir void ScPosWnd::FillFunctions() 1478cdf0e10cSrcweir { 1479cdf0e10cSrcweir Clear(); 1480cdf0e10cSrcweir 1481cdf0e10cSrcweir String aFirstName; 1482cdf0e10cSrcweir const ScAppOptions& rOpt = SC_MOD()->GetAppOptions(); 1483cdf0e10cSrcweir sal_uInt16 nMRUCount = rOpt.GetLRUFuncListCount(); 1484cdf0e10cSrcweir const sal_uInt16* pMRUList = rOpt.GetLRUFuncList(); 1485cdf0e10cSrcweir if (pMRUList) 1486cdf0e10cSrcweir { 1487cdf0e10cSrcweir const ScFunctionList* pFuncList = ScGlobal::GetStarCalcFunctionList(); 1488cdf0e10cSrcweir sal_uLong nListCount = pFuncList->GetCount(); 1489cdf0e10cSrcweir for (sal_uInt16 i=0; i<nMRUCount; i++) 1490cdf0e10cSrcweir { 1491cdf0e10cSrcweir sal_uInt16 nId = pMRUList[i]; 1492cdf0e10cSrcweir for (sal_uLong j=0; j<nListCount; j++) 1493cdf0e10cSrcweir { 1494cdf0e10cSrcweir const ScFuncDesc* pDesc = pFuncList->GetFunction( j ); 1495cdf0e10cSrcweir if ( pDesc->nFIndex == nId && pDesc->pFuncName ) 1496cdf0e10cSrcweir { 1497cdf0e10cSrcweir InsertEntry( *pDesc->pFuncName ); 1498cdf0e10cSrcweir if (!aFirstName.Len()) 1499cdf0e10cSrcweir aFirstName = *pDesc->pFuncName; 1500cdf0e10cSrcweir break; // nicht weitersuchen 1501cdf0e10cSrcweir } 1502cdf0e10cSrcweir } 1503cdf0e10cSrcweir } 1504cdf0e10cSrcweir } 1505cdf0e10cSrcweir 1506cdf0e10cSrcweir //! Eintrag "Andere..." fuer Funktions-Autopilot wieder aufnehmen, 1507cdf0e10cSrcweir //! wenn der Funktions-Autopilot mit dem bisher eingegebenen Text arbeiten kann! 1508cdf0e10cSrcweir 1509cdf0e10cSrcweir // InsertEntry( ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) ); 1510cdf0e10cSrcweir 1511cdf0e10cSrcweir SetText(aFirstName); 1512cdf0e10cSrcweir } 1513cdf0e10cSrcweir 1514cdf0e10cSrcweir void __EXPORT ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint ) 1515cdf0e10cSrcweir { 1516cdf0e10cSrcweir if ( !bFormulaMode ) 1517cdf0e10cSrcweir { 1518cdf0e10cSrcweir // muss die Liste der Bereichsnamen updgedated werden? 1519cdf0e10cSrcweir 1520cdf0e10cSrcweir if ( rHint.ISA(SfxSimpleHint) ) 1521cdf0e10cSrcweir { 1522cdf0e10cSrcweir sal_uLong nHintId = ((SfxSimpleHint&)rHint).GetId(); 1523cdf0e10cSrcweir if ( nHintId == SC_HINT_AREAS_CHANGED || nHintId == SC_HINT_NAVIGATOR_UPDATEALL) 1524cdf0e10cSrcweir FillRangeNames(); 1525cdf0e10cSrcweir } 1526cdf0e10cSrcweir else if ( rHint.ISA(SfxEventHint) ) 1527cdf0e10cSrcweir { 1528cdf0e10cSrcweir sal_uLong nEventId = ((SfxEventHint&)rHint).GetEventId(); 1529cdf0e10cSrcweir if ( nEventId == SFX_EVENT_ACTIVATEDOC ) 1530cdf0e10cSrcweir FillRangeNames(); 1531cdf0e10cSrcweir } 1532cdf0e10cSrcweir } 1533cdf0e10cSrcweir } 1534cdf0e10cSrcweir 1535cdf0e10cSrcweir void ScPosWnd::HideTip() 1536cdf0e10cSrcweir { 1537cdf0e10cSrcweir if ( nTipVisible ) 1538cdf0e10cSrcweir { 1539cdf0e10cSrcweir Help::HideTip( nTipVisible ); 1540cdf0e10cSrcweir nTipVisible = 0; 1541cdf0e10cSrcweir } 1542cdf0e10cSrcweir } 1543cdf0e10cSrcweir 1544cdf0e10cSrcweir ScNameInputType lcl_GetInputType( const String& rText ) 1545cdf0e10cSrcweir { 1546cdf0e10cSrcweir ScNameInputType eRet = SC_NAME_INPUT_BAD_NAME; // the more general error 1547cdf0e10cSrcweir 1548cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 1549cdf0e10cSrcweir if ( pViewSh ) 1550cdf0e10cSrcweir { 1551cdf0e10cSrcweir ScViewData* pViewData = pViewSh->GetViewData(); 1552cdf0e10cSrcweir ScDocument* pDoc = pViewData->GetDocument(); 1553cdf0e10cSrcweir SCTAB nTab = pViewData->GetTabNo(); 1554cdf0e10cSrcweir formula::FormulaGrammar::AddressConvention eConv = pDoc->GetAddressConvention(); 1555cdf0e10cSrcweir 1556cdf0e10cSrcweir // test in same order as in SID_CURRENTCELL execute 1557cdf0e10cSrcweir 1558cdf0e10cSrcweir ScRange aRange; 1559cdf0e10cSrcweir ScAddress aAddress; 1560cdf0e10cSrcweir ScRangeUtil aRangeUtil; 1561cdf0e10cSrcweir SCTAB nNameTab; 1562cdf0e10cSrcweir sal_Int32 nNumeric; 1563cdf0e10cSrcweir 1564cdf0e10cSrcweir if ( aRange.Parse( rText, pDoc, eConv ) & SCA_VALID ) 1565cdf0e10cSrcweir eRet = SC_NAME_INPUT_NAMEDRANGE; 1566cdf0e10cSrcweir else if ( aAddress.Parse( rText, pDoc, eConv ) & SCA_VALID ) 1567cdf0e10cSrcweir eRet = SC_NAME_INPUT_CELL; 1568cdf0e10cSrcweir else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_NAMES, eConv ) ) 1569cdf0e10cSrcweir eRet = SC_NAME_INPUT_NAMEDRANGE; 1570cdf0e10cSrcweir else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_DBASE, eConv ) ) 1571cdf0e10cSrcweir eRet = SC_NAME_INPUT_DATABASE; 1572cdf0e10cSrcweir else if ( ByteString( rText, RTL_TEXTENCODING_ASCII_US ).IsNumericAscii() && 1573cdf0e10cSrcweir ( nNumeric = rText.ToInt32() ) > 0 && nNumeric <= MAXROW+1 ) 1574cdf0e10cSrcweir eRet = SC_NAME_INPUT_ROW; 1575cdf0e10cSrcweir else if ( pDoc->GetTable( rText, nNameTab ) ) 1576cdf0e10cSrcweir eRet = SC_NAME_INPUT_SHEET; 1577cdf0e10cSrcweir else if ( ScRangeData::IsNameValid( rText, pDoc ) ) // nothing found, create new range? 1578cdf0e10cSrcweir { 1579cdf0e10cSrcweir if ( pViewData->GetSimpleArea( aRange ) == SC_MARK_SIMPLE ) 1580cdf0e10cSrcweir eRet = SC_NAME_INPUT_DEFINE; 1581cdf0e10cSrcweir else 1582cdf0e10cSrcweir eRet = SC_NAME_INPUT_BAD_SELECTION; 1583cdf0e10cSrcweir } 1584cdf0e10cSrcweir else 1585cdf0e10cSrcweir eRet = SC_NAME_INPUT_BAD_NAME; 1586cdf0e10cSrcweir } 1587cdf0e10cSrcweir 1588cdf0e10cSrcweir return eRet; 1589cdf0e10cSrcweir } 1590cdf0e10cSrcweir 1591cdf0e10cSrcweir void ScPosWnd::Modify() 1592cdf0e10cSrcweir { 1593cdf0e10cSrcweir ComboBox::Modify(); 1594cdf0e10cSrcweir 1595cdf0e10cSrcweir HideTip(); 1596cdf0e10cSrcweir 1597cdf0e10cSrcweir if ( !IsTravelSelect() && !bFormulaMode ) 1598cdf0e10cSrcweir { 1599cdf0e10cSrcweir // determine the action that would be taken for the current input 1600cdf0e10cSrcweir 1601cdf0e10cSrcweir ScNameInputType eType = lcl_GetInputType( GetText() ); // uses current view 1602cdf0e10cSrcweir sal_uInt16 nStrId = 0; 1603cdf0e10cSrcweir switch ( eType ) 1604cdf0e10cSrcweir { 1605cdf0e10cSrcweir case SC_NAME_INPUT_CELL: 1606cdf0e10cSrcweir nStrId = STR_NAME_INPUT_CELL; 1607cdf0e10cSrcweir break; 1608cdf0e10cSrcweir case SC_NAME_INPUT_RANGE: 1609cdf0e10cSrcweir case SC_NAME_INPUT_NAMEDRANGE: 1610cdf0e10cSrcweir nStrId = STR_NAME_INPUT_RANGE; // named range or range reference 1611cdf0e10cSrcweir break; 1612cdf0e10cSrcweir case SC_NAME_INPUT_DATABASE: 1613cdf0e10cSrcweir nStrId = STR_NAME_INPUT_DBRANGE; 1614cdf0e10cSrcweir break; 1615cdf0e10cSrcweir case SC_NAME_INPUT_ROW: 1616cdf0e10cSrcweir nStrId = STR_NAME_INPUT_ROW; 1617cdf0e10cSrcweir break; 1618cdf0e10cSrcweir case SC_NAME_INPUT_SHEET: 1619cdf0e10cSrcweir nStrId = STR_NAME_INPUT_SHEET; 1620cdf0e10cSrcweir break; 1621cdf0e10cSrcweir case SC_NAME_INPUT_DEFINE: 1622cdf0e10cSrcweir nStrId = STR_NAME_INPUT_DEFINE; 1623cdf0e10cSrcweir break; 1624cdf0e10cSrcweir default: 1625cdf0e10cSrcweir // other cases (error): no tip help 1626cdf0e10cSrcweir break; 1627cdf0e10cSrcweir } 1628cdf0e10cSrcweir 1629cdf0e10cSrcweir if ( nStrId ) 1630cdf0e10cSrcweir { 1631cdf0e10cSrcweir // show the help tip at the text cursor position 1632cdf0e10cSrcweir 1633cdf0e10cSrcweir Window* pWin = GetSubEdit(); 1634cdf0e10cSrcweir if (!pWin) 1635cdf0e10cSrcweir pWin = this; 1636cdf0e10cSrcweir Point aPos; 1637cdf0e10cSrcweir Cursor* pCur = pWin->GetCursor(); 1638cdf0e10cSrcweir if (pCur) 1639cdf0e10cSrcweir aPos = pWin->LogicToPixel( pCur->GetPos() ); 1640cdf0e10cSrcweir aPos = pWin->OutputToScreenPixel( aPos ); 1641cdf0e10cSrcweir Rectangle aRect( aPos, aPos ); 1642cdf0e10cSrcweir 1643cdf0e10cSrcweir String aText = ScGlobal::GetRscString( nStrId ); 1644cdf0e10cSrcweir sal_uInt16 nAlign = QUICKHELP_LEFT|QUICKHELP_BOTTOM; 1645cdf0e10cSrcweir nTipVisible = Help::ShowTip(pWin, aRect, aText, nAlign); 1646cdf0e10cSrcweir } 1647cdf0e10cSrcweir } 1648cdf0e10cSrcweir } 1649cdf0e10cSrcweir 1650cdf0e10cSrcweir void __EXPORT ScPosWnd::Select() 1651cdf0e10cSrcweir { 1652cdf0e10cSrcweir ComboBox::Select(); // in VCL gibt GetText() erst danach den ausgewaehlten Eintrag 1653cdf0e10cSrcweir 1654cdf0e10cSrcweir HideTip(); 1655cdf0e10cSrcweir 1656cdf0e10cSrcweir if (!IsTravelSelect()) 1657cdf0e10cSrcweir DoEnter(); 1658cdf0e10cSrcweir } 1659cdf0e10cSrcweir 1660cdf0e10cSrcweir void ScPosWnd::DoEnter() 1661cdf0e10cSrcweir { 1662cdf0e10cSrcweir String aText = GetText(); 1663cdf0e10cSrcweir if ( aText.Len() ) 1664cdf0e10cSrcweir { 1665cdf0e10cSrcweir if ( bFormulaMode ) 1666cdf0e10cSrcweir { 1667cdf0e10cSrcweir ScModule* pScMod = SC_MOD(); 1668cdf0e10cSrcweir if ( aText == ScGlobal::GetRscString(STR_FUNCTIONLIST_MORE) ) 1669cdf0e10cSrcweir { 1670cdf0e10cSrcweir // Funktions-Autopilot 1671cdf0e10cSrcweir //! mit dem bisher eingegebenen Text weiterarbeiten !!! 1672cdf0e10cSrcweir 1673cdf0e10cSrcweir //! new method at ScModule to query if function autopilot is open 1674cdf0e10cSrcweir SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 1675cdf0e10cSrcweir if ( pViewFrm && !pViewFrm->GetChildWindow( SID_OPENDLG_FUNCTION ) ) 1676cdf0e10cSrcweir pViewFrm->GetDispatcher()->Execute( SID_OPENDLG_FUNCTION, 1677cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD ); 1678cdf0e10cSrcweir } 1679cdf0e10cSrcweir else 1680cdf0e10cSrcweir { 1681cdf0e10cSrcweir ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, SfxViewShell::Current() ); 1682cdf0e10cSrcweir ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh ); 1683cdf0e10cSrcweir if (pHdl) 1684cdf0e10cSrcweir pHdl->InsertFunction( aText ); 1685cdf0e10cSrcweir } 1686cdf0e10cSrcweir } 1687cdf0e10cSrcweir else 1688cdf0e10cSrcweir { 1689cdf0e10cSrcweir // depending on the input, select something or create a new named range 1690cdf0e10cSrcweir 1691cdf0e10cSrcweir ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell(); 1692cdf0e10cSrcweir if ( pViewSh ) 1693cdf0e10cSrcweir { 1694cdf0e10cSrcweir ScNameInputType eType = lcl_GetInputType( aText ); 1695cdf0e10cSrcweir if ( eType == SC_NAME_INPUT_BAD_NAME || eType == SC_NAME_INPUT_BAD_SELECTION ) 1696cdf0e10cSrcweir { 1697cdf0e10cSrcweir sal_uInt16 nId = ( eType == SC_NAME_INPUT_BAD_NAME ) ? STR_NAME_ERROR_NAME : STR_NAME_ERROR_SELECTION; 1698cdf0e10cSrcweir pViewSh->ErrorMessage( nId ); 1699cdf0e10cSrcweir } 1700cdf0e10cSrcweir else if ( eType == SC_NAME_INPUT_DEFINE ) 1701cdf0e10cSrcweir { 1702cdf0e10cSrcweir ScViewData* pViewData = pViewSh->GetViewData(); 1703cdf0e10cSrcweir ScDocShell* pDocShell = pViewData->GetDocShell(); 1704cdf0e10cSrcweir ScDocument* pDoc = pDocShell->GetDocument(); 1705cdf0e10cSrcweir ScRangeName* pNames = pDoc->GetRangeName(); 1706cdf0e10cSrcweir ScRange aSelection; 1707cdf0e10cSrcweir sal_uInt16 nIndex = 0; 1708cdf0e10cSrcweir if ( pNames && !pNames->SearchName( aText, nIndex ) && 1709cdf0e10cSrcweir (pViewData->GetSimpleArea( aSelection ) == SC_MARK_SIMPLE) ) 1710cdf0e10cSrcweir { 1711cdf0e10cSrcweir ScRangeName aNewRanges( *pNames ); 1712cdf0e10cSrcweir ScAddress aCursor( pViewData->GetCurX(), pViewData->GetCurY(), pViewData->GetTabNo() ); 1713cdf0e10cSrcweir String aContent; 1714cdf0e10cSrcweir aSelection.Format( aContent, SCR_ABS_3D, pDoc, pDoc->GetAddressConvention() ); 1715cdf0e10cSrcweir ScRangeData* pNew = new ScRangeData( pDoc, aText, aContent, aCursor ); 1716cdf0e10cSrcweir if ( aNewRanges.Insert(pNew) ) 1717cdf0e10cSrcweir { 1718cdf0e10cSrcweir ScDocFunc aFunc(*pDocShell); 1719cdf0e10cSrcweir aFunc.ModifyRangeNames( aNewRanges, sal_False ); 1720cdf0e10cSrcweir pViewSh->UpdateInputHandler(sal_True); 1721cdf0e10cSrcweir } 1722cdf0e10cSrcweir else 1723cdf0e10cSrcweir delete pNew; // shouldn't happen 1724cdf0e10cSrcweir } 1725cdf0e10cSrcweir } 1726cdf0e10cSrcweir else 1727cdf0e10cSrcweir { 1728cdf0e10cSrcweir // for all selection types, excecute the SID_CURRENTCELL slot 1729cdf0e10cSrcweir 1730cdf0e10cSrcweir SfxStringItem aPosItem( SID_CURRENTCELL, aText ); 1731cdf0e10cSrcweir SfxBoolItem aUnmarkItem( FN_PARAM_1, sal_True ); // remove existing selection 1732cdf0e10cSrcweir 1733cdf0e10cSrcweir pViewSh->GetViewData()->GetDispatcher().Execute( SID_CURRENTCELL, 1734cdf0e10cSrcweir SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD, 1735cdf0e10cSrcweir &aPosItem, &aUnmarkItem, 0L ); 1736cdf0e10cSrcweir } 1737cdf0e10cSrcweir } 1738cdf0e10cSrcweir } 1739cdf0e10cSrcweir } 1740cdf0e10cSrcweir else 1741cdf0e10cSrcweir SetText( aPosStr ); 1742cdf0e10cSrcweir 1743cdf0e10cSrcweir ReleaseFocus_Impl(); 1744cdf0e10cSrcweir } 1745cdf0e10cSrcweir 1746cdf0e10cSrcweir long __EXPORT ScPosWnd::Notify( NotifyEvent& rNEvt ) 1747cdf0e10cSrcweir { 1748cdf0e10cSrcweir long nHandled = 0; 1749cdf0e10cSrcweir 1750cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_KEYINPUT ) 1751cdf0e10cSrcweir { 1752cdf0e10cSrcweir const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 1753cdf0e10cSrcweir 1754cdf0e10cSrcweir switch ( pKEvt->GetKeyCode().GetCode() ) 1755cdf0e10cSrcweir { 1756cdf0e10cSrcweir case KEY_RETURN: 1757cdf0e10cSrcweir DoEnter(); 1758cdf0e10cSrcweir nHandled = 1; 1759cdf0e10cSrcweir break; 1760cdf0e10cSrcweir 1761cdf0e10cSrcweir case KEY_ESCAPE: 1762cdf0e10cSrcweir if (nTipVisible) 1763cdf0e10cSrcweir { 1764cdf0e10cSrcweir // escape when the tip help is shown: only hide the tip 1765cdf0e10cSrcweir HideTip(); 1766cdf0e10cSrcweir } 1767cdf0e10cSrcweir else 1768cdf0e10cSrcweir { 1769cdf0e10cSrcweir if (!bFormulaMode) 1770cdf0e10cSrcweir SetText( aPosStr ); 1771cdf0e10cSrcweir ReleaseFocus_Impl(); 1772cdf0e10cSrcweir } 1773cdf0e10cSrcweir nHandled = 1; 1774cdf0e10cSrcweir break; 1775cdf0e10cSrcweir } 1776cdf0e10cSrcweir } 1777cdf0e10cSrcweir 1778cdf0e10cSrcweir if ( !nHandled ) 1779cdf0e10cSrcweir nHandled = ComboBox::Notify( rNEvt ); 1780cdf0e10cSrcweir 1781cdf0e10cSrcweir if ( rNEvt.GetType() == EVENT_LOSEFOCUS ) 1782cdf0e10cSrcweir HideTip(); 1783cdf0e10cSrcweir 1784cdf0e10cSrcweir return nHandled; 1785cdf0e10cSrcweir } 1786cdf0e10cSrcweir 1787cdf0e10cSrcweir void ScPosWnd::ReleaseFocus_Impl() 1788cdf0e10cSrcweir { 1789cdf0e10cSrcweir HideTip(); 1790cdf0e10cSrcweir 1791cdf0e10cSrcweir SfxViewShell* pCurSh = SfxViewShell::Current(); 1792cdf0e10cSrcweir ScInputHandler* pHdl = SC_MOD()->GetInputHdl( PTR_CAST( ScTabViewShell, pCurSh ) ); 1793cdf0e10cSrcweir if ( pHdl && pHdl->IsTopMode() ) 1794cdf0e10cSrcweir { 1795cdf0e10cSrcweir // Focus wieder in die Eingabezeile? 1796cdf0e10cSrcweir 1797cdf0e10cSrcweir ScInputWindow* pInputWin = pHdl->GetInputWindow(); 1798cdf0e10cSrcweir if (pInputWin) 1799cdf0e10cSrcweir { 1800cdf0e10cSrcweir pInputWin->TextGrabFocus(); 1801cdf0e10cSrcweir return; 1802cdf0e10cSrcweir } 1803cdf0e10cSrcweir } 1804cdf0e10cSrcweir 1805cdf0e10cSrcweir // Focus auf die aktive View 1806cdf0e10cSrcweir 1807cdf0e10cSrcweir if ( pCurSh ) 1808cdf0e10cSrcweir { 1809cdf0e10cSrcweir Window* pShellWnd = pCurSh->GetWindow(); 1810cdf0e10cSrcweir 1811cdf0e10cSrcweir if ( pShellWnd ) 1812cdf0e10cSrcweir pShellWnd->GrabFocus(); 1813cdf0e10cSrcweir } 1814cdf0e10cSrcweir } 1815cdf0e10cSrcweir 1816cdf0e10cSrcweir 1817cdf0e10cSrcweir 1818cdf0e10cSrcweir 1819cdf0e10cSrcweir 1820cdf0e10cSrcweir 1821