1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 28 29 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 30 #include <svl/eitem.hxx> 31 #include <svx/htmlmode.hxx> 32 #include <sfx2/dispatch.hxx> 33 #include <sfx2/bindings.hxx> 34 #ifndef _SFX_IMAGEMGR_HXX 35 #include <sfx2/imagemgr.hxx> 36 #endif 37 #include <swmodule.hxx> 38 #ifndef _VIEW_HXX 39 #include <view.hxx> 40 #endif 41 #include <initui.hxx> 42 #include <viewopt.hxx> 43 #ifndef _DOCSH_HXX 44 #include <docsh.hxx> 45 #endif 46 #include <gloshdl.hxx> 47 #include <glosdoc.hxx> 48 #include <gloslst.hxx> 49 #include <workctrl.hxx> 50 #ifndef _WORKCTRL_HRC 51 #include <workctrl.hrc> 52 #endif 53 #ifndef _CMDID_H 54 #include <cmdid.h> 55 #endif 56 #ifndef _HELPID_H 57 #include <helpid.h> 58 #endif 59 #include <wrtsh.hxx> 60 #include <svl/imageitm.hxx> 61 #include <vcl/lstbox.hxx> 62 #include <rtl/ustring.hxx> 63 #include "swabstdlg.hxx" 64 #include <misc.hrc> 65 66 #include <vcl/svapp.hxx> 67 68 //JP 14.01.99: Size Abpruefung 69 #define NAVI_ENTRIES 20 70 #if NAVI_ENTRIES != NID_COUNT 71 #error SwScrollNaviPopup-CTOR static Array falsche Size. Wurden neue IDs zugefuegt ?? 72 #endif 73 74 using ::rtl::OUString; 75 using namespace ::com::sun::star; 76 using namespace ::com::sun::star::uno; 77 using namespace ::com::sun::star::beans; 78 using namespace ::com::sun::star::frame; 79 80 SFX_IMPL_TOOLBOX_CONTROL( SwTbxInsertCtrl, SfxImageItem); 81 SFX_IMPL_TOOLBOX_CONTROL( SwTbxAutoTextCtrl, SfxBoolItem ); 82 83 /********************************************************************** 84 85 **********************************************************************/ 86 SwTbxInsertCtrl::SwTbxInsertCtrl( 87 sal_uInt16 nSlotId, 88 sal_uInt16 nId, 89 ToolBox& rTbx ) : 90 SfxToolBoxControl( nSlotId, nId, rTbx ), 91 nLastSlotId(FN_INSERT_CTRL == nSlotId ? FN_INSERT_TABLE : SID_INSERT_DIAGRAM) 92 { 93 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 94 } 95 /********************************************************************** 96 97 **********************************************************************/ 98 SwTbxInsertCtrl::~SwTbxInsertCtrl() 99 { 100 } 101 102 void SAL_CALL SwTbxInsertCtrl::update() throw (uno::RuntimeException) 103 { 104 ToolBox& rTbx = GetToolBox(); 105 rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 106 aSlotURL += rtl::OUString::valueOf( sal_Int32( nLastSlotId )); 107 Image aImage = GetImage( m_xFrame, 108 aSlotURL, 109 hasBigImages(), 110 rTbx.GetSettings().GetStyleSettings().GetHighContrastMode() ); 111 112 rTbx.SetItemImage(GetId(), aImage); 113 rTbx.Invalidate(); 114 115 SfxToolBoxControl::update(); 116 } 117 118 /********************************************************************** 119 120 **********************************************************************/ 121 122 123 void SwTbxInsertCtrl::StateChanged( sal_uInt16 /*nSID*/, 124 SfxItemState eState, 125 const SfxPoolItem* pState ) 126 { 127 sal_uInt16 nId = GetId(); 128 GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) ); 129 130 if( eState == SFX_ITEM_AVAILABLE ) 131 { 132 const SfxImageItem* pItem = PTR_CAST( SfxImageItem, pState ); 133 if(pItem) 134 { 135 nLastSlotId = pItem->GetValue(); 136 if( nLastSlotId ) 137 nId = nLastSlotId; 138 139 rtl::OUString aSlotURL( RTL_CONSTASCII_USTRINGPARAM( "slot:" )); 140 aSlotURL += rtl::OUString::valueOf( sal_Int32( nId )); 141 ToolBox& rBox = GetToolBox(); 142 Image aImage = GetImage( m_xFrame, 143 aSlotURL, 144 hasBigImages(), 145 rBox.GetSettings().GetStyleSettings().GetHighContrastMode() ); 146 rBox.SetItemImage(GetId(), aImage); 147 rBox.SetItemImageMirrorMode( GetId(), sal_False ); 148 rBox.SetItemImageAngle( GetId(), pItem->GetRotation() ); 149 rBox.SetItemImageMirrorMode( GetId(), pItem->IsMirrored() ); 150 } 151 } 152 153 } 154 /********************************************************************** 155 156 **********************************************************************/ 157 158 159 SfxPopupWindow* SwTbxInsertCtrl::CreatePopupWindow() 160 { 161 if(GetSlotId() == FN_INSERT_CTRL) 162 { 163 OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertbar" )); 164 createAndPositionSubToolBar( aToolBarResStr ); 165 } 166 else /* FN_INSERT_OBJ_CTRL */ 167 { 168 OUString aToolBarResStr( RTL_CONSTASCII_USTRINGPARAM( "private:resource/toolbar/insertobjectbar" )); 169 createAndPositionSubToolBar( aToolBarResStr ); 170 } 171 return NULL; 172 } 173 174 /********************************************************************** 175 176 **********************************************************************/ 177 178 179 SfxPopupWindowType SwTbxInsertCtrl::GetPopupWindowType() const 180 { 181 return nLastSlotId ? SFX_POPUPWINDOW_ONTIMEOUT : SFX_POPUPWINDOW_ONCLICK; 182 } 183 184 185 /********************************************************************** 186 187 **********************************************************************/ 188 189 190 void SwTbxInsertCtrl::Select( sal_Bool /*bMod1*/ ) 191 { 192 if( nLastSlotId ) 193 { 194 SfxViewShell* pCurSh( SfxViewShell::Current() ); 195 SfxDispatcher* pDispatch( 0 ); 196 197 if ( pCurSh ) 198 { 199 SfxViewFrame* pViewFrame = pCurSh->GetViewFrame(); 200 if ( pViewFrame ) 201 pDispatch = pViewFrame->GetDispatcher(); 202 } 203 204 if ( pDispatch ) 205 pDispatch->Execute(nLastSlotId); 206 } 207 } 208 209 /********************************************************************** 210 211 **********************************************************************/ 212 213 214 SwTbxAutoTextCtrl::SwTbxAutoTextCtrl( 215 sal_uInt16 nSlotId, 216 sal_uInt16 nId, 217 ToolBox& rTbx ) : 218 SfxToolBoxControl( nSlotId, nId, rTbx ), 219 pPopup(0), 220 pView(0) 221 { 222 rTbx.SetItemBits( nId, TIB_DROPDOWN | rTbx.GetItemBits( nId ) ); 223 } 224 /********************************************************************** 225 226 **********************************************************************/ 227 228 229 SwTbxAutoTextCtrl::~SwTbxAutoTextCtrl() 230 { 231 DelPopup(); 232 } 233 234 /********************************************************************** 235 236 **********************************************************************/ 237 238 239 SfxPopupWindow* SwTbxAutoTextCtrl::CreatePopupWindow() 240 { 241 pView = ::GetActiveView(); 242 if(pView && !pView->GetDocShell()->IsReadOnly() && 243 !pView->GetWrtShell().HasReadonlySel() ) 244 { 245 ToolBox& rBox = GetToolBox(); 246 247 Rectangle aItemRect( rBox.GetItemRect( GetId() ) ); 248 Point aPt(rBox.OutputToScreenPixel(aItemRect.TopLeft())); 249 aPt.X() += aItemRect.GetWidth()/2; 250 aPt.Y() += aItemRect.GetHeight()/2; 251 if(pView) 252 { 253 Link aLnk = LINK(this, SwTbxAutoTextCtrl, PopupHdl); 254 255 if (GetSlotId() == FN_INSERT_FIELD_CTRL) 256 { 257 pPopup = new PopupMenu(SW_RES(RID_INSERT_FIELD_CTRL)); 258 pPopup->SetSelectHdl(aLnk); 259 260 if (::GetHtmlMode(pView->GetDocShell()) & HTMLMODE_ON) 261 { 262 pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_PGCOUNT)); 263 pPopup->RemoveItem(pPopup->GetItemPos(FN_INSERT_FLD_TOPIC)); 264 } 265 } 266 else 267 { 268 pPopup = new PopupMenu; 269 SwGlossaryList* pGlossaryList = ::GetGlossaryList(); 270 sal_uInt16 nGroupCount = pGlossaryList->GetGroupCount(); 271 for(sal_uInt16 i = 1; i <= nGroupCount; i++) 272 { 273 // Gruppenname mit Pfad-Extension besorgen 274 String sTitle; 275 String sGroupName = pGlossaryList->GetGroupName(i - 1, sal_False, &sTitle); 276 sal_uInt16 nBlockCount = pGlossaryList->GetBlockCount(i -1); 277 if(nBlockCount) 278 { 279 sal_uInt16 nIndex = 100 * (i); 280 // aber ohne extension einfuegen 281 pPopup->InsertItem( i, sTitle);//sGroupName.GetToken(0, GLOS_DELIM)); 282 PopupMenu* pSub = new PopupMenu; 283 pSub->SetSelectHdl(aLnk); 284 pPopup->SetPopupMenu(i, pSub); 285 for(sal_uInt16 j = 0; j < nBlockCount; j++) 286 { 287 String sEntry; 288 String sLongName(pGlossaryList->GetBlockName(i - 1, j, sEntry)); 289 sEntry.AppendAscii(" - "); 290 sEntry += sLongName; 291 pSub->InsertItem(++nIndex, sEntry); 292 } 293 } 294 } 295 } 296 } 297 ToolBox* pToolBox = &GetToolBox(); 298 sal_uInt16 nId = GetId(); 299 pToolBox->SetItemDown( nId, sal_True ); 300 301 pPopup->Execute( pToolBox, pToolBox->GetItemRect( nId ), 302 (pToolBox->GetAlign() == WINDOWALIGN_TOP || pToolBox->GetAlign() == WINDOWALIGN_BOTTOM) ? 303 POPUPMENU_EXECUTE_DOWN : POPUPMENU_EXECUTE_RIGHT ); 304 305 pToolBox->SetItemDown( nId, sal_False ); 306 } 307 GetToolBox().EndSelection(); 308 DelPopup(); 309 return 0; 310 311 } 312 313 314 /********************************************************************** 315 316 **********************************************************************/ 317 318 319 SfxPopupWindowType SwTbxAutoTextCtrl::GetPopupWindowType() const 320 { 321 return SFX_POPUPWINDOW_ONTIMEOUT; 322 } 323 324 /********************************************************************** 325 326 **********************************************************************/ 327 328 329 void SwTbxAutoTextCtrl::StateChanged( sal_uInt16 nSID, 330 SfxItemState eState, 331 const SfxPoolItem* pState ) 332 { 333 GetToolBox().EnableItem( GetId(), (GetItemState(pState) != SFX_ITEM_DISABLED) ); 334 if(FN_INSERT_FIELD_CTRL == nSID && eState >= SFX_ITEM_DEFAULT) 335 { 336 GetToolBox().CheckItem( GetId(), ((SfxBoolItem*)pState)->GetValue() ); 337 } 338 } 339 340 /********************************************************************** 341 342 **********************************************************************/ 343 344 345 IMPL_LINK(SwTbxAutoTextCtrl, PopupHdl, PopupMenu*, pMenu) 346 { 347 sal_uInt16 nId = pMenu->GetCurItemId(); 348 349 if ( GetSlotId() == FN_INSERT_FIELD_CTRL) 350 { 351 Sequence< PropertyValue > aArgs; 352 const char* pChar = 0; 353 switch(nId) 354 { 355 case FN_INSERT_FLD_DATE: 356 pChar = ".uno:InsertDateField"; 357 break; 358 case FN_INSERT_FLD_TIME: 359 pChar = ".uno:InsertTimeField"; 360 break; 361 case FN_INSERT_FLD_PGNUMBER: 362 pChar = ".uno:InsertPageNumberField"; 363 break; 364 case FN_INSERT_FLD_PGCOUNT: 365 pChar = ".uno:InsertPageCountField"; 366 break; 367 case FN_INSERT_FLD_TOPIC: 368 pChar = ".uno:InsertTopicField"; 369 break; 370 case FN_INSERT_FLD_TITLE: 371 pChar = ".uno:InsertTitleField"; 372 break; 373 case FN_INSERT_FLD_AUTHOR: 374 pChar = ".uno:InsertAuthorField"; 375 break; 376 default: 377 pChar = ".uno:InsertFieldCtrl"; 378 } 379 Dispatch( rtl::OUString::createFromAscii( pChar ),aArgs ); 380 } 381 else 382 { 383 sal_uInt16 nBlock = nId / 100; 384 385 SwGlossaryList* pGlossaryList = ::GetGlossaryList(); 386 String sShortName; 387 String sGroup = pGlossaryList->GetGroupName(nBlock - 1, sal_False); 388 String sLongName(pGlossaryList->GetBlockName(nBlock - 1, nId - (100 * nBlock) - 1, sShortName)); 389 390 SwGlossaryHdl* pGlosHdl = pView->GetGlosHdl(); 391 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 392 DBG_ASSERT(pFact, "Dialogdiet fail!"); 393 ::GlossarySetActGroup fnSetActGroup = pFact->SetGlossaryActGroupFunc( DLG_RENAME_GLOS ); 394 if ( fnSetActGroup ) 395 (*fnSetActGroup)( sGroup ); 396 pGlosHdl->SetCurGroup(sGroup, sal_True); 397 pGlosHdl->InsertGlossary(sShortName); 398 } 399 return 0; 400 } 401 402 /********************************************************************** 403 404 **********************************************************************/ 405 406 407 void SwTbxAutoTextCtrl::DelPopup() 408 { 409 if(pPopup) 410 { 411 if (GetSlotId() != FN_INSERT_FIELD_CTRL) 412 { 413 for( sal_uInt16 i = 0; i < pPopup->GetItemCount(); i ++ ) 414 { 415 PopupMenu* pSubPopup = pPopup->GetPopupMenu(pPopup->GetItemId(i)); 416 delete pSubPopup; 417 } 418 } 419 delete pPopup; 420 pPopup = 0; 421 } 422 } 423 424 /*-----------------19.02.97 10.52------------------- 425 Navigations-Popup 426 --------------------------------------------------*/ 427 // determine the order of the toolbox items 428 static sal_uInt16 __READONLY_DATA aNavigationInsertIds[ NAVI_ENTRIES ] = 429 { 430 // -- first line 431 NID_TBL, 432 NID_FRM, 433 NID_GRF, 434 NID_OLE, 435 NID_PGE, 436 NID_OUTL, 437 NID_MARK, 438 NID_DRW, 439 NID_CTRL, 440 NID_PREV, 441 // -- second line 442 NID_REG, 443 NID_BKM, 444 NID_SEL, 445 NID_FTN, 446 NID_POSTIT, 447 NID_SRCH_REP, 448 NID_INDEX_ENTRY, 449 NID_TABLE_FORMULA, 450 NID_TABLE_FORMULA_ERROR, 451 NID_NEXT 452 }; 453 static const char* __READONLY_DATA aNavigationHelpIds[ NAVI_ENTRIES ] = 454 { 455 // -- first line 456 HID_NID_TBL, 457 HID_NID_FRM, 458 HID_NID_GRF, 459 HID_NID_OLE, 460 HID_NID_PGE, 461 HID_NID_OUTL, 462 HID_NID_MARK, 463 HID_NID_DRW, 464 HID_NID_CTRL, 465 HID_NID_PREV, 466 // -- second line 467 HID_NID_REG, 468 HID_NID_BKM, 469 HID_NID_SEL, 470 HID_NID_FTN, 471 HID_NID_POSTIT, 472 HID_NID_SRCH_REP, 473 HID_NID_INDEX_ENTRY, 474 HID_NID_TABLE_FORMULA, 475 HID_NID_TABLE_FORMULA_ERROR, 476 HID_NID_NEXT 477 }; 478 479 SwScrollNaviPopup::SwScrollNaviPopup( sal_uInt16 nId, const Reference< XFrame >& rFrame ) 480 : SfxPopupWindow(nId, rFrame, SW_RES(RID_SCROLL_NAVIGATION_WIN) ), 481 aToolBox(this, 0), 482 aSeparator(this, SW_RES(FL_SEP)), 483 aInfoField(this, SW_RES(FI_INFO)), 484 aIList(SW_RES(IL_VALUES)), 485 aIListH(SW_RES(ILH_VALUES)), 486 nFwdId(FN_START_OF_NEXT_PAGE), 487 nBackId(FN_START_OF_PREV_PAGE) 488 { 489 sal_uInt16 i; 490 491 aToolBox.SetHelpId(HID_NAVI_VS); 492 aToolBox.SetLineCount( 2 ); 493 aToolBox.SetOutStyle(TOOLBOX_STYLE_FLAT); 494 for( i = 0; i < NID_COUNT; i++) 495 { 496 sal_uInt16 nNaviId = aNavigationInsertIds[i]; 497 String sText; 498 ToolBoxItemBits nTbxBits = 0; 499 if((NID_PREV != nNaviId) && (NID_NEXT != nNaviId)) 500 { 501 // -2, there's no string for Next/Prev 502 sal_uInt16 nResStr = ST_TBL - 2 + nNaviId - NID_START; 503 sText = String(SW_RES(nResStr)); 504 nTbxBits = TIB_CHECKABLE; 505 } 506 //IAccessibility2 Impplementaton 2009----- 507 else 508 { 509 if (nNaviId == NID_PREV) 510 sText = String(SW_RES(STR_IMGBTN_PGE_UP)); 511 else if (nNaviId == NID_NEXT) 512 sText = String(SW_RES(STR_IMGBTN_PGE_DOWN)); 513 } 514 //-----IAccessibility2 Impplementaton 2009 515 aToolBox.InsertItem(nNaviId, sText, nTbxBits); 516 aToolBox.SetHelpId( nNaviId, aNavigationHelpIds[i] ); 517 } 518 ApplyImageList(); 519 aToolBox.InsertBreak(NID_COUNT/2); 520 // don't call it before! 521 FreeResource(); 522 523 // these are global strings 524 for( i = 0; i < 2 * NID_COUNT; i++) 525 { 526 sQuickHelp[i] = String(SW_RES(STR_IMGBTN_START + i)); 527 } 528 529 Size aImgSize = aIList.GetImageSize(); 530 aImgSize.Width() += 5; 531 aImgSize.Height() += 5; 532 Size aSz = aToolBox.CalcWindowSizePixel(2); 533 aToolBox.SetPosSizePixel( Point(), aSz ); 534 sal_uInt16 nItemId = SwView::GetMoveType(); 535 aInfoField.SetText(aToolBox.GetItemText(nItemId)); 536 aToolBox.CheckItem( nItemId, sal_True ); 537 Size aFTSize(aInfoField.GetSizePixel()); 538 Size aSepSize(aSeparator.GetSizePixel()); 539 aSepSize.Width() = aSz.Width(); 540 541 aSz.Height() += aFTSize.Height() + aSepSize.Height(); 542 aInfoField.SetPosSizePixel( 543 Point(0, aSz.Height() - aFTSize.Height()), Size(aSz.Width(), aFTSize.Height())); 544 545 aSeparator.SetSizePixel(aSepSize); 546 aSeparator.SetPosPixel(Point(0, aSz.Height() - aFTSize.Height() - aSepSize.Height())); 547 548 SetOutputSizePixel(aSz); 549 aToolBox.SetSelectHdl(LINK(this, SwScrollNaviPopup, SelectHdl)); 550 aToolBox.StartSelection(); 551 aToolBox.Show(); 552 } 553 /*-----------------19.02.97 12.45------------------- 554 555 --------------------------------------------------*/ 556 557 SwScrollNaviPopup::~SwScrollNaviPopup() 558 { 559 } 560 /* -----------------------------08.05.2002 14:00------------------------------ 561 562 ---------------------------------------------------------------------------*/ 563 void SwScrollNaviPopup::DataChanged( const DataChangedEvent& rDCEvt ) 564 { 565 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 566 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 567 ApplyImageList(); 568 569 Window::DataChanged( rDCEvt ); 570 } 571 /* -----------------------------08.05.2002 14:02------------------------------ 572 573 ---------------------------------------------------------------------------*/ 574 void SwScrollNaviPopup::ApplyImageList() 575 { 576 ImageList& rImgLst = aToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ? 577 aIListH : aIList; 578 for(sal_uInt16 i = 0; i < NID_COUNT; i++) 579 { 580 sal_uInt16 nNaviId = aNavigationInsertIds[i]; 581 aToolBox.SetItemImage(nNaviId, rImgLst.GetImage(nNaviId)); 582 } 583 } 584 /*-----------------19.02.97 13.58------------------- 585 586 --------------------------------------------------*/ 587 588 SfxPopupWindow* SwScrollNaviPopup::Clone() const 589 { 590 return new SwScrollNaviPopup( GetId(), GetFrame() ); 591 } 592 593 /*-----------------19.02.97 14.10------------------- 594 595 --------------------------------------------------*/ 596 597 IMPL_LINK(SwScrollNaviPopup, SelectHdl, ToolBox*, pSet) 598 { 599 sal_uInt16 nSet = pSet->GetCurItemId(); 600 if( nSet != NID_PREV && nSet != NID_NEXT ) 601 { 602 SwView::SetMoveType(nSet); 603 aToolBox.SetItemText(NID_NEXT, sQuickHelp[nSet - NID_START]); 604 aToolBox.SetItemText(NID_PREV, sQuickHelp[nSet - NID_START + NID_COUNT]); 605 aInfoField.SetText(aToolBox.GetItemText(nSet)); 606 //check the current button only 607 for(sal_uInt16 i = 0; i < NID_COUNT; i++) 608 { 609 sal_uInt16 nItemId = aToolBox.GetItemId( i ); 610 aToolBox.CheckItem( nItemId, nItemId == nSet ); 611 } 612 } 613 else 614 { 615 SfxBoolItem aNext(FN_SCROLL_NEXT_PREV, NID_NEXT == nSet); 616 Any a; 617 Sequence< PropertyValue > aArgs( 1 ); 618 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScrollNextPrev" )); 619 aNext.QueryValue( a ); 620 aArgs[0].Value = a; 621 SfxToolBoxControl::Dispatch( Reference< XDispatchProvider >( GetFrame()->getController(), UNO_QUERY ), 622 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ScrollNextPrev" )), 623 aArgs ); 624 } 625 return 0; 626 } 627 /*-----------------23.02.97 18.21------------------- 628 629 --------------------------------------------------*/ 630 631 void SwScrollNaviToolBox::MouseButtonUp( const MouseEvent& rMEvt ) 632 { 633 ToolBox::MouseButtonUp(rMEvt); 634 if ( ((SwScrollNaviPopup*)GetParent())->IsInPopupMode() ) 635 ((SwScrollNaviPopup*)GetParent())->EndPopupMode( FLOATWIN_POPUPMODEEND_CLOSEALL ); 636 } 637 638 /*-----------------20.06.97 13:28------------------- 639 640 --------------------------------------------------*/ 641 void SwScrollNaviToolBox::RequestHelp( const HelpEvent& rHEvt ) 642 { 643 SetItemText(NID_NEXT, SwScrollNaviPopup::GetQuickHelpText(sal_True)); 644 SetItemText(NID_PREV, SwScrollNaviPopup::GetQuickHelpText(sal_False)); 645 ToolBox::RequestHelp( rHEvt ); 646 647 } 648 649 /*-----------------20.06.97 13:41------------------- 650 651 --------------------------------------------------*/ 652 String SwScrollNaviPopup::GetQuickHelpText(sal_Bool bNext) 653 { 654 sal_uInt16 nResId = STR_IMGBTN_START; 655 nResId += SwView::GetMoveType() - NID_START; 656 if(!bNext) 657 nResId += NID_COUNT; 658 return String(SW_RES(nResId)); 659 } 660 /* -----------------------------05.09.2002 13:53------------------------------ 661 662 ---------------------------------------------------------------------------*/ 663 void SwNaviImageButton::Click() 664 { 665 // SfxBindings& rBind = SfxViewFrame::Current()->GetBindings(); 666 // rBind.ENTERREGISTRATIONS(); 667 pPopup = new 668 SwScrollNaviPopup( FN_SCROLL_NAVIGATION, 669 m_xFrame ); 670 // rBind.LEAVEREGISTRATIONS(); 671 Point aPos = OutputToScreenPixel(Point(0,0)); 672 Rectangle aRect(aPos, GetSizePixel()); 673 SetPopupWindow( pPopup ); 674 pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_LEFT|FLOATWIN_POPUPMODE_ALLOWTEAROFF); 675 } 676 677 //-------------------------------------------------------------------- 678 679 void SwNaviImageButton::SetPopupWindow( SfxPopupWindow* pWindow ) 680 { 681 pPopupWindow = pWindow; 682 pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNaviImageButton, PopupModeEndHdl )); 683 pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNaviImageButton, ClosePopupWindow )); 684 } 685 686 //-------------------------------------------------------------------- 687 688 IMPL_LINK( SwNaviImageButton, PopupModeEndHdl, void *, EMPTYARG ) 689 { 690 if ( pPopupWindow->IsVisible() ) 691 { 692 // Replace floating window with popup window and destroy 693 // floating window instance. 694 delete pFloatingWindow; 695 pFloatingWindow = pPopupWindow; 696 pPopupWindow = 0; 697 } 698 else 699 { 700 // Popup window has been closed by the user. No replacement, instance 701 // will destroy itself. 702 pPopupWindow = 0; 703 } 704 705 return 1; 706 } 707 708 //-------------------------------------------------------------------- 709 IMPL_LINK( SwNaviImageButton, ClosePopupWindow, SfxPopupWindow *, pWindow ) 710 { 711 if ( pWindow == pFloatingWindow ) 712 pFloatingWindow = 0; 713 else 714 pPopupWindow = 0; 715 716 return 1; 717 } 718 719 /*-----------------21.02.97 09:41------------------- 720 721 --------------------------------------------------*/ 722 723 void SwHlpImageButton::RequestHelp( const HelpEvent& rHEvt ) 724 { 725 726 SetQuickHelpText(SwScrollNaviPopup::GetQuickHelpText(!bUp)); 727 728 ImageButton::RequestHelp(rHEvt); 729 } 730 731 /*-----------------25.02.97 12:38------------------- 732 733 --------------------------------------------------*/ 734 735 SwNaviImageButton::SwNaviImageButton( 736 Window* pParent, 737 const Reference< XFrame >& rFrame ) : 738 ImageButton(pParent, SW_RES(BTN_NAVI)), 739 pPopup(0), 740 aImage(SW_RES(IMG_BTN)), 741 aImageH(SW_RES(IMG_BTN_H)), 742 sQuickText(SW_RES(ST_QUICK)), 743 pPopupWindow(0), 744 pFloatingWindow(0), 745 m_xFrame( rFrame ) 746 { 747 FreeResource(); 748 SetStyle(GetStyle()|WB_NOPOINTERFOCUS); 749 SetQuickHelpText(sQuickText); 750 SetModeImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImageH : aImage); 751 } 752 /* -----------------------------2002/07/05 9:41------------------------------- 753 754 ---------------------------------------------------------------------------*/ 755 void SwNaviImageButton::DataChanged( const DataChangedEvent& rDCEvt ) 756 { 757 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 758 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 759 SetModeImage( GetSettings().GetStyleSettings().GetHighContrastMode() ? aImageH : aImage); 760 761 Window::DataChanged( rDCEvt ); 762 } 763 /* -----------------26.11.2002 09:28----------------- 764 * 765 * --------------------------------------------------*/ 766 class SwZoomBox_Impl : public ComboBox 767 { 768 sal_uInt16 nSlotId; 769 sal_Bool bRelease; 770 uno::Reference< frame::XDispatchProvider > m_xDispatchProvider; 771 772 public: 773 SwZoomBox_Impl( 774 Window* pParent, 775 sal_uInt16 nSlot, 776 const Reference< XDispatchProvider >& rDispatchProvider ); 777 ~SwZoomBox_Impl(); 778 779 protected: 780 virtual void Select(); 781 virtual long Notify( NotifyEvent& rNEvt ); 782 783 void ReleaseFocus(); 784 785 }; 786 /* -----------------26.11.2002 09:29----------------- 787 * 788 * --------------------------------------------------*/ 789 SwZoomBox_Impl::SwZoomBox_Impl( 790 Window* pParent, 791 sal_uInt16 nSlot, 792 const Reference< XDispatchProvider >& rDispatchProvider ): 793 ComboBox( pParent, SW_RES(RID_PVIEW_ZOOM_LB)), 794 nSlotId(nSlot), 795 bRelease(sal_True), 796 m_xDispatchProvider( rDispatchProvider ) 797 { 798 EnableAutocomplete( sal_False ); 799 sal_uInt16 aZoomValues[] = 800 { 25, 50, 75, 100, 150, 200 }; 801 for(sal_uInt16 i = 0; i < sizeof(aZoomValues)/sizeof(sal_uInt16); i++) 802 { 803 String sEntry = String::CreateFromInt32(aZoomValues[i]); 804 sEntry += '%'; 805 InsertEntry(sEntry); 806 } 807 } 808 /* -----------------26.11.2002 09:29----------------- 809 * 810 * --------------------------------------------------*/ 811 SwZoomBox_Impl::~SwZoomBox_Impl() 812 {} 813 /* -----------------26.11.2002 09:34----------------- 814 * 815 * --------------------------------------------------*/ 816 void SwZoomBox_Impl::Select() 817 { 818 if ( !IsTravelSelect() ) 819 { 820 String sEntry(GetText()); 821 sEntry.EraseAllChars( '%' ); 822 sal_uInt16 nZoom = (sal_uInt16)sEntry.ToInt32(); 823 if(nZoom < MINZOOM) 824 nZoom = MINZOOM; 825 if(nZoom > MAXZOOM) 826 nZoom = MAXZOOM; 827 828 SfxUInt16Item aItem( nSlotId, nZoom ); 829 if ( FN_PREVIEW_ZOOM == nSlotId ) 830 { 831 Any a; 832 Sequence< PropertyValue > aArgs( 1 ); 833 aArgs[0].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PreviewZoom" )); 834 aItem.QueryValue( a ); 835 aArgs[0].Value = a; 836 SfxToolBoxControl::Dispatch( 837 m_xDispatchProvider, 838 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:PreviewZoom" )), 839 aArgs ); 840 } 841 842 ReleaseFocus(); 843 } 844 } 845 /* -----------------02.12.2002 07:49----------------- 846 * 847 * --------------------------------------------------*/ 848 long SwZoomBox_Impl::Notify( NotifyEvent& rNEvt ) 849 { 850 long nHandled = 0; 851 852 if ( rNEvt.GetType() == EVENT_KEYINPUT ) 853 { 854 sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); 855 856 switch ( nCode ) 857 { 858 case KEY_RETURN: 859 case KEY_TAB: 860 { 861 if ( KEY_TAB == nCode ) 862 bRelease = sal_False; 863 else 864 nHandled = 1; 865 Select(); 866 break; 867 } 868 869 case KEY_ESCAPE: 870 SetText( GetSavedValue() ); 871 ReleaseFocus(); 872 break; 873 } 874 } 875 else if ( EVENT_LOSEFOCUS == rNEvt.GetType() ) 876 { 877 Window* pFocusWin = Application::GetFocusWindow(); 878 if ( !HasFocus() && GetSubEdit() != pFocusWin ) 879 SetText( GetSavedValue() ); 880 } 881 882 return nHandled ? nHandled : ComboBox::Notify( rNEvt ); 883 } 884 /* -----------------02.12.2002 07:51----------------- 885 * 886 * --------------------------------------------------*/ 887 void SwZoomBox_Impl::ReleaseFocus() 888 { 889 if ( !bRelease ) 890 { 891 bRelease = sal_True; 892 return; 893 } 894 SfxViewShell* pCurSh = SfxViewShell::Current(); 895 896 if ( pCurSh ) 897 { 898 Window* pShellWnd = pCurSh->GetWindow(); 899 900 if ( pShellWnd ) 901 pShellWnd->GrabFocus(); 902 } 903 } 904 905 /* -----------------26.11.2002 09:29----------------- 906 * 907 * --------------------------------------------------*/ 908 SFX_IMPL_TOOLBOX_CONTROL( SwPreviewZoomControl, SfxUInt16Item); 909 910 SwPreviewZoomControl::SwPreviewZoomControl( 911 sal_uInt16 nSlotId, 912 sal_uInt16 nId, 913 ToolBox& rTbx) : 914 SfxToolBoxControl( nSlotId, nId, rTbx ) 915 { 916 } 917 /* -----------------26.11.2002 09:29----------------- 918 * 919 * --------------------------------------------------*/ 920 SwPreviewZoomControl::~SwPreviewZoomControl() 921 { 922 } 923 /* -----------------26.11.2002 09:29----------------- 924 * 925 * --------------------------------------------------*/ 926 void SwPreviewZoomControl::StateChanged( sal_uInt16 /*nSID*/, 927 SfxItemState eState, 928 const SfxPoolItem* pState ) 929 { 930 sal_uInt16 nId = GetId(); 931 GetToolBox().EnableItem( nId, (GetItemState(pState) != SFX_ITEM_DISABLED) ); 932 SwZoomBox_Impl* pBox = (SwZoomBox_Impl*)GetToolBox().GetItemWindow( GetId() ); 933 if(SFX_ITEM_AVAILABLE <= eState) 934 { 935 String sZoom(String::CreateFromInt32(((const SfxUInt16Item*)pState)->GetValue())); 936 sZoom += '%'; 937 pBox->SetText(sZoom); 938 pBox->SaveValue(); 939 } 940 } 941 /* -----------------26.11.2002 09:29----------------- 942 * 943 * --------------------------------------------------*/ 944 Window* SwPreviewZoomControl::CreateItemWindow( Window *pParent ) 945 { 946 SwZoomBox_Impl* pRet = new SwZoomBox_Impl( pParent, GetSlotId(), Reference< XDispatchProvider >( m_xFrame->getController(), UNO_QUERY )); 947 return pRet; 948 } 949