1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 32 33 // INCLUDE --------------------------------------------------------------- 34 35 #include <editeng/editview.hxx> 36 #include <sfx2/bindings.hxx> 37 #include <sfx2/dispatch.hxx> 38 #include <sfx2/objsh.hxx> 39 #include <sfx2/viewsh.hxx> 40 41 #include "sc.hrc" 42 #include "global.hxx" // ScAddress 43 #include "scresid.hxx" 44 #include "reffact.hxx" 45 #include "document.hxx" 46 #include "cell.hxx" 47 #include "scmod.hxx" 48 #include "inputhdl.hxx" 49 #include "tabvwsh.hxx" 50 #include "appoptio.hxx" 51 #include "compiler.hxx" 52 53 #include "dwfunctr.hrc" 54 #include "dwfunctr.hxx" 55 56 // ----------------------------------------------------------------------- 57 58 #define ARG_SEPERATOR String("; ") 59 SFX_IMPL_DOCKINGWINDOW( ScFunctionChildWindow, FID_FUNCTION_BOX ) 60 61 /************************************************************************* 62 #* Member: ScFunctionChildWindow Datum:06.10.97 63 #*------------------------------------------------------------------------ 64 #* 65 #* Klasse: ScFunctionChildWindow 66 #* 67 #* Funktion: Konstruktor der Klasse ScFunctionChildWindow 68 #* Ableitung vom SfxChildWindow als "Behaelter" fuer 69 #* Funktions- Fenster in Clac 70 #* 71 #* Input: --- 72 #* 73 #* Output: --- 74 #* 75 #************************************************************************/ 76 77 __EXPORT ScFunctionChildWindow::ScFunctionChildWindow( Window* pParentP, 78 sal_uInt16 nId, 79 SfxBindings* pBindings, 80 SfxChildWinInfo* pInfo ) : 81 SfxChildWindow( pParentP, nId ) 82 { 83 ScFunctionDockWin* pWin = new ScFunctionDockWin( pBindings, this, 84 pParentP, ScResId( FID_FUNCTION_BOX ) ); 85 pWindow = pWin; 86 87 eChildAlignment = SFX_ALIGN_RIGHT; 88 89 pWin->Initialize( pInfo ); 90 } 91 92 /************************************************************************* 93 #* Member: ScFunctionDockWin Datum:06.10.97 94 #*------------------------------------------------------------------------ 95 #* 96 #* Klasse: ScFunctionDockWin 97 #* 98 #* Funktion: Konstruktor der Klasse ScFunctionDockWin 99 #* 100 #* Input: Sfx- Verknuepfungen, Fenster, Resource 101 #* 102 #* Output: --- 103 #* 104 #************************************************************************/ 105 106 ScFunctionDockWin::ScFunctionDockWin( SfxBindings* pBindingsP, 107 SfxChildWindow *pCW, Window* pParent, const ResId& rResId ) : 108 109 SfxDockingWindow( pBindingsP, pCW, pParent, rResId ), 110 aPrivatSplit ( this, ResId( FT_SPLIT, *rResId.GetResMgr() ),SC_SPLIT_VERT), 111 aCatBox ( this, ResId( CB_CAT, *rResId.GetResMgr() ) ), 112 aFuncList ( this, ResId( LB_FUNC, *rResId.GetResMgr() ) ), 113 aDDFuncList ( this, ResId( DDLB_FUNC, *rResId.GetResMgr() ) ), 114 aInsertButton ( this, ResId( IMB_INSERT, *rResId.GetResMgr() ) ), 115 aFiFuncDesc ( this, ResId( FI_FUNCDESC, *rResId.GetResMgr() ) ), 116 aOldSize (0,0) 117 { 118 FreeResource(); 119 InitLRUList(); 120 SetStyle(GetStyle()|WB_CLIPCHILDREN); 121 122 aTimer.SetTimeout(200); 123 aTimer.SetTimeoutHdl(LINK( this, ScFunctionDockWin, TimerHdl)); 124 125 eSfxNewAlignment=GetAlignment(); 126 eSfxOldAlignment=eSfxNewAlignment; 127 aFiFuncDesc.SetUpdateMode(sal_True); 128 pAllFuncList=&aFuncList; 129 aDDFuncList.Disable(); 130 aDDFuncList.Hide(); 131 nArgs=0; 132 nDockMode=0; 133 bSizeFlag=sal_False; 134 aCatBox.SetDropDownLineCount(9); 135 Font aFont=aFiFuncDesc.GetFont(); 136 aFont.SetColor(Color(COL_BLACK)); 137 aFiFuncDesc.SetFont(aFont); 138 aFiFuncDesc.SetBackground( GetBackground() ); //! never transparent? 139 //? SetBackground(); 140 141 Link aLink=LINK( this, ScFunctionDockWin, SelHdl); 142 aCatBox.SetSelectHdl(aLink); 143 aFuncList.SetSelectHdl(aLink); 144 aDDFuncList.SetSelectHdl(aLink); 145 146 Link a2Link=LINK( this, ScFunctionDockWin, SetSelectionHdl); 147 aFuncList.SetDoubleClickHdl(a2Link); 148 aDDFuncList.SetSelectHdl(aLink); 149 aInsertButton.SetClickHdl(a2Link); 150 151 Link a3Link=LINK( this, ScFunctionDockWin, SetSplitHdl); 152 aPrivatSplit.SetCtrModifiedHdl(a3Link); 153 StartListening( *pBindingsP, sal_True ); 154 155 Point aTopLeft=aCatBox.GetPosPixel(); 156 //String aString=aCatBox.GetEntry( 0)+String("www"); 157 String aString=String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww")); 158 Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() ); 159 nMinWidth=aTxtSize.Width()+aTopLeft.X() 160 +2*aFuncList.GetPosPixel().X(); 161 nMinHeight=19*aTxtSize.Height(); 162 aCatBox.SelectEntryPos(0); 163 164 Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(), 165 GetOutputSizePixel().Height()-2*aTxtSize.Height()); 166 aPrivatSplit.SetYRange(aYRange); 167 SelHdl(&aCatBox); 168 bInit=sal_True; 169 } 170 171 /************************************************************************* 172 #* Member: ScFunctionDockWin Datum:06.10.97 173 #*------------------------------------------------------------------------ 174 #* 175 #* Klasse: ScFunctionDockWin 176 #* 177 #* Funktion: Destruktor der Klasse ScFunctionDockWin 178 #* 179 #* Input: --- 180 #* 181 #* Output: --- 182 #* 183 #************************************************************************/ 184 185 __EXPORT ScFunctionDockWin::~ScFunctionDockWin() 186 { 187 EndListening( GetBindings() ); 188 } 189 190 /************************************************************************* 191 #* Member: UpdateFunctionList Datum:06.10.97 192 #*------------------------------------------------------------------------ 193 #* 194 #* Klasse: ScFunctionDockWin 195 #* 196 #* Funktion: Aktualisiert die Liste der Funktionen ab- 197 #* haengig von der eingestellten Kategorie. 198 #* 199 #* Input: --- 200 #* 201 #* Output: --- 202 #* 203 #************************************************************************/ 204 205 void ScFunctionDockWin::InitLRUList() 206 { 207 const ScAppOptions& rAppOpt = SC_MOD()->GetAppOptions(); 208 sal_uInt16 nLRUFuncCount = Min( rAppOpt.GetLRUFuncListCount(), (sal_uInt16)LRU_MAX ); 209 sal_uInt16* pLRUListIds = rAppOpt.GetLRUFuncList(); 210 211 sal_uInt16 i; 212 for ( i=0; i<LRU_MAX; i++ ) 213 aLRUList[i] = NULL; 214 215 if ( pLRUListIds ) 216 { 217 ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); 218 for ( i=0; i<nLRUFuncCount; i++ ) 219 aLRUList[i] = pFuncMgr->Get( pLRUListIds[i] ); 220 } 221 222 sal_uInt16 nSelPos = aCatBox.GetSelectEntryPos(); 223 224 if(nSelPos == 0) 225 UpdateFunctionList(); 226 } 227 228 /************************************************************************* 229 #* Member: UpdateFunctionList Datum:10.12.99 230 #*------------------------------------------------------------------------ 231 #* 232 #* Klasse: ScFunctionDockWin 233 #* 234 #* Funktion: Aktualisiert die Liste der zuletzt verwendeten Funktionen. 235 #* 236 #* Input: --- 237 #* 238 #* Output: --- 239 #* 240 #************************************************************************/ 241 242 void ScFunctionDockWin::UpdateLRUList() 243 { 244 if (pFuncDesc && pFuncDesc->nFIndex!=0) 245 { 246 ScModule* pScMod = SC_MOD(); 247 pScMod->InsertEntryToLRUList(pFuncDesc->nFIndex); 248 } 249 } 250 251 252 /************************************************************************* 253 #* Member: SetSize Datum:06.10.97 254 #*------------------------------------------------------------------------ 255 #* 256 #* Klasse: ScFunctionDockWin 257 #* 258 #* Funktion: Groesse fuer die einzelnen Controls einzustellen. 259 #* 260 #* Input: --- 261 #* 262 #* Output: --- 263 #* 264 #************************************************************************/ 265 266 void ScFunctionDockWin::SetSize() 267 { 268 sal_uInt16 nSelEntry=0; 269 SfxChildAlignment aChildAlign=eSfxOldAlignment;//GetAlignment(); 270 short nNewDockMode; 271 switch(aChildAlign) 272 { 273 case SFX_ALIGN_HIGHESTTOP: 274 case SFX_ALIGN_TOP: 275 case SFX_ALIGN_LOWESTTOP: 276 case SFX_ALIGN_LOWESTBOTTOM: 277 case SFX_ALIGN_BOTTOM: 278 case SFX_ALIGN_TOOLBOXTOP: 279 case SFX_ALIGN_TOOLBOXBOTTOM: 280 281 282 nNewDockMode=1; 283 if(nDockMode!=nNewDockMode) 284 { 285 nDockMode=nNewDockMode; 286 nSelEntry=aFuncList.GetSelectEntryPos(); 287 aFuncList.Clear(); 288 aFiFuncDesc.SetPosPixel(aFuncList.GetPosPixel()); 289 aDDFuncList.Enable(); 290 aDDFuncList.Show(); 291 aPrivatSplit.Disable(); 292 aPrivatSplit.Hide(); 293 aFuncList.Disable(); 294 aFuncList.Hide(); 295 pAllFuncList=&aDDFuncList; 296 SelHdl(&aCatBox); 297 aDDFuncList.SelectEntryPos(nSelEntry); 298 } 299 break; 300 301 default: nNewDockMode=0; 302 if(nDockMode!=nNewDockMode) 303 { 304 nDockMode=nNewDockMode; 305 nSelEntry=aDDFuncList.GetSelectEntryPos(); 306 aDDFuncList.Clear(); 307 aDDFuncList.Disable(); 308 aDDFuncList.Hide(); 309 aPrivatSplit.Enable(); 310 aPrivatSplit.Show(); 311 aFuncList.Enable(); 312 aFuncList.Show(); 313 pAllFuncList=&aFuncList; 314 SelHdl(&aCatBox); 315 aFuncList.SelectEntryPos(nSelEntry); 316 } 317 break; 318 } 319 320 if(nDockMode==0) 321 { 322 SetLeftRightSize(); 323 } 324 else 325 { 326 SetTopBottonSize(); 327 } 328 } 329 /************************************************************************* 330 #* Member: SetLeftRightSize Datum:15.10.97 331 #*------------------------------------------------------------------------ 332 #* 333 #* Klasse: ScFunctionDockWin 334 #* 335 #* Funktion: Groesse fuer die einzelnen Controls einstellen, 336 #* wenn Links oder Rechts angedockt wird. 337 #* 338 #* Input: --- 339 #* 340 #* Output: --- 341 #* 342 #************************************************************************/ 343 344 void ScFunctionDockWin::SetLeftRightSize() 345 { 346 if(bSizeFlag==sal_False) 347 { 348 bSizeFlag=sal_True; 349 350 Size aDiffSize=GetSizePixel(); 351 Size aNewSize=GetOutputSizePixel(); 352 aDiffSize.Width()-=aNewSize.Width(); 353 aDiffSize.Height()-=aNewSize.Height(); 354 355 //@ SetUpdateMode( sal_False); 356 357 String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww")); 358 359 Size aTxtSize( aFuncList.GetTextWidth(aString), aFuncList.GetTextHeight() ); 360 361 Range aYRange(3*aTxtSize.Height()+aFuncList.GetPosPixel().Y(), 362 GetOutputSizePixel().Height()-2*aTxtSize.Height()); 363 aPrivatSplit.SetYRange(aYRange); 364 365 366 if(aOldSize.Width()!=aNewSize.Width()) 367 SetMyWidthLeRi(aNewSize); 368 369 if(aOldSize.Height()!=aNewSize.Height()) 370 SetMyHeightLeRi(aNewSize); 371 372 aOldSize=aNewSize; 373 aNewSize.Width()+=aDiffSize.Width(); 374 aNewSize.Height()+=aDiffSize.Height(); 375 //SetSizePixel(aNewSize); 376 //@ SetUpdateMode( sal_True); 377 bSizeFlag=sal_False; 378 } 379 380 } 381 /************************************************************************* 382 #* Member: SetTopBottonSize Datum:15.10.97 383 #*------------------------------------------------------------------------ 384 #* 385 #* Klasse: ScFunctionDockWin 386 #* 387 #* Funktion: Groesse fuer die einzelnen Controls einzustellen. 388 #* wenn oben oder unten angedockt wird. 389 #* 390 #* Input: --- 391 #* 392 #* Output: --- 393 #* 394 #************************************************************************/ 395 396 void ScFunctionDockWin::SetTopBottonSize() 397 { 398 if(bSizeFlag==sal_False) 399 { 400 bSizeFlag=sal_True; 401 Size aDiffSize=GetSizePixel(); 402 Size aNewSize=GetOutputSizePixel(); 403 aDiffSize.Width()-=aNewSize.Width(); 404 aDiffSize.Height()-=aNewSize.Height(); 405 406 SetMyWidthToBo(aNewSize); 407 SetMyHeightToBo(aNewSize); 408 409 aNewSize.Width()+=aDiffSize.Width(); 410 aNewSize.Height()+=aDiffSize.Height(); 411 //SetSizePixel(aNewSize); 412 //@ SetUpdateMode( sal_True); 413 bSizeFlag=sal_False; 414 } 415 } 416 417 /************************************************************************* 418 #* Member: SetMyWidthLeRi Datum:15.10.97 419 #*------------------------------------------------------------------------ 420 #* 421 #* Klasse: ScFunctionDockWin 422 #* 423 #* Funktion: Breite fuer die einzelnen Controls und 424 #* das Fenster einstellen,wenn Li oder Re 425 #* 426 #* Input: neue Fenstergroesse 427 #* 428 #* Output: --- 429 #* 430 #************************************************************************/ 431 432 void ScFunctionDockWin::SetMyWidthLeRi(Size &aNewSize) 433 { 434 if((sal_uLong)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth; 435 436 Size aCDSize=aCatBox.GetSizePixel(); 437 Size aFLSize=aFuncList.GetSizePixel(); 438 Size aSplitterSize=aPrivatSplit.GetSizePixel(); 439 Size aFDSize=aFiFuncDesc.GetSizePixel(); 440 441 Point aCDTopLeft=aCatBox.GetPosPixel(); 442 Point aFLTopLeft=aFuncList.GetPosPixel(); 443 Point aSplitterTopLeft=aPrivatSplit.GetPosPixel(); 444 Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); 445 446 aCDSize.Width()=aNewSize.Width()-aCDTopLeft.X()-aFLTopLeft.X(); 447 aFLSize.Width()=aNewSize.Width()-2*aFLTopLeft.X(); 448 aFDSize.Width()=aFLSize.Width(); 449 aSplitterSize.Width()=aFLSize.Width(); 450 451 aCatBox.SetSizePixel(aCDSize); 452 aFuncList.SetSizePixel(aFLSize); 453 aPrivatSplit.SetSizePixel(aSplitterSize); 454 aFiFuncDesc.SetSizePixel(aFDSize); 455 } 456 457 /************************************************************************* 458 #* Member: SetHeight Datum:06.10.97 459 #*------------------------------------------------------------------------ 460 #* 461 #* Klasse: ScFunctionDockWin 462 #* 463 #* Funktion: Hoehe fuer die einzelnen Controls und 464 #* das Fenster einstellen bei Li oder Re 465 #* 466 #* Input: neue Fenstergroesse 467 #* 468 #* Output: --- 469 #* 470 #************************************************************************/ 471 472 void ScFunctionDockWin::SetMyHeightLeRi(Size &aNewSize) 473 { 474 if((sal_uLong)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight; 475 476 Size aFLSize=aFuncList.GetSizePixel(); 477 Size aSplitterSize=aPrivatSplit.GetSizePixel(); 478 Size aFDSize=aFiFuncDesc.GetSizePixel(); 479 480 Point aFLTopLeft=aFuncList.GetPosPixel(); 481 Point aSplitterTopLeft=aPrivatSplit.GetPosPixel(); 482 Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); 483 484 long nTxtHeight = aFuncList.GetTextHeight(); 485 486 short nY=(short)(3*nTxtHeight+ 487 aFuncList.GetPosPixel().Y()+aSplitterSize.Height()); 488 489 aFDTopLeft.Y()=aNewSize.Height()-aFDSize.Height()-4; 490 if(nY>aFDTopLeft.Y()) 491 { 492 aFDSize.Height()-=nY-aFDTopLeft.Y(); 493 aFDTopLeft.Y()=nY; 494 } 495 aSplitterTopLeft.Y()=aFDTopLeft.Y()-aSplitterSize.Height()-1; 496 aFLSize.Height()=aSplitterTopLeft.Y()-aFLTopLeft.Y()-1; 497 498 aFuncList.SetSizePixel(aFLSize); 499 aPrivatSplit.SetPosPixel(aSplitterTopLeft); 500 aFiFuncDesc.SetPosPixel(aFDTopLeft); 501 aFiFuncDesc.SetSizePixel(aFDSize); 502 503 } 504 505 /************************************************************************* 506 #* Member: SetMyWidthToBo Datum:16.10.97 507 #*------------------------------------------------------------------------ 508 #* 509 #* Klasse: ScFunctionDockWin 510 #* 511 #* Funktion: Breite fuer die einzelnen Controls und 512 #* das Fenster einstellen, wenn oben oder 513 #* unten angedockt werden soll. 514 #* 515 #* Input: neue Fenstergroesse 516 #* 517 #* Output: --- 518 #* 519 #************************************************************************/ 520 521 void ScFunctionDockWin::SetMyWidthToBo(Size &aNewSize) 522 { 523 if((sal_uLong)aNewSize.Width()<nMinWidth) aNewSize.Width()=nMinWidth; 524 525 Size aCDSize=aCatBox.GetSizePixel(); 526 Size aDdFLSize=aDDFuncList.GetSizePixel(); 527 Size aFDSize=aFiFuncDesc.GetSizePixel(); 528 529 Point aCDTopLeft=aCatBox.GetPosPixel(); 530 Point aDdFLTopLeft=aDDFuncList.GetPosPixel(); 531 Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); 532 533 aCDSize.Width()=aDdFLTopLeft.X()-aFDTopLeft.X()-aCDTopLeft.X(); 534 aDdFLTopLeft.X()=aCDSize.Width()+aCDTopLeft.X()+aFDTopLeft.X(); 535 536 aDdFLSize.Width()=aNewSize.Width()-aDdFLTopLeft.X()-aFDTopLeft.X(); 537 538 aFDSize.Width()=aNewSize.Width()-2*aFDTopLeft.X(); 539 540 aDDFuncList.SetPosPixel(aDdFLTopLeft); 541 aDDFuncList.SetSizePixel(aDdFLSize); 542 aCatBox.SetSizePixel(aCDSize); 543 aFiFuncDesc.SetSizePixel(aFDSize); 544 } 545 546 /************************************************************************* 547 #* Member: SetHeight Datum:16.10.97 548 #*------------------------------------------------------------------------ 549 #* 550 #* Klasse: ScFunctionDockWin 551 #* 552 #* Funktion: Hoehe fuer die einzelnen Controls und 553 #* das Fenster einstellen, wenn oben oder 554 #* unten angedockt werden soll. 555 #* 556 #* Input: neue Fenstergroesse 557 #* 558 #* Output: --- 559 #* 560 #************************************************************************/ 561 562 void ScFunctionDockWin::SetMyHeightToBo(Size &aNewSize) 563 { 564 if((sal_uLong)aNewSize.Height()<nMinHeight) aNewSize.Height()=nMinHeight; 565 566 Size aFDSize=aFiFuncDesc.GetSizePixel(); 567 568 Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); 569 Point aCBTopLeft=aCatBox.GetPosPixel(); 570 aFDSize.Height()=aNewSize.Height()-aFDTopLeft.Y()-aCBTopLeft.Y(); 571 aFiFuncDesc.SetSizePixel(aFDSize); 572 573 } 574 575 /************************************************************************* 576 #* Member: SetDescription Datum:13.10.97 577 #*------------------------------------------------------------------------ 578 #* 579 #* Klasse: ScFunctionDockWin 580 #* 581 #* Funktion: Erklaerungstext fuer die Funktion einstellen. 582 #* 583 #* Input: --- 584 #* 585 #* Output: --- 586 #* 587 #************************************************************************/ 588 589 void ScFunctionDockWin::SetDescription() 590 { 591 aFiFuncDesc.SetText( EMPTY_STRING ); 592 const ScFuncDesc* pDesc = 593 (const ScFuncDesc*)pAllFuncList->GetEntryData( 594 pAllFuncList->GetSelectEntryPos() ); 595 if (pDesc) 596 { 597 pDesc->initArgumentInfo(); // full argument info is needed 598 599 String aString=pAllFuncList->GetSelectEntry(); 600 if(nDockMode==0) 601 { 602 aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ":\n\n" )); 603 } 604 else 605 { 606 aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( ": " )); 607 } 608 609 aString+=pDesc->GetParamList(); 610 611 if(nDockMode==0) 612 { 613 aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "\n\n" )); 614 } 615 else 616 { 617 aString += '\n'; 618 } 619 620 aString+=*(pDesc->pFuncDesc); 621 622 aFiFuncDesc.SetText(aString); 623 aFiFuncDesc.StateChanged(STATE_CHANGE_TEXT); 624 aFiFuncDesc.Invalidate(); 625 aFiFuncDesc.Update(); 626 627 } 628 } 629 630 /************************************************************************* 631 #* Member: Resizing Datum:06.10.97 632 #*------------------------------------------------------------------------ 633 #* 634 #* Klasse: ScFunctionDockWin 635 #* 636 #* Funktion: Ueberladene Funktion um die Groesse der 637 #* einzelnen Controls einzustellen. 638 #* 639 #* Input: neue Groesse 640 #* 641 #* Output: --- 642 #* 643 #************************************************************************/ 644 645 void __EXPORT ScFunctionDockWin::Resizing( Size& rNewSize ) 646 { 647 if((sal_uLong)rNewSize.Width()<nMinWidth) rNewSize.Width()=nMinWidth; 648 if((sal_uLong)rNewSize.Height()<nMinHeight) rNewSize.Height()=nMinHeight; 649 650 } 651 652 /************************************************************************* 653 #* Member: Close Datum:07.10.97 654 #*------------------------------------------------------------------------ 655 #* 656 #* Klasse: ScFunctionDockWin 657 #* 658 #* Funktion: Schliessen des Fensters 659 #* 660 #* Input: --- 661 #* 662 #* Output: TRUE 663 #* 664 #************************************************************************/ 665 666 sal_Bool __EXPORT ScFunctionDockWin::Close() 667 { 668 SfxBoolItem aItem( FID_FUNCTION_BOX, sal_False ); 669 670 GetBindings().GetDispatcher()->Execute( FID_FUNCTION_BOX, 671 SFX_CALLMODE_ASYNCHRON | SFX_CALLMODE_RECORD, 672 &aItem, 0L ); 673 674 SfxDockingWindow::Close(); 675 676 return( sal_True ); 677 } 678 679 680 /************************************************************************* 681 #* Member: CheckAlignment Datum:16.10.97 682 #*------------------------------------------------------------------------ 683 #* 684 #* Klasse: ScFunctionDockWin 685 #* 686 #* Funktion: Ueberprueft den Andockmodus und stellt die 687 #* Groessen dementsprechend ein. 688 #* 689 #* Input: Das neue Alignment 690 #* 691 #* Output: Das uebergebene Alignment 692 #* 693 #************************************************************************/ 694 SfxChildAlignment __EXPORT ScFunctionDockWin::CheckAlignment(SfxChildAlignment /* abla */, 695 SfxChildAlignment aChildAlign) 696 { 697 String aString = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ww")); 698 Size aTxtSize( aFiFuncDesc.GetTextWidth(aString), aFiFuncDesc.GetTextHeight() ); 699 if(!bInit) 700 { 701 eSfxOldAlignment=eSfxNewAlignment; 702 eSfxNewAlignment=aChildAlign; 703 } 704 else 705 { 706 bInit=sal_False; 707 eSfxOldAlignment=aChildAlign; 708 eSfxNewAlignment=aChildAlign; 709 } 710 711 switch(eSfxOldAlignment) 712 { 713 case SFX_ALIGN_HIGHESTTOP: 714 case SFX_ALIGN_TOP: 715 case SFX_ALIGN_LOWESTTOP: 716 case SFX_ALIGN_LOWESTBOTTOM: 717 case SFX_ALIGN_BOTTOM: 718 case SFX_ALIGN_TOOLBOXTOP: 719 case SFX_ALIGN_TOOLBOXBOTTOM: 720 721 nMinWidth= 0;/*aDDFuncList.GetPosPixel().X()+ 722 10*aTxtSize.Width()+ 723 aFuncList.GetPosPixel().X();*/ 724 nMinHeight=0; 725 726 break; 727 728 case SFX_ALIGN_NOALIGNMENT: 729 730 aString = aCatBox.GetEntry(0); 731 aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM("www")); 732 aTxtSize = Size( aFiFuncDesc.GetTextWidth(aString), 733 aFiFuncDesc.GetTextHeight() ); 734 735 default: Point aTopLeft=aCatBox.GetPosPixel(); 736 nMinWidth=aTxtSize.Width()+aTopLeft.X() 737 +2*aFuncList.GetPosPixel().X(); 738 nMinHeight=19*aTxtSize.Height(); 739 //aCatBox.SelectEntryPos(0); 740 741 break; 742 } 743 744 return aChildAlign; 745 } 746 /************************************************************************* 747 #* Member: Close Datum:07.10.97 748 #*------------------------------------------------------------------------ 749 #* 750 #* Klasse: ScFunctionDockWin 751 #* 752 #* Funktion: Aenderungen erkennen 753 #* 754 #* Input: --- 755 #* 756 #* Output: TRUE 757 #* 758 #************************************************************************/ 759 void ScFunctionDockWin::Notify( SfxBroadcaster&, const SfxHint& /* rHint */ ) 760 { 761 // const SfxPoolItemHint *pPoolItemHint = PTR_CAST(SfxPoolItemHint, &rHint); 762 /* 763 if ( pPoolItemHint 764 && ( pPoolItemHint->GetObject()->ISA( SvxColorTableItem ) ) ) 765 { 766 // Die Liste der Farben hat sich geaendert 767 pColorTable = ( (SvxColorTableItem*) pPoolItemHint->GetObject() )->GetColorTable(); 768 FillValueSet(); 769 } 770 */ 771 } 772 773 774 /************************************************************************* 775 #* Member: Resize Datum:06.10.97 776 #*------------------------------------------------------------------------ 777 #* 778 #* Klasse: ScFunctionDockWin 779 #* 780 #* Funktion: Ueberladene Funktion um die Groesse der 781 #* einzelnen Controls einzustellen. 782 #* 783 #* Input: neue Groesse 784 #* 785 #* Output: --- 786 #* 787 #************************************************************************/ 788 789 void __EXPORT ScFunctionDockWin::Resize() 790 { 791 if ( !IsFloatingMode() || 792 !GetFloatingWindow()->IsRollUp() ) 793 { 794 Size aQSize=GetOutputSizePixel(); 795 Resizing( aQSize); 796 SetSize(); 797 } 798 SfxDockingWindow::Resize(); 799 } 800 801 /************************************************************************* 802 #* Member: UpdateFunctionList Datum:06.10.97 803 #*------------------------------------------------------------------------ 804 #* 805 #* Klasse: ScFunctionDockWin 806 #* 807 #* Funktion: Aktualisiert die Liste der Funktionen ab- 808 #* haengig von der eingestellten Kategorie. 809 #* 810 #* Input: --- 811 #* 812 #* Output: --- 813 #* 814 #************************************************************************/ 815 816 void ScFunctionDockWin::UpdateFunctionList() 817 { 818 sal_uInt16 nSelPos = aCatBox.GetSelectEntryPos(); 819 sal_uInt16 nCategory = ( LISTBOX_ENTRY_NOTFOUND != nSelPos ) 820 ? (nSelPos-1) : 0; 821 822 pAllFuncList->Clear(); 823 pAllFuncList->SetUpdateMode( sal_False ); 824 825 if ( nSelPos > 0 ) 826 { 827 ScFunctionMgr* pFuncMgr = ScGlobal::GetStarCalcFunctionMgr(); 828 829 const ScFuncDesc* pDesc = pFuncMgr->First( nCategory ); 830 while ( pDesc ) 831 { 832 pAllFuncList->SetEntryData( 833 pAllFuncList->InsertEntry( *(pDesc->pFuncName) ), 834 (void*)pDesc ); 835 pDesc = pFuncMgr->Next(); 836 } 837 } 838 else // LRU-Liste 839 { 840 for ( sal_uInt16 i=0; i<LRU_MAX && aLRUList[i]; i++ ) 841 { 842 const ScFuncDesc* pDesc = aLRUList[i]; 843 pAllFuncList->SetEntryData( 844 pAllFuncList->InsertEntry( *(pDesc->pFuncName) ), 845 (void*)pDesc ); 846 } 847 } 848 849 850 //------------------------------------------------------ 851 pAllFuncList->SetUpdateMode( sal_True ); 852 853 if ( pAllFuncList->GetEntryCount() > 0 ) 854 { 855 pAllFuncList->Enable(); 856 pAllFuncList->SelectEntryPos( 0 ); 857 } 858 else 859 { 860 pAllFuncList->Disable(); 861 } 862 } 863 864 /************************************************************************* 865 #* Member: DoEnter Datum:06.10.97 866 #*------------------------------------------------------------------------ 867 #* 868 #* Klasse: ScFunctionDockWin 869 #* 870 #* Funktion: Eingabe ins Dokument uebernehmen. Wird aufgerufen 871 #* nach betaetigen der Uebernehmen- Schaltflaeche 872 #* oder einem Doppelklick in die Funktionsliste. 873 #* 874 #* Input: --- 875 #* 876 #* Output: --- 877 #* 878 #************************************************************************/ 879 880 void ScFunctionDockWin::DoEnter(sal_Bool /* bOk */) //@@ ??? 881 { 882 String aFirstArgStr; 883 String aParaStr; 884 String aArgStr; 885 String aString=pAllFuncList->GetSelectEntry(); 886 SfxViewShell* pCurSh = SfxViewShell::Current(); 887 nArgs=0; 888 889 if(aString.Len()>0) 890 { 891 892 ScModule* pScMod = SC_MOD(); 893 ScTabViewShell* pViewSh = PTR_CAST( ScTabViewShell, pCurSh); 894 ScInputHandler* pHdl = pScMod->GetInputHdl( pViewSh ); 895 if(!pScMod->IsEditMode()) 896 { 897 pScMod->SetInputMode(SC_INPUT_TABLE); 898 aString = '='; 899 aString += pAllFuncList->GetSelectEntry(); 900 if (pHdl) 901 pHdl->ClearText(); 902 } 903 const ScFuncDesc* pDesc = 904 (const ScFuncDesc*)pAllFuncList->GetEntryData( 905 pAllFuncList->GetSelectEntryPos() ); 906 if (pDesc) 907 { 908 pFuncDesc=pDesc; 909 UpdateLRUList(); 910 nArgs = pDesc->nArgCount; 911 if(nArgs>0) 912 { 913 // NOTE: Theoretically the first parameter could have the 914 // suppress flag as well, but practically it doesn't. 915 aFirstArgStr = *(pDesc->ppDefArgNames[0]); 916 aFirstArgStr.EraseLeadingAndTrailingChars(); 917 aFirstArgStr.SearchAndReplaceAll(' ', '_'); 918 aArgStr = aFirstArgStr; 919 if ( nArgs != VAR_ARGS ) 920 { // no VarArgs or Fix plus VarArgs, but not VarArgs only 921 String aArgSep = String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM( "; " )); 922 sal_uInt16 nFix = ( nArgs < VAR_ARGS ? nArgs : nArgs - VAR_ARGS + 1 ); 923 for ( sal_uInt16 nArg = 1; 924 nArg < nFix && !pDesc->pDefArgFlags[nArg].bOptional; nArg++ ) 925 { 926 if (!pDesc->pDefArgFlags[nArg].bSuppress) 927 { 928 aArgStr += aArgSep; 929 String sTmp(*(pDesc->ppDefArgNames[nArg])); 930 sTmp.EraseLeadingAndTrailingChars(); 931 sTmp.SearchAndReplaceAll(' ', '_'); 932 aArgStr += sTmp; 933 } 934 } 935 } 936 } 937 } 938 if (pHdl) 939 { 940 if(pHdl->GetEditString().Len()==0) 941 { 942 aString = '='; 943 aString += pAllFuncList->GetSelectEntry(); 944 } 945 EditView *pEdView=pHdl->GetActiveView(); 946 if(pEdView!=NULL) // @ Wegen Absturz bei Namen festlegen 947 { 948 if(nArgs>0) 949 { 950 pHdl->InsertFunction(aString); 951 pEdView->InsertText(aArgStr,sal_True); 952 ESelection aESel=pEdView->GetSelection(); 953 aESel.nEndPos=aESel.nStartPos+aFirstArgStr.Len(); 954 pEdView->SetSelection(aESel); 955 pHdl->DataChanged(); 956 } 957 else 958 { 959 aString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "()" )); 960 pEdView->InsertText(aString,sal_False); 961 pHdl->DataChanged(); 962 } 963 } 964 } 965 InitLRUList(); 966 } 967 if ( pCurSh ) 968 { 969 Window* pShellWnd = pCurSh->GetWindow(); 970 971 if ( pShellWnd ) 972 pShellWnd->GrabFocus(); 973 } 974 975 976 } 977 978 979 980 /************************************************************************* 981 #* Handle: SelHdl Datum:06.10.97 982 #*------------------------------------------------------------------------ 983 #* 984 #* Klasse: ScFunctionDockWin 985 #* 986 #* Funktion: Bei einer Aenderung der Kategorie wird die 987 #* die Liste der Funktionen aktualisiert. 988 #* 989 #* Input: --- 990 #* 991 #* Output: --- 992 #* 993 #************************************************************************/ 994 995 IMPL_LINK( ScFunctionDockWin, SelHdl, ListBox*, pLb ) 996 { 997 if ( pLb == &aCatBox) 998 { 999 UpdateFunctionList(); 1000 SetDescription(); 1001 } 1002 1003 if ( pLb == &aFuncList||pLb == &aDDFuncList) 1004 { 1005 SetDescription(); 1006 } 1007 1008 1009 //SetSize(); 1010 return 0; 1011 } 1012 1013 /************************************************************************* 1014 #* Handle: SelHdl Datum:06.10.97 1015 #*------------------------------------------------------------------------ 1016 #* 1017 #* Klasse: ScFunctionDockWin 1018 #* 1019 #* Funktion: Bei einer Aenderung der Kategorie wird die 1020 #* die Liste der Funktionen aktualisiert. 1021 #* 1022 #* Input: --- 1023 #* 1024 #* Output: --- 1025 #* 1026 #************************************************************************/ 1027 1028 IMPL_LINK( ScFunctionDockWin, SetSelectionHdl, void*, pCtrl ) 1029 { 1030 if ((ImageButton *)pCtrl == &aInsertButton || 1031 (ListBox *)pCtrl == &aFuncList) 1032 { 1033 DoEnter(sal_True); // Uebernimmt die Eingabe 1034 } 1035 //... 1036 1037 return 0; 1038 } 1039 1040 /************************************************************************* 1041 #* Handle: SetSplitHdl Datum:13.10.97 1042 #*------------------------------------------------------------------------ 1043 #* 1044 #* Klasse: ScFunctionDockWin 1045 #* 1046 #* Funktion: Bei einer Aenderung des Split- Controls werden die 1047 #* einzelnen Controls an die neue Groesse angepasst. 1048 #* 1049 #* Input: Zeiger auf Control 1050 #* 1051 #* Output: --- 1052 #* 1053 #************************************************************************/ 1054 1055 IMPL_LINK( ScFunctionDockWin, SetSplitHdl, ScPrivatSplit*, pCtrl ) 1056 { 1057 if (pCtrl == &aPrivatSplit) 1058 { 1059 short nDeltaY=aPrivatSplit.GetDeltaY(); 1060 Size aFLSize=aFuncList.GetSizePixel(); 1061 Size aFDSize=aFiFuncDesc.GetSizePixel(); 1062 Point aFDTopLeft=aFiFuncDesc.GetPosPixel(); 1063 1064 aFLSize.Height()+=nDeltaY; 1065 aFDSize.Height()-=nDeltaY; 1066 aFDTopLeft.Y()+=nDeltaY; 1067 aFuncList.SetSizePixel(aFLSize); 1068 aFiFuncDesc.SetPosPixel(aFDTopLeft); 1069 aFiFuncDesc.SetSizePixel(aFDSize); 1070 /* 1071 aFuncList.Invalidate(); 1072 aFuncList.Update(); 1073 aFiFuncDesc.Invalidate(); 1074 aFiFuncDesc.Update(); 1075 */ 1076 } 1077 //... 1078 1079 return 0; 1080 } 1081 1082 void ScFunctionDockWin::ToggleFloatingMode() 1083 { 1084 aSplitterInitPos = Point(); 1085 SfxDockingWindow::ToggleFloatingMode(); 1086 1087 eSfxNewAlignment=GetAlignment(); 1088 eSfxOldAlignment=eSfxNewAlignment; 1089 1090 aOldSize.Height()=0; 1091 aOldSize.Width()=0; 1092 aTimer.Start(); 1093 } 1094 1095 IMPL_LINK( ScFunctionDockWin, TimerHdl, Timer*, EMPTYARG ) 1096 { 1097 CheckAlignment(eSfxOldAlignment,eSfxNewAlignment); 1098 SetSize(); 1099 return 0; 1100 } 1101 1102 void ScFunctionDockWin::Initialize(SfxChildWinInfo *pInfo) 1103 { 1104 String aStr; 1105 if(pInfo!=NULL) 1106 { 1107 if ( pInfo->aExtraString.Len() ) 1108 { 1109 xub_StrLen nPos = pInfo->aExtraString.Search( 1110 String::CreateFromAscii(RTL_CONSTASCII_STRINGPARAM("ScFuncList:"))); 1111 1112 // Versuche, den Alignment-String "ALIGN:(...)" einzulesen; wenn 1113 // er nicht vorhanden ist, liegt eine "altere Version vor 1114 if ( nPos != STRING_NOTFOUND ) 1115 { 1116 xub_StrLen n1 = pInfo->aExtraString.Search('(', nPos); 1117 if ( n1 != STRING_NOTFOUND ) 1118 { 1119 xub_StrLen n2 = pInfo->aExtraString.Search(')', n1); 1120 if ( n2 != STRING_NOTFOUND ) 1121 { 1122 // Alignment-String herausschneiden 1123 aStr = pInfo->aExtraString.Copy(nPos, n2 - nPos + 1); 1124 pInfo->aExtraString.Erase(nPos, n2 - nPos + 1); 1125 aStr.Erase(0, n1-nPos+1); 1126 } 1127 } 1128 } 1129 } 1130 } 1131 SfxDockingWindow::Initialize(pInfo); 1132 1133 if ( aStr.Len()) 1134 { 1135 aSplitterInitPos=aPrivatSplit.GetPosPixel(); 1136 aSplitterInitPos.Y()=(sal_uInt16) aStr.ToInt32(); 1137 xub_StrLen n1 = aStr.Search(';'); 1138 aStr.Erase(0, n1+1); 1139 sal_uInt16 nSelPos=sal::static_int_cast<sal_uInt16>( aStr.ToInt32() ); 1140 aCatBox.SelectEntryPos(nSelPos); 1141 SelHdl(&aCatBox); 1142 1143 // if the window has already been shown (from SfxDockingWindow::Initialize if docked), 1144 // set the splitter position now, otherwise it is set in StateChanged with type INITSHOW 1145 1146 UseSplitterInitPos(); 1147 } 1148 } 1149 1150 //------------------------------------------------------------------------- 1151 1152 void ScFunctionDockWin::FillInfo(SfxChildWinInfo& rInfo) const 1153 { 1154 SfxDockingWindow::FillInfo(rInfo); 1155 Point aPoint=aPrivatSplit.GetPosPixel(); 1156 rInfo.aExtraString.AppendAscii(RTL_CONSTASCII_STRINGPARAM( "ScFuncList:(" )); 1157 rInfo.aExtraString += String::CreateFromInt32(aPoint.Y()); 1158 rInfo.aExtraString += ';'; 1159 rInfo.aExtraString += String::CreateFromInt32(aCatBox.GetSelectEntryPos()); 1160 rInfo.aExtraString += ')'; 1161 } 1162 1163 void ScFunctionDockWin::UseSplitterInitPos() 1164 { 1165 if ( IsVisible() && aPrivatSplit.IsEnabled() && aSplitterInitPos != Point() ) 1166 { 1167 aPrivatSplit.MoveSplitTo(aSplitterInitPos); 1168 aSplitterInitPos = Point(); // use only once 1169 } 1170 } 1171 1172 void ScFunctionDockWin::StateChanged( StateChangedType nStateChange ) 1173 { 1174 SfxDockingWindow::StateChanged( nStateChange ); 1175 1176 if (nStateChange == STATE_CHANGE_INITSHOW) 1177 { 1178 UseSplitterInitPos(); // set initial splitter position if necessary 1179 } 1180 } 1181 1182 1183