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_sw.hxx" 30 31 32 33 #define NAVIPI_CXX 34 35 #include <string> // HACK: prevent conflict between STLPORT and Workshop headers 36 #include <tools/list.hxx> 37 #include <svl/urlbmk.hxx> 38 #include <svl/stritem.hxx> 39 #include <svtools/filter.hxx> 40 #include <svl/urihelper.hxx> 41 #include <sot/formats.hxx> 42 #include <sot/filelist.hxx> 43 #include <sfx2/event.hxx> 44 #include <sfx2/imgmgr.hxx> 45 #include <sfx2/dispatch.hxx> 46 #include <sfx2/dockwin.hxx> 47 #include <vcl/toolbox.hxx> 48 #include <swtypes.hxx> // fuer Pathfinder 49 #include <errhdl.hxx> 50 #include <swmodule.hxx> 51 #ifndef _VIEW_HXX 52 #include <view.hxx> 53 #endif 54 #include <navicfg.hxx> 55 #include <wrtsh.hxx> 56 #ifndef _DOCSH_HXX 57 #include <docsh.hxx> 58 #endif 59 #include <actctrl.hxx> 60 #include <IMark.hxx> 61 #include <navipi.hxx> 62 #include <content.hxx> 63 #include <workctrl.hxx> 64 #include <section.hxx> 65 #include <edtwin.hxx> 66 #include <sfx2/app.hxx> 67 #ifndef _CMDID_H 68 #include <cmdid.h> 69 #endif 70 #ifndef _HELPID_H 71 #include <helpid.h> 72 #endif 73 #ifndef _RIBBAR_HRC 74 #include <ribbar.hrc> 75 #endif 76 #ifndef _NAVIPI_HRC 77 #include <navipi.hrc> 78 #endif 79 #ifndef _UTLUI_HRC 80 #include <utlui.hrc> 81 #endif 82 83 #include "access.hrc" 84 85 #include <unomid.h> 86 87 88 #define PAGE_CHANGE_TIMEOUT 1000 //Timeout fuer Seitenwechsel 89 90 #define JUMP_TYPE_TBL 0 91 #define JUMP_TYPE_FRM 1 92 #define JUMP_TYPE_GRF 2 93 #define JUMP_TYPE_REG 3 94 #define JUMP_TYPE_BKM 4 95 96 // Version fuer Konfiguration 97 98 #define NAVI_VERSION0 0 99 #define NAVI_VERSION1 1 100 #define NAVI_VERSION2 2 // bIsGlobalActive 101 102 #define NAVI_CONFIG_VERSION NAVI_VERSION2 103 104 using namespace ::com::sun::star::uno; 105 using namespace ::com::sun::star::frame; 106 107 SFX_IMPL_CHILDWINDOW_CONTEXT( SwNavigationChild, SID_NAVIGATOR, SwView ) 108 109 /*------------------------------------------------------------------------ 110 Bechreibung: Steuerzeichen aus dem Outline-Entry filtern 111 ------------------------------------------------------------------------*/ 112 113 void SwNavigationPI::CleanEntry( String& rEntry ) 114 { 115 sal_uInt16 i = rEntry.Len(); 116 if( i ) 117 for( sal_Unicode* pStr = rEntry.GetBufferAccess(); i; --i, ++pStr ) 118 if( *pStr == 10 || *pStr == 9 ) 119 *pStr = 0x20; 120 } 121 /*------------------------------------------------------------------------ 122 Beschreibung: Ausfuehrung der Drag-Operation 123 mit und ohne Childs 124 ------------------------------------------------------------------------*/ 125 126 void SwNavigationPI::MoveOutline(sal_uInt16 nSource, sal_uInt16 nTarget, 127 sal_Bool bWithChilds) 128 { 129 SwView *pView = GetCreateView(); 130 SwWrtShell &rSh = pView->GetWrtShell(); 131 if(nTarget < nSource || nTarget == USHRT_MAX) 132 nTarget ++; 133 if ( rSh.IsOutlineMovable( nSource )) 134 { 135 136 short nMove = nTarget-nSource; //( nDir<0 ) ? 1 : 0 ; 137 rSh.GotoOutline(nSource); 138 if (bWithChilds) 139 rSh.MakeOutlineSel(nSource, nSource, sal_True); 140 // Die selektierten Children zaehlen bei der Bewegung vorwaerts nicht mit 141 sal_uInt16 nLastOutlinePos = rSh.GetOutlinePos(MAXLEVEL); 142 if(bWithChilds && nMove > 1 && 143 nLastOutlinePos < nTarget) 144 { 145 if(!rSh.IsCrsrPtAtEnd()) 146 rSh.SwapPam(); 147 nMove -= nLastOutlinePos - nSource; 148 } 149 if(!bWithChilds || nMove < 1 || nLastOutlinePos < nTarget ) 150 rSh.MoveOutlinePara( nMove ); 151 rSh.ClearMark(); 152 rSh.GotoOutline( nSource + nMove); 153 FillBox(); 154 } 155 156 } 157 158 159 /*------------------------------------------------------------------------ 160 Beschreibung: Nach Goto einen Status Rahmenselektion aufheben 161 ------------------------------------------------------------------------*/ 162 163 164 void lcl_UnSelectFrm(SwWrtShell *pSh) 165 { 166 if (pSh->IsFrmSelected()) 167 { 168 pSh->UnSelectFrm(); 169 pSh->LeaveSelFrmMode(); 170 } 171 } 172 173 /*------------------------------------------------------------------------ 174 Beschreibung: Select der Documentanzeige 175 ------------------------------------------------------------------------*/ 176 177 178 IMPL_LINK( SwNavigationPI, DocListBoxSelectHdl, ListBox *, pBox ) 179 { 180 int nEntryIdx = pBox->GetSelectEntryPos(); 181 SwView *pView ; 182 pView = SwModule::GetFirstView(); 183 while (nEntryIdx-- && pView) 184 { 185 pView = SwModule::GetNextView(pView); 186 } 187 if(!pView) 188 { 189 nEntryIdx == 0 ? 190 aContentTree.ShowHiddenShell(): 191 aContentTree.ShowActualView(); 192 193 194 } 195 else 196 { 197 aContentTree.SetConstantShell(pView->GetWrtShellPtr()); 198 } 199 return 0; 200 } 201 202 /*------------------------------------------------------------------------ 203 Beschreibung: Fuellen der ListBox fuer Outline Sicht oder Dokumente 204 Der PI wird auf volle Groesse gesetzt 205 ------------------------------------------------------------------------*/ 206 207 208 void SwNavigationPI::FillBox() 209 { 210 if(pContentWrtShell) 211 { 212 aContentTree.SetHiddenShell( pContentWrtShell ); 213 aContentTree.Display( sal_False ); 214 } 215 else 216 { 217 SwView *pView = GetCreateView(); 218 if(!pView) 219 { 220 aContentTree.SetActiveShell(0); 221 } 222 else if( pView != pActContView) 223 { 224 SwWrtShell* pWrtShell = pView->GetWrtShellPtr(); 225 aContentTree.SetActiveShell(pWrtShell); 226 } 227 else 228 aContentTree.Display( sal_True ); 229 pActContView = pView; 230 } 231 } 232 233 234 void SwNavigationPI::UsePage(SwWrtShell *pSh) 235 { 236 if (!pSh) 237 { 238 SwView *pView = GetCreateView(); 239 pSh = pView ? &pView->GetWrtShell() : 0; 240 GetPageEdit().SetValue(1); 241 } 242 if (pSh) 243 { 244 const sal_uInt16 nPageCnt = pSh->GetPageCnt(); 245 sal_uInt16 nPhyPage, nVirPage; 246 pSh->GetPageNum(nPhyPage, nVirPage); 247 248 GetPageEdit().SetMax(nPageCnt); 249 GetPageEdit().SetLast(nPageCnt); 250 GetPageEdit().SetValue(nPhyPage); 251 } 252 } 253 254 /*------------------------------------------------------------------------ 255 Beschreibung: SelectHandler der Toolboxen 256 ------------------------------------------------------------------------*/ 257 258 259 IMPL_LINK( SwNavigationPI, ToolBoxSelectHdl, ToolBox *, pBox ) 260 { 261 const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); 262 SwView *pView = GetCreateView(); 263 if (!pView) 264 return 1; 265 SwWrtShell &rSh = pView->GetWrtShell(); 266 //MouseModifier fuer Outline-Move besorgen 267 268 //Standard: Unterebenen werden mitgenommen 269 // mit Ctrl Unterebenen nicht mitnehmen 270 sal_Bool bOutlineWithChilds = ( KEY_MOD1 != pBox->GetModifier()); 271 int nFuncId = 0; 272 sal_Bool bFocusToDoc = sal_False; 273 switch (nCurrItemId) 274 { 275 case FN_UP: 276 case FN_DOWN: 277 { 278 // #i75416# move the execution of the search to an asynchronously called static link 279 bool* pbNext = new bool( FN_DOWN == nCurrItemId ); 280 Application::PostUserEvent( STATIC_LINK(pView, SwView, MoveNavigationHdl), pbNext ); 281 } 282 break; 283 case FN_SHOW_ROOT: 284 { 285 aContentTree.ToggleToRoot(); 286 } 287 break; 288 case FN_SHOW_CONTENT_BOX: 289 case FN_SELECT_CONTENT: 290 if(pContextWin->GetFloatingWindow()) 291 { 292 if(_IsZoomedIn() ) 293 { 294 _ZoomOut(); 295 } 296 else 297 { 298 _ZoomIn(); 299 } 300 } 301 return sal_True; 302 //break; 303 // Funktionen, die eine direkte Aktion ausloesen 304 305 case FN_SELECT_FOOTER: 306 { 307 rSh.MoveCrsr(); 308 const sal_uInt16 eType = rSh.GetFrmType(0,sal_False); 309 if (eType & FRMTYPE_FOOTER) 310 { 311 if (rSh.EndPg()) 312 nFuncId = FN_END_OF_PAGE; 313 } 314 else if (rSh.GotoFooterTxt()) 315 nFuncId = FN_TO_FOOTER; 316 bFocusToDoc = sal_True; 317 } 318 break; 319 case FN_SELECT_HEADER: 320 { 321 rSh.MoveCrsr(); 322 const sal_uInt16 eType = rSh.GetFrmType(0,sal_False); 323 if (eType & FRMTYPE_HEADER) 324 { 325 if (rSh.SttPg()) 326 nFuncId = FN_START_OF_PAGE; 327 } 328 else if (rSh.GotoHeaderTxt()) 329 nFuncId = FN_TO_HEADER; 330 bFocusToDoc = sal_True; 331 } 332 break; 333 case FN_SELECT_FOOTNOTE: 334 { 335 rSh.MoveCrsr(); 336 const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_False); 337 // aus Fussnote zum Anker springen 338 if (eFrmType & FRMTYPE_FOOTNOTE) 339 { 340 if (rSh.GotoFtnAnchor()) 341 nFuncId = FN_FOOTNOTE_TO_ANCHOR; 342 } 343 // andernfalls zuerst zum Fussnotentext springen; geht 344 // dies nicht, zur naechten Fussnote; geht auch dies 345 // nicht, zur vorhergehenden Fussnote 346 else 347 { 348 if (rSh.GotoFtnTxt()) 349 nFuncId = FN_FOOTNOTE_TO_ANCHOR; 350 else if (rSh.GotoNextFtnAnchor()) 351 nFuncId = FN_NEXT_FOOTNOTE; 352 else if (rSh.GotoPrevFtnAnchor()) 353 nFuncId = FN_PREV_FOOTNOTE; 354 } 355 bFocusToDoc = sal_True; 356 } 357 break; 358 359 case FN_SELECT_SET_AUTO_BOOKMARK: 360 MakeMark(); 361 break; 362 case FN_ITEM_DOWN: 363 case FN_ITEM_UP: 364 case FN_ITEM_LEFT: 365 case FN_ITEM_RIGHT: 366 case FN_GLOBAL_EDIT: 367 { 368 if(IsGlobalMode()) 369 aGlobalTree.ExecCommand(nCurrItemId); 370 else 371 aContentTree.ExecCommand(nCurrItemId, bOutlineWithChilds); 372 } 373 break; 374 case FN_GLOBAL_SWITCH: 375 { 376 ToggleTree(); 377 pConfig->SetGlobalActive(IsGlobalMode()); 378 } 379 break; 380 case FN_GLOBAL_SAVE_CONTENT: 381 { 382 sal_Bool bSave = rSh.IsGlblDocSaveLinks(); 383 rSh.SetGlblDocSaveLinks( !bSave ); 384 pBox->CheckItem(FN_GLOBAL_SAVE_CONTENT, !bSave ); 385 } 386 break; 387 } 388 389 if (nFuncId) 390 { 391 lcl_UnSelectFrm(&rSh); 392 } 393 if(bFocusToDoc) 394 pView->GetEditWin().GrabFocus(); 395 return sal_True; 396 } 397 /*------------------------------------------------------------------------ 398 Beschreibung: ClickHandler der Toolboxen 399 ------------------------------------------------------------------------*/ 400 401 402 IMPL_LINK( SwNavigationPI, ToolBoxClickHdl, ToolBox *, pBox ) 403 { 404 const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); 405 switch (nCurrItemId) 406 { 407 case FN_GLOBAL_UPDATE: 408 case FN_GLOBAL_OPEN: 409 { 410 aGlobalTree.TbxMenuHdl(nCurrItemId, pBox); 411 } 412 break; 413 } 414 415 return sal_True; 416 } 417 418 /*-----------------13.07.04 ------------------- 419 ----------------------------------------------*/ 420 421 IMPL_LINK( SwNavigationPI, ToolBoxDropdownClickHdl, ToolBox*, pBox ) 422 { 423 const sal_uInt16 nCurrItemId = pBox->GetCurItemId(); 424 switch (nCurrItemId) 425 { 426 case FN_CREATE_NAVIGATION: 427 { 428 CreateNavigationTool(pBox->GetItemRect(FN_CREATE_NAVIGATION), sal_True); 429 } 430 break; 431 432 case FN_DROP_REGION: 433 { 434 static const char* aHIDs[] = 435 { 436 HID_NAVI_DRAG_HYP, 437 HID_NAVI_DRAG_LINK, 438 HID_NAVI_DRAG_COPY, 439 }; 440 PopupMenu *pMenu = new PopupMenu; 441 for (sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++) 442 { 443 pMenu->InsertItem( i + 1, aContextArr[i] ); 444 pMenu->SetHelpId(i + 1, aHIDs[i]); 445 } 446 pMenu->CheckItem( nRegionMode + 1 ); 447 pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl)); 448 pBox->SetItemDown( nCurrItemId, sal_True ); 449 pMenu->Execute( pBox, 450 pBox->GetItemRect(FN_DROP_REGION), 451 POPUPMENU_EXECUTE_DOWN ); 452 pBox->SetItemDown( nCurrItemId, sal_False ); 453 pBox->EndSelection(); 454 delete pMenu; 455 pBox->Invalidate(); 456 } 457 break; 458 case FN_OUTLINE_LEVEL: 459 { 460 PopupMenu *pMenu = new PopupMenu; 461 for (sal_uInt16 i = 101; i <= 100 + MAXLEVEL; i++) 462 { 463 pMenu->InsertItem( i, String::CreateFromInt32(i - 100) ); 464 pMenu->SetHelpId( i, HID_NAVI_OUTLINES ); 465 } 466 pMenu->CheckItem( aContentTree.GetOutlineLevel() + 100 ); 467 pMenu->SetSelectHdl(LINK(this, SwNavigationPI, MenuSelectHdl)); 468 pBox->SetItemDown( nCurrItemId, sal_True ); 469 pMenu->Execute( pBox, 470 pBox->GetItemRect(FN_OUTLINE_LEVEL), 471 POPUPMENU_EXECUTE_DOWN ); 472 pBox->SetItemDown( nCurrItemId, sal_False ); 473 delete pMenu; 474 pBox->EndSelection(); 475 pBox->Invalidate(); 476 } 477 break; 478 } 479 return sal_True; 480 } 481 482 /*-----------------13.07.04 ------------------- 483 --------------------------------------------------*/ 484 485 SwNavHelpToolBox::SwNavHelpToolBox(SwNavigationPI* pParent, const ResId &rResId) : 486 SwHelpToolBox(pParent, rResId) 487 {} 488 /*-----------------19.06.97 09:09------------------- 489 490 --------------------------------------------------*/ 491 void SwNavHelpToolBox::MouseButtonDown(const MouseEvent &rEvt) 492 { 493 if(rEvt.GetButtons() == MOUSE_LEFT && 494 FN_CREATE_NAVIGATION == GetItemId(rEvt.GetPosPixel())) 495 { 496 ((SwNavigationPI*)GetParent())->CreateNavigationTool(GetItemRect(FN_CREATE_NAVIGATION), sal_False); 497 } 498 else 499 SwHelpToolBox::MouseButtonDown(rEvt); 500 } 501 /* -----------------------------12.03.2002 16:55------------------------------ 502 503 ---------------------------------------------------------------------------*/ 504 void SwNavigationPI::CreateNavigationTool(const Rectangle& rRect, sal_Bool bSetFocus) 505 { 506 // SfxBindings& rBind = GetCreateView()->GetViewFrame()->GetBindings(); 507 // rBind.ENTERREGISTRATIONS(); 508 Reference< XFrame > xFrame = GetCreateView()->GetViewFrame()->GetFrame().GetFrameInterface(); 509 SwScrollNaviPopup* pPopup = new 510 SwScrollNaviPopup(FN_SCROLL_NAVIGATION, 511 xFrame ); 512 // rBind.LEAVEREGISTRATIONS(); 513 514 Rectangle aRect(rRect); 515 Point aT1 = aRect.TopLeft(); 516 aT1 = pPopup->GetParent()->OutputToScreenPixel(pPopup->GetParent()->AbsoluteScreenToOutputPixel(aContentToolBox.OutputToAbsoluteScreenPixel(aT1))); 517 aRect.SetPos(aT1); 518 pPopup->StartPopupMode(aRect, FLOATWIN_POPUPMODE_RIGHT|FLOATWIN_POPUPMODE_ALLOWTEAROFF); 519 SetPopupWindow( pPopup ); 520 if(bSetFocus) 521 { 522 pPopup->EndPopupMode(FLOATWIN_POPUPMODEEND_TEAROFF); 523 pPopup->GrabFocus(); 524 } 525 } 526 527 /*-----------------19.06.97 10:12------------------- 528 529 --------------------------------------------------*/ 530 void SwNavHelpToolBox::RequestHelp( const HelpEvent& rHEvt ) 531 { 532 sal_uInt16 nItemId = GetItemId(ScreenToOutputPixel(rHEvt.GetMousePosPixel())); 533 if( FN_UP == nItemId || FN_DOWN == nItemId ) 534 { 535 SetItemText(nItemId, SwScrollNaviPopup::GetQuickHelpText((FN_DOWN == nItemId))); 536 } 537 SwHelpToolBox::RequestHelp(rHEvt); 538 } 539 540 /*------------------------------------------------------------------------ 541 Beschreibung: Action-Handler Edit; wechselt auf die Seite, wenn 542 nicht Gliederungssicht angeschaltet ist. 543 ------------------------------------------------------------------------*/ 544 545 546 IMPL_LINK( SwNavigationPI, EditAction, NumEditAction *, pEdit ) 547 { 548 SwView *pView = GetCreateView(); 549 if (pView) 550 { 551 if(aPageChgTimer.IsActive()) 552 aPageChgTimer.Stop(); 553 pCreateView->GetWrtShell().GotoPage((sal_uInt16)pEdit->GetValue(), sal_True); 554 pCreateView->GetEditWin().GrabFocus(); 555 pCreateView->GetViewFrame()->GetBindings().Invalidate(FN_STAT_PAGE); 556 } 557 return 0; 558 } 559 560 /*------------------------------------------------------------------------ 561 Beschreibung: Falls die Seite eingestellt werden kann, wird hier 562 das Maximum gesetzt. 563 ------------------------------------------------------------------------*/ 564 565 566 IMPL_LINK( SwNavigationPI, EditGetFocus, NumEditAction *, pEdit ) 567 { 568 SwView *pView = GetCreateView(); 569 if (!pView) 570 return 0; 571 SwWrtShell &rSh = pView->GetWrtShell(); 572 573 const sal_uInt16 nPageCnt = rSh.GetPageCnt(); 574 pEdit->SetMax(nPageCnt); 575 pEdit->SetLast(nPageCnt); 576 return 0; 577 } 578 579 /*------------------------------------------------------------------------ 580 Beschreibung: 581 ------------------------------------------------------------------------*/ 582 583 sal_Bool SwNavigationPI::Close() 584 { 585 SfxViewFrame* pVFrame = pCreateView->GetViewFrame(); 586 pVFrame->GetBindings().Invalidate(SID_NAVIGATOR); 587 pVFrame->GetDispatcher()->Execute(SID_NAVIGATOR); 588 return sal_True; 589 } 590 591 /*------------------------------------------------------------------------ 592 Beschreibung: Setzen einer automatischen Marke 593 ------------------------------------------------------------------------*/ 594 595 596 void SwNavigationPI::MakeMark() 597 { 598 SwView *pView = GetCreateView(); 599 if (!pView) return; 600 SwWrtShell &rSh = pView->GetWrtShell(); 601 IDocumentMarkAccess* const pMarkAccess = rSh.getIDocumentMarkAccess(); 602 603 // collect and sort navigator reminder names 604 ::std::vector< ::rtl::OUString > vNavMarkNames; 605 for(IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->getMarksBegin(); 606 ppMark != pMarkAccess->getMarksEnd(); 607 ppMark++) 608 if( IDocumentMarkAccess::GetType(**ppMark) == IDocumentMarkAccess::NAVIGATOR_REMINDER ) 609 vNavMarkNames.push_back(ppMark->get()->GetName()); 610 ::std::sort(vNavMarkNames.begin(), vNavMarkNames.end()); 611 612 // we are maxed out and delete one 613 // nAutoMarkIdx rotates through the available MarkNames 614 // this assumes that IDocumentMarkAccess generates Names in ascending order 615 if(vNavMarkNames.size() == MAX_MARKS) 616 pMarkAccess->deleteMark(pMarkAccess->findMark(vNavMarkNames[nAutoMarkIdx])); 617 618 rSh.SetBookmark(KeyCode(), ::rtl::OUString(), ::rtl::OUString(), IDocumentMarkAccess::NAVIGATOR_REMINDER); 619 SwView::SetActMark( nAutoMarkIdx ); 620 621 if(++nAutoMarkIdx == MAX_MARKS) 622 nAutoMarkIdx = 0; 623 } 624 625 /*------------------------------------------------------------------------ 626 Beschreibung: 627 ------------------------------------------------------------------------*/ 628 629 void SwNavigationPI::GotoPage() 630 { 631 if ( pContextWin->GetFloatingWindow() && pContextWin->GetFloatingWindow()->IsRollUp()) 632 _ZoomIn(); 633 if(IsGlobalMode()) 634 ToggleTree(); 635 UsePage(0); 636 GetPageEdit().GrabFocus(); 637 } 638 639 /*------------------------------------------------------------------------ 640 Beschreibung: 641 ------------------------------------------------------------------------*/ 642 643 void SwNavigationPI::_ZoomOut() 644 { 645 if (_IsZoomedIn()) 646 { 647 FloatingWindow* pFloat = pContextWin->GetFloatingWindow(); 648 bIsZoomedIn = sal_False; 649 Size aSz(GetOutputSizePixel()); 650 aSz.Height() = nZoomOut; 651 Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel(); 652 ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size( 653 aMinOutSizePixel.Width(),nZoomOutInit)); 654 pFloat->SetOutputSizePixel(aSz); 655 FillBox(); 656 if(IsGlobalMode()) 657 { 658 aGlobalTree.ShowTree(); 659 } 660 else 661 { 662 aContentTree.ShowTree(); 663 aDocListBox.Show(); 664 } 665 SvLBoxEntry* pFirst = aContentTree.FirstSelected(); 666 if(pFirst) 667 aContentTree.Select(pFirst, sal_True); // toolbox enablen 668 pConfig->SetSmall( sal_False ); 669 aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX); 670 } 671 } 672 673 /*------------------------------------------------------------------------ 674 Beschreibung: 675 ------------------------------------------------------------------------*/ 676 677 void SwNavigationPI::_ZoomIn() 678 { 679 FloatingWindow* pFloat = pContextWin->GetFloatingWindow(); 680 if (pFloat && 681 (!_IsZoomedIn() || ( pContextWin->GetFloatingWindow()->IsRollUp()))) 682 { 683 aContentTree.HideTree(); 684 aDocListBox.Hide(); 685 aGlobalTree.HideTree(); 686 bIsZoomedIn = sal_True; 687 Size aSz(GetOutputSizePixel()); 688 if( aSz.Height() > nZoomIn ) 689 nZoomOut = ( short ) aSz.Height(); 690 691 aSz.Height() = nZoomIn; 692 Size aMinOutSizePixel = ((SfxDockingWindow*)GetParent())->GetMinOutputSizePixel(); 693 ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(Size( 694 aMinOutSizePixel.Width(), aSz.Height())); 695 pFloat->SetOutputSizePixel(aSz); 696 SvLBoxEntry* pFirst = aContentTree.FirstSelected(); 697 if(pFirst) 698 aContentTree.Select(pFirst, sal_True); // toolbox enablen 699 pConfig->SetSmall( sal_True ); 700 aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_False); 701 } 702 } 703 /*------------------------------------------------------------------------ 704 Beschreibung: 705 ------------------------------------------------------------------------*/ 706 707 void SwNavigationPI::Resize() 708 { 709 Window* pParent = GetParent(); 710 FloatingWindow* pFloat = ((DockingWindow*)pParent)->GetFloatingWindow(); 711 Size aNewSize; 712 if( !_IsZoomedIn() ) 713 { 714 //change the minimum width depending on the dock status 715 Size aMinOutSizePixel = ((SfxDockingWindow*)pParent)->GetMinOutputSizePixel(); 716 if( pFloat) 717 { 718 aNewSize = pFloat->GetOutputSizePixel(); 719 aMinOutSizePixel.Width() = nWishWidth; 720 aMinOutSizePixel.Height() = _IsZoomedIn() ? nZoomIn : nZoomOutInit; 721 } 722 else 723 { 724 aNewSize = pParent->GetOutputSizePixel(); 725 aMinOutSizePixel.Width() = 0; 726 aMinOutSizePixel.Height() = 0; 727 } 728 ((SfxDockingWindow*)GetParent())->SetMinOutputSizePixel(aMinOutSizePixel); 729 730 const Point aPos = aContentTree.GetPosPixel(); 731 Point aLBPos = aDocListBox.GetPosPixel(); 732 long nDist = aPos.X(); 733 aNewSize.Height() -= (aPos.Y() + aPos.X() + nDocLBIniHeight + nDist); 734 aNewSize.Width() -= 2 * nDist; 735 aLBPos.Y() = aPos.Y() + aNewSize.Height() + nDist; 736 aDocListBox.Show(!aGlobalTree.IsVisible() && aLBPos.Y() > aPos.Y() ); 737 738 Size aDocLBSz = aDocListBox.GetSizePixel(); 739 aDocLBSz.Width() = aNewSize.Width(); 740 if(aNewSize.Height() < 0) 741 aDocLBSz.Height() = 0; 742 else 743 aDocLBSz.Height() = nDocLBIniHeight; 744 aContentTree.SetSizePixel(aNewSize); 745 // GlobalTree faengt weiter oben an und reicht bis ganz unten 746 aNewSize.Height() += (nDist + nDocLBIniHeight + aPos.Y() - aGlobalTree.GetPosPixel().Y()); 747 aGlobalTree.SetSizePixel(aNewSize); 748 aDocListBox.SetPosSizePixel( aLBPos.X(), aLBPos.Y(), 749 aDocLBSz.Width(), aDocLBSz.Height(), 750 WINDOW_POSSIZE_X|WINDOW_POSSIZE_Y|WINDOW_POSSIZE_WIDTH); 751 752 } 753 } 754 755 756 /*------------------------------------------------------------------------ 757 Beschreibung: 758 ------------------------------------------------------------------------*/ 759 760 SwNavigationPI::SwNavigationPI( SfxBindings* _pBindings, 761 SfxChildWindowContext* pCw, 762 Window* pParent) : 763 764 Window( pParent, SW_RES(DLG_NAVIGATION_PI)), 765 SfxControllerItem( SID_DOCFULLNAME, *_pBindings ), 766 767 aContentToolBox(this, SW_RES(TB_CONTENT)), 768 aGlobalToolBox(this, SW_RES(TB_GLOBAL)), 769 aContentImageList(SW_RES(IL_CONTENT)), 770 aContentImageListH(SW_RES(ILH_CONTENT)), 771 aContentTree(this, SW_RES(TL_CONTENT)), 772 aGlobalTree(this, SW_RES(TL_GLOBAL)), 773 aDocListBox(this, SW_RES(LB_DOCS)), 774 775 pxObjectShell(0), 776 pContentView(0), 777 pContentWrtShell(0), 778 pActContView(0), 779 pCreateView(0), 780 pPopupWindow(0), 781 pFloatingWindow(0), 782 783 pContextWin(pCw), 784 785 pConfig(SW_MOD()->GetNavigationConfig()), 786 rBindings(*_pBindings), 787 788 nWishWidth(0), 789 nAutoMarkIdx(1), 790 nRegionMode(REGION_MODE_NONE), 791 792 bSmallMode(sal_False), 793 bIsZoomedIn(sal_False), 794 bPageCtrlsVisible(sal_False), 795 bGlobalMode(sal_False) 796 { 797 GetCreateView(); 798 InitImageList(); 799 800 aContentToolBox.SetHelpId(HID_NAVIGATOR_TOOLBOX ); 801 aGlobalToolBox.SetHelpId(HID_NAVIGATOR_GLOBAL_TOOLBOX); 802 aDocListBox.SetHelpId(HID_NAVIGATOR_LISTBOX ); 803 804 nDocLBIniHeight = aDocListBox.GetSizePixel().Height(); 805 nZoomOutInit = nZoomOut = Resource::ReadShortRes(); 806 807 //NumericField in die Toolbox einfuegen 808 NumEditAction* pEdit = new NumEditAction( 809 &aContentToolBox, SW_RES(NF_PAGE )); 810 pEdit->SetActionHdl(LINK(this, SwNavigationPI, EditAction)); 811 pEdit->SetGetFocusHdl(LINK(this, SwNavigationPI, EditGetFocus)); 812 pEdit->SetAccessibleName(pEdit->GetQuickHelpText()); 813 pEdit->SetUpHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); 814 pEdit->SetDownHdl(LINK(this, SwNavigationPI, PageEditModifyHdl)); 815 816 bPageCtrlsVisible = sal_True; 817 818 // Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SHOW_ROOT); 819 // sal_uInt16 nWidth = 2 * (sal_uInt16)aFirstRect.Left(); 820 //doppelte Separatoren sind nicht erlaubt, also muss 821 //die passende Groesse anders ermittelt werden 822 Rectangle aFirstRect = aContentToolBox.GetItemRect(FN_SELECT_FOOTNOTE); 823 Rectangle aSecondRect = aContentToolBox.GetItemRect(FN_SELECT_HEADER); 824 sal_uInt16 nWidth = sal_uInt16(aFirstRect.Left() - aSecondRect.Left()); 825 826 Size aItemWinSize( nWidth , aFirstRect.Bottom() - aFirstRect.Top() ); 827 pEdit->SetSizePixel(aItemWinSize); 828 aContentToolBox.InsertSeparator(4); 829 aContentToolBox.InsertWindow( FN_PAGENUMBER, pEdit, 0, 4); 830 aContentToolBox.InsertSeparator(4); 831 aContentToolBox.SetHelpId(FN_PAGENUMBER, HID_NAVI_TBX16); 832 aContentToolBox.ShowItem( FN_PAGENUMBER ); 833 834 for( sal_uInt16 i = 0; i <= REGION_MODE_EMBEDDED; i++ ) 835 { 836 aContextArr[i] = SW_RESSTR(ST_HYPERLINK + i); 837 aStatusArr[i] = SW_RESSTR(ST_STATUS_FIRST + i); 838 } 839 aStatusArr[3] = SW_RESSTR(ST_ACTIVE_VIEW); 840 FreeResource(); 841 842 843 const Size& rOutSize = GetOutputSizePixel(); 844 845 nZoomIn = (short)rOutSize.Height(); 846 847 // Make sure the toolbox has a size that fits all its contents 848 Size aContentToolboxSize( aContentToolBox.CalcWindowSizePixel() ); 849 aContentToolBox.SetOutputSizePixel( aContentToolboxSize ); 850 851 // position listbox below toolbar and add some space 852 long nListboxYPos = aContentToolBox.GetPosPixel().Y() + aContentToolboxSize.Height() + 4; 853 854 //Der linke und rechte Rand um die Toolboxen soll gleich sein 855 nWishWidth = aContentToolboxSize.Width(); 856 nWishWidth += 2 * aContentToolBox.GetPosPixel().X(); 857 858 FloatingWindow* pFloat = ((DockingWindow*)pParent)->GetFloatingWindow(); 859 Size aMinSize(pFloat ? nWishWidth : 0, pFloat ? nZoomOutInit : 0); 860 ((SfxDockingWindow*)pParent)->SetMinOutputSizePixel(aMinSize); 861 SetOutputSizePixel( Size( nWishWidth, nZoomOutInit)); 862 Size aTmpParentSize(((SfxDockingWindow*)pParent)->GetSizePixel()); 863 if( 864 ( 865 aTmpParentSize.Width() < aMinSize.Width() || 866 aTmpParentSize.Height() < aMinSize.Height() 867 ) 868 && 869 ((SfxDockingWindow*)pParent)->GetFloatingWindow() && 870 !((SfxDockingWindow*)pParent)->GetFloatingWindow()->IsRollUp() 871 ) 872 ((SfxDockingWindow*)pParent)->SetOutputSizePixel(aMinSize); 873 874 aContentTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y ); 875 aContentTree.SetStyle( aContentTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT| 876 WB_CLIPCHILDREN|WB_HSCROLL|WB_FORCE_MAKEVISIBLE ); 877 aContentTree.SetSpaceBetweenEntries(3); 878 aContentTree.SetSelectionMode( SINGLE_SELECTION ); 879 aContentTree.SetDragDropMode( SV_DRAGDROP_CTRL_MOVE | 880 SV_DRAGDROP_CTRL_COPY | 881 SV_DRAGDROP_ENABLE_TOP ); 882 aContentTree.EnableAsyncDrag(sal_True); 883 aContentTree.ShowTree(); 884 aContentToolBox.CheckItem(FN_SHOW_CONTENT_BOX, sal_True); 885 886 // TreeListBox fuer Globaldokument 887 aGlobalTree.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y ); 888 aGlobalTree.SetSelectionMode( MULTIPLE_SELECTION ); 889 aGlobalTree.SetStyle( aGlobalTree.GetStyle()|WB_HASBUTTONS|WB_HASBUTTONSATROOT| 890 WB_CLIPCHILDREN|WB_HSCROLL ); 891 Size aGlblSize(aGlobalToolBox.CalcWindowSizePixel()); 892 aGlobalToolBox.SetSizePixel(aGlblSize); 893 894 // Handler 895 896 Link aLk = LINK(this, SwNavigationPI, ToolBoxSelectHdl); 897 aContentToolBox.SetSelectHdl( aLk ); 898 aGlobalToolBox.SetSelectHdl( aLk ); 899 aDocListBox.SetSelectHdl(LINK(this, SwNavigationPI, 900 DocListBoxSelectHdl)); 901 aContentToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) ); 902 aContentToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) ); 903 aGlobalToolBox.SetClickHdl( LINK(this, SwNavigationPI, ToolBoxClickHdl) ); 904 aGlobalToolBox.SetDropdownClickHdl( LINK(this, SwNavigationPI, ToolBoxDropdownClickHdl) ); 905 aGlobalToolBox.CheckItem(FN_GLOBAL_SWITCH, sal_True); 906 907 Font aFont(GetFont()); 908 aFont.SetWeight(WEIGHT_NORMAL); 909 GetPageEdit().SetFont(aFont); 910 aFont = aContentTree.GetFont(); 911 aFont.SetWeight(WEIGHT_NORMAL); 912 aContentTree.SetFont(aFont); 913 aGlobalTree.SetFont(aFont); 914 915 StartListening(*SFX_APP()); 916 if ( pCreateView ) 917 StartListening(*pCreateView); 918 SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() ); 919 pImgMan->RegisterToolBox(&aContentToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); 920 pImgMan->RegisterToolBox(&aGlobalToolBox, SFX_TOOLBOX_CHANGEOUTSTYLE); 921 922 aContentToolBox.SetItemBits( FN_CREATE_NAVIGATION, aContentToolBox.GetItemBits( FN_CREATE_NAVIGATION ) | TIB_DROPDOWNONLY ); 923 aContentToolBox.SetItemBits( FN_DROP_REGION, aContentToolBox.GetItemBits( FN_DROP_REGION ) | TIB_DROPDOWNONLY ); 924 aContentToolBox.SetItemBits( FN_OUTLINE_LEVEL, aContentToolBox.GetItemBits( FN_OUTLINE_LEVEL ) | TIB_DROPDOWNONLY ); 925 926 if(IsGlobalDoc()) 927 { 928 SwView *pActView = GetCreateView(); 929 aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, 930 pActView->GetWrtShellPtr()->IsGlblDocSaveLinks()); 931 if(pConfig->IsGlobalActive()) 932 ToggleTree(); 933 aGlobalTree.GrabFocus(); 934 } 935 else 936 aContentTree.GrabFocus(); 937 UsePage(0); 938 aPageChgTimer.SetTimeoutHdl(LINK(this, SwNavigationPI, ChangePageHdl)); 939 aPageChgTimer.SetTimeout(PAGE_CHANGE_TIMEOUT); 940 941 aContentTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_CONTENT)); 942 aGlobalTree.SetAccessibleName(SW_RESSTR(STR_ACCESS_TL_GLOBAL)); 943 aDocListBox.SetAccessibleName(aStatusArr[3]); 944 } 945 946 /*------------------------------------------------------------------------ 947 Beschreibung: 948 ------------------------------------------------------------------------*/ 949 950 SwNavigationPI::~SwNavigationPI() 951 { 952 if(IsGlobalDoc() && !IsGlobalMode()) 953 { 954 SwView *pView = GetCreateView(); 955 SwWrtShell &rSh = pView->GetWrtShell(); 956 if( !rSh.IsAllProtect() ) 957 pView->GetDocShell()->SetReadOnlyUI(sal_False); 958 } 959 960 EndListening(*SFX_APP()); 961 962 SfxImageManager* pImgMan = SfxImageManager::GetImageManager( SW_MOD() ); 963 pImgMan->ReleaseToolBox(&aContentToolBox); 964 pImgMan->ReleaseToolBox(&aGlobalToolBox); 965 delete aContentToolBox.GetItemWindow(FN_PAGENUMBER); 966 aContentToolBox.Clear(); 967 if(pxObjectShell) 968 { 969 if(pxObjectShell->Is()) 970 (*pxObjectShell)->DoClose(); 971 delete pxObjectShell; 972 } 973 delete pPopupWindow; 974 delete pFloatingWindow; 975 976 if ( IsBound() ) 977 rBindings.Release(*this); 978 } 979 980 /*------------------------------------------------------------------------ 981 Beschreibung: 982 ------------------------------------------------------------------------*/ 983 984 void SwNavigationPI::SetPopupWindow( SfxPopupWindow* pWindow ) 985 { 986 pPopupWindow = pWindow; 987 pPopupWindow->SetPopupModeEndHdl( LINK( this, SwNavigationPI, PopupModeEndHdl )); 988 pPopupWindow->SetDeleteLink_Impl( LINK( this, SwNavigationPI, ClosePopupWindow )); 989 } 990 991 /*------------------------------------------------------------------------ 992 Beschreibung: 993 ------------------------------------------------------------------------*/ 994 995 IMPL_LINK( SwNavigationPI, PopupModeEndHdl, void *, EMPTYARG ) 996 { 997 if ( pPopupWindow->IsVisible() ) 998 { 999 // Replace floating window with popup window and destroy 1000 // floating window instance. 1001 delete pFloatingWindow; 1002 pFloatingWindow = pPopupWindow; 1003 pPopupWindow = 0; 1004 } 1005 else 1006 { 1007 // Popup window has been closed by the user. No replacement, instance 1008 // will destroy itself. 1009 pPopupWindow = 0; 1010 } 1011 1012 return 1; 1013 } 1014 1015 /*------------------------------------------------------------------------ 1016 Beschreibung: 1017 ------------------------------------------------------------------------*/ 1018 1019 IMPL_LINK( SwNavigationPI, ClosePopupWindow, SfxPopupWindow *, pWindow ) 1020 { 1021 if ( pWindow == pFloatingWindow ) 1022 pFloatingWindow = 0; 1023 else 1024 pPopupWindow = 0; 1025 1026 return 1; 1027 } 1028 1029 /*------------------------------------------------------------------------ 1030 Beschreibung: 1031 ------------------------------------------------------------------------*/ 1032 1033 void SwNavigationPI::StateChanged( sal_uInt16 nSID, SfxItemState /*eState*/, 1034 const SfxPoolItem* /*pState*/ ) 1035 { 1036 if(nSID == SID_DOCFULLNAME) 1037 { 1038 SwView *pActView = GetCreateView(); 1039 if(pActView) 1040 { 1041 SwWrtShell* pWrtShell = pActView->GetWrtShellPtr(); 1042 aContentTree.SetActiveShell(pWrtShell); 1043 sal_Bool bGlobal = IsGlobalDoc(); 1044 aContentToolBox.EnableItem(FN_GLOBAL_SWITCH, bGlobal); 1045 if( (!bGlobal && IsGlobalMode()) || 1046 (!IsGlobalMode() && pConfig->IsGlobalActive()) ) 1047 { 1048 ToggleTree(); 1049 } 1050 if(bGlobal) 1051 { 1052 aGlobalToolBox.CheckItem(FN_GLOBAL_SAVE_CONTENT, pWrtShell->IsGlblDocSaveLinks()); 1053 } 1054 } 1055 else 1056 { 1057 aContentTree.SetActiveShell(0); 1058 } 1059 UpdateListBox(); 1060 } 1061 } 1062 1063 /*------------------------------------------------------------------------ 1064 Bechreibung: NumericField aus der Toolbox holen 1065 ------------------------------------------------------------------------*/ 1066 1067 NumEditAction& SwNavigationPI::GetPageEdit() 1068 { 1069 return *(NumEditAction*)aContentToolBox.GetItemWindow(FN_PAGENUMBER); 1070 } 1071 1072 /*------------------------------------------------------------------------ 1073 Beschreibung: 1074 ------------------------------------------------------------------------*/ 1075 1076 SfxChildAlignment SwNavigationPI::CheckAlignment 1077 ( 1078 SfxChildAlignment eActAlign, 1079 SfxChildAlignment eAlign 1080 ) 1081 { 1082 SfxChildAlignment eRetAlign; 1083 1084 if(_IsZoomedIn()) 1085 eRetAlign = SFX_ALIGN_NOALIGNMENT; 1086 else 1087 switch (eAlign) 1088 { 1089 case SFX_ALIGN_BOTTOM: 1090 case SFX_ALIGN_LOWESTBOTTOM: 1091 case SFX_ALIGN_HIGHESTBOTTOM: 1092 eRetAlign = eActAlign; 1093 break; 1094 1095 case SFX_ALIGN_TOP: 1096 case SFX_ALIGN_HIGHESTTOP: 1097 case SFX_ALIGN_LOWESTTOP: 1098 case SFX_ALIGN_LEFT: 1099 case SFX_ALIGN_RIGHT: 1100 case SFX_ALIGN_FIRSTLEFT: 1101 case SFX_ALIGN_LASTLEFT: 1102 case SFX_ALIGN_FIRSTRIGHT: 1103 case SFX_ALIGN_LASTRIGHT: 1104 eRetAlign = eAlign; 1105 break; 1106 1107 default: 1108 eRetAlign = eAlign; 1109 break; 1110 } 1111 return eRetAlign; 1112 1113 } 1114 1115 /*-------------------------------------------------------------------- 1116 Beschreibung: Benachrichtigung bei geaenderter DocInfo 1117 --------------------------------------------------------------------*/ 1118 1119 void SwNavigationPI::Notify( SfxBroadcaster& rBrdc, const SfxHint& rHint ) 1120 { 1121 if(&rBrdc == pCreateView) 1122 { 1123 if(rHint.ISA(SfxSimpleHint) && ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING) 1124 { 1125 pCreateView = 0; 1126 } 1127 } 1128 else 1129 { 1130 if(rHint.ISA(SfxEventHint)) 1131 { 1132 if( pxObjectShell && 1133 ((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_CLOSEAPP) 1134 { 1135 DELETEZ(pxObjectShell); 1136 } 1137 else if(((SfxEventHint&) rHint).GetEventId() == SFX_EVENT_OPENDOC) 1138 { 1139 1140 SwView *pActView = GetCreateView(); 1141 if(pActView) 1142 { 1143 SwWrtShell* pWrtShell = pActView->GetWrtShellPtr(); 1144 aContentTree.SetActiveShell(pWrtShell); 1145 if(aGlobalTree.IsVisible()) 1146 { 1147 if(aGlobalTree.Update( sal_False )) 1148 aGlobalTree.Display(); 1149 else 1150 // wenn kein Update notwendig, dann zumindest painten 1151 // wg. der roten Eintraege fuer broken links 1152 aGlobalTree.Invalidate(); 1153 } 1154 } 1155 } 1156 } 1157 } 1158 } 1159 1160 /*-------------------------------------------------------------------- 1161 Beschreibung: 1162 --------------------------------------------------------------------*/ 1163 1164 IMPL_LINK( SwNavigationPI, MenuSelectHdl, Menu *, pMenu ) 1165 { 1166 sal_uInt16 nMenuId = pMenu->GetCurItemId(); 1167 if(nMenuId != USHRT_MAX) 1168 { 1169 if(nMenuId < 100) 1170 SetRegionDropMode( --nMenuId); 1171 else 1172 aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >(nMenuId - 100) ); 1173 } 1174 return 0; 1175 } 1176 1177 1178 /*-------------------------------------------------------------------- 1179 Beschreibung: 1180 --------------------------------------------------------------------*/ 1181 1182 void SwNavigationPI::UpdateListBox() 1183 { 1184 aDocListBox.SetUpdateMode(sal_False); 1185 aDocListBox.Clear(); 1186 SwView *pActView = GetCreateView(); 1187 sal_Bool bDisable = pActView == 0; 1188 SwView *pView = SwModule::GetFirstView(); 1189 sal_uInt16 nCount = 0; 1190 sal_uInt16 nAct = 0; 1191 sal_uInt16 nConstPos = 0; 1192 const SwView* pConstView = aContentTree.IsConstantView() && 1193 aContentTree.GetActiveWrtShell() ? 1194 &aContentTree.GetActiveWrtShell()->GetView(): 1195 0; 1196 while (pView) 1197 { 1198 SfxObjectShell* pDoc = pView->GetDocShell(); 1199 // pb: #i53333# don't show help pages here 1200 if ( !pDoc->IsHelpDocument() ) 1201 { 1202 String sEntry = pDoc->GetTitle(); 1203 sEntry += C2S(" ("); 1204 if (pView == pActView) 1205 { 1206 nAct = nCount; 1207 sEntry += aStatusArr[ST_ACTIVE - ST_STATUS_FIRST]; 1208 } 1209 else 1210 sEntry += aStatusArr[ST_INACTIVE - ST_STATUS_FIRST]; 1211 sEntry += ')'; 1212 aDocListBox.InsertEntry(sEntry); 1213 1214 1215 if (pConstView && pView == pConstView) 1216 nConstPos = nCount; 1217 1218 nCount++; 1219 } 1220 pView = SwModule::GetNextView(pView); 1221 } 1222 aDocListBox.InsertEntry(aStatusArr[3]); //"Aktives Fenster" 1223 nCount++; 1224 1225 if(aContentTree.GetHiddenWrtShell()) 1226 { 1227 String sEntry = aContentTree.GetHiddenWrtShell()->GetView(). 1228 GetDocShell()->GetTitle(); 1229 sEntry += C2S(" ("); 1230 sEntry += aStatusArr[ST_HIDDEN - ST_STATUS_FIRST]; 1231 sEntry += ')'; 1232 aDocListBox.InsertEntry(sEntry); 1233 bDisable = sal_False; 1234 } 1235 if(aContentTree.IsActiveView()) 1236 { 1237 //entweder den Namen des akt. Docs oder "Aktives Dokument" 1238 sal_uInt16 nTmp = pActView ? nAct : --nCount; 1239 aDocListBox.SelectEntryPos( nTmp ); 1240 } 1241 else if(aContentTree.IsHiddenView()) 1242 { 1243 aDocListBox.SelectEntryPos(nCount); 1244 } 1245 else 1246 aDocListBox.SelectEntryPos(nConstPos); 1247 1248 aDocListBox.Enable( !bDisable ); 1249 aDocListBox.SetUpdateMode(sal_True); 1250 } 1251 1252 /*-----------------16.06.97 15:05------------------- 1253 1254 --------------------------------------------------*/ 1255 1256 /*------------------------------------------------------------------------ 1257 Beschreibung: 1258 ------------------------------------------------------------------------*/ 1259 1260 IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem) 1261 { 1262 const SfxViewFrameItem* pFrameItem = PTR_CAST(SfxViewFrameItem, pItem ); 1263 if( pFrameItem ) 1264 { 1265 SfxViewFrame* pFrame = pFrameItem->GetFrame(); 1266 if(pFrame) 1267 { 1268 aContentTree.Clear(); 1269 pContentView = PTR_CAST(SwView, pFrame->GetViewShell()); 1270 DBG_ASSERT(pContentView, "keine SwView"); 1271 if(pContentView) 1272 pContentWrtShell = pContentView->GetWrtShellPtr(); 1273 else 1274 pContentWrtShell = 0; 1275 pxObjectShell = new SfxObjectShellLock(pFrame->GetObjectShell()); 1276 FillBox(); 1277 aContentTree.Update(); 1278 } 1279 } 1280 return 0; 1281 } 1282 1283 String SwNavigationPI::CreateDropFileName( TransferableDataHelper& rData ) 1284 { 1285 String sFileName; 1286 sal_uLong nFmt; 1287 if( rData.HasFormat( nFmt = FORMAT_FILE_LIST )) 1288 { 1289 FileList aFileList; 1290 rData.GetFileList( nFmt, aFileList ); 1291 sFileName = aFileList.GetFile( 0 ); 1292 } 1293 else if( rData.HasFormat( nFmt = FORMAT_STRING ) || 1294 rData.HasFormat( nFmt = FORMAT_FILE ) || 1295 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILENAME )) 1296 rData.GetString( nFmt, sFileName ); 1297 else if( rData.HasFormat( nFmt = SOT_FORMATSTR_ID_SOLK ) || 1298 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )|| 1299 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILECONTENT ) || 1300 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) || 1301 rData.HasFormat( nFmt = SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR )) 1302 { 1303 INetBookmark aBkmk( aEmptyStr, aEmptyStr ); 1304 rData.GetINetBookmark( nFmt, aBkmk ); 1305 sFileName = aBkmk.GetURL(); 1306 } 1307 if( sFileName.Len() ) 1308 { 1309 sFileName = INetURLObject( sFileName ).GetMainURL( INetURLObject::NO_DECODE ); 1310 } 1311 return sFileName; 1312 } 1313 1314 /*------------------------------------------------------------------------ 1315 Beschreibung: 1316 ------------------------------------------------------------------------*/ 1317 1318 sal_Int8 SwNavigationPI::AcceptDrop( const AcceptDropEvent& /*rEvt*/ ) 1319 { 1320 return ( !aContentTree.IsInDrag() && 1321 ( aContentTree.IsDropFormatSupported( FORMAT_FILE ) || 1322 aContentTree.IsDropFormatSupported( FORMAT_STRING ) || 1323 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) || 1324 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )|| 1325 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) || 1326 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) || 1327 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) || 1328 aContentTree.IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME ))) 1329 ? DND_ACTION_COPY 1330 : DND_ACTION_NONE; 1331 } 1332 1333 sal_Int8 SwNavigationPI::ExecuteDrop( const ExecuteDropEvent& rEvt ) 1334 { 1335 TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); 1336 sal_Int8 nRet = DND_ACTION_NONE; 1337 String sFileName; 1338 if( !aContentTree.IsInDrag() && 1339 0 != (sFileName = SwNavigationPI::CreateDropFileName( aData )).Len() ) 1340 { 1341 INetURLObject aTemp( sFileName ); 1342 GraphicDescriptor aDesc( aTemp ); 1343 if( !aDesc.Detect() ) // keine Grafiken annehmen 1344 { 1345 if( STRING_NOTFOUND == sFileName.Search('#') 1346 && (!sContentFileName.Len() || sContentFileName != sFileName )) 1347 { 1348 nRet = rEvt.mnAction; 1349 sFileName.EraseTrailingChars( char(0) ); 1350 sContentFileName = sFileName; 1351 if(pxObjectShell) 1352 { 1353 aContentTree.SetHiddenShell( 0 ); 1354 (*pxObjectShell)->DoClose(); 1355 DELETEZ( pxObjectShell); 1356 } 1357 SfxStringItem aFileItem(SID_FILE_NAME, sFileName ); 1358 String sOptions = C2S("HRC"); 1359 SfxStringItem aOptionsItem( SID_OPTIONS, sOptions ); 1360 SfxLinkItem aLink( SID_DONELINK, 1361 LINK( this, SwNavigationPI, DoneLink ) ); 1362 GetActiveView()->GetViewFrame()->GetDispatcher()->Execute( 1363 SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, 1364 &aFileItem, &aOptionsItem, &aLink, 0L ); 1365 } 1366 } 1367 } 1368 return nRet; 1369 } 1370 1371 /*-----------------27.11.96 13.00------------------- 1372 1373 --------------------------------------------------*/ 1374 1375 void SwNavigationPI::SetRegionDropMode(sal_uInt16 nNewMode) 1376 { 1377 nRegionMode = nNewMode; 1378 pConfig->SetRegionMode( nRegionMode ); 1379 1380 sal_uInt16 nDropId = FN_DROP_REGION; 1381 if(nRegionMode == REGION_MODE_LINK) 1382 nDropId = FN_DROP_REGION_LINK; 1383 else if(nRegionMode == REGION_MODE_EMBEDDED) 1384 nDropId = FN_DROP_REGION_COPY; 1385 1386 ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() 1387 ? aContentImageListH : aContentImageList; 1388 1389 aContentToolBox.SetItemImage( FN_DROP_REGION, 1390 rImgLst.GetImage(nDropId)); 1391 } 1392 1393 1394 /*-----------------12.06.97 09:47------------------- 1395 1396 --------------------------------------------------*/ 1397 1398 sal_Bool SwNavigationPI::ToggleTree() 1399 { 1400 sal_Bool bRet = sal_True; 1401 sal_Bool bGlobalDoc = IsGlobalDoc(); 1402 if(!IsGlobalMode() && bGlobalDoc) 1403 { 1404 SetUpdateMode(sal_False); 1405 if(_IsZoomedIn()) 1406 _ZoomOut(); 1407 aGlobalTree.ShowTree(); 1408 aGlobalToolBox.Show(); 1409 aContentTree.HideTree(); 1410 aContentToolBox.Hide(); 1411 aDocListBox.Hide(); 1412 SetGlobalMode(sal_True); 1413 SetUpdateMode(sal_True); 1414 } 1415 else 1416 { 1417 aGlobalTree.HideTree(); 1418 aGlobalToolBox.Hide(); 1419 if(!_IsZoomedIn()) 1420 { 1421 aContentTree.ShowTree(); 1422 aContentToolBox.Show(); 1423 aDocListBox.Show(); 1424 } 1425 bRet = sal_False; 1426 SetGlobalMode(sal_False); 1427 } 1428 return bRet; 1429 } 1430 1431 /*-----------------13.06.97 09:42------------------- 1432 1433 --------------------------------------------------*/ 1434 sal_Bool SwNavigationPI::IsGlobalDoc() const 1435 { 1436 sal_Bool bRet = sal_False; 1437 SwView *pView = GetCreateView(); 1438 if(pView) 1439 { 1440 SwWrtShell &rSh = pView->GetWrtShell(); 1441 bRet = rSh.IsGlobalDoc(); 1442 } 1443 return bRet; 1444 } 1445 /* -----------------26.10.98 08:10------------------- 1446 * 1447 * --------------------------------------------------*/ 1448 IMPL_LINK( SwNavigationPI, ChangePageHdl, Timer*, EMPTYARG ) 1449 { 1450 EditAction(&GetPageEdit()); 1451 GetPageEdit().GrabFocus(); 1452 return 0; 1453 } 1454 /* -----------------26.10.98 08:14------------------- 1455 * 1456 * --------------------------------------------------*/ 1457 IMPL_LINK( SwNavigationPI, PageEditModifyHdl, Edit*, EMPTYARG ) 1458 { 1459 if(aPageChgTimer.IsActive()) 1460 aPageChgTimer.Stop(); 1461 aPageChgTimer.Start(); 1462 return 0; 1463 } 1464 1465 /* -----------------------------23.04.01 07:34-------------------------------- 1466 1467 ---------------------------------------------------------------------------*/ 1468 SwView* SwNavigationPI::GetCreateView() const 1469 { 1470 if(!pCreateView) 1471 { 1472 SwView* pView = SwModule::GetFirstView(); 1473 while(pView) 1474 { 1475 if(&pView->GetViewFrame()->GetBindings() == &rBindings) 1476 { 1477 ((SwNavigationPI*)this)->pCreateView = pView; 1478 ((SwNavigationPI*)this)->StartListening(*pCreateView); 1479 break; 1480 } 1481 pView = SwModule::GetNextView(pView); 1482 } 1483 } 1484 return pCreateView; 1485 } 1486 1487 1488 /*------------------------------------------------------------------------ 1489 Beschreibung: 1490 ------------------------------------------------------------------------*/ 1491 1492 SwNavigationChild::SwNavigationChild( Window* pParent, 1493 sal_uInt16 nId, 1494 SfxBindings* _pBindings, 1495 SfxChildWinInfo* pInfo ) 1496 : SfxChildWindowContext( nId ) 1497 { 1498 SwNavigationPI* pNavi = new SwNavigationPI( _pBindings, this, pParent ); 1499 SetWindow( pNavi ); 1500 _pBindings->Invalidate(SID_NAVIGATOR); 1501 String sExtra = pInfo->aExtraString; 1502 1503 SwNavigationConfig* pNaviConfig = SW_MOD()->GetNavigationConfig(); 1504 1505 sal_uInt16 nRootType = static_cast< sal_uInt16 >( pNaviConfig->GetRootType() ); 1506 if( nRootType < CONTENT_TYPE_MAX ) 1507 { 1508 pNavi->aContentTree.SetRootType(nRootType); 1509 pNavi->aContentToolBox.CheckItem(FN_SHOW_ROOT, sal_True); 1510 } 1511 pNavi->aContentTree.SetOutlineLevel( static_cast< sal_uInt8 >( pNaviConfig->GetOutlineLevel() ) ); 1512 pNavi->SetRegionDropMode( static_cast< sal_uInt16 >( pNaviConfig->GetRegionMode() ) ); 1513 1514 if(GetFloatingWindow() && pNaviConfig->IsSmall()) 1515 { 1516 pNavi->_ZoomIn(); 1517 } 1518 } 1519 /* -----------------------------06.05.2002 10:06------------------------------ 1520 1521 ---------------------------------------------------------------------------*/ 1522 void SwNavigationPI::DataChanged( const DataChangedEvent& rDCEvt ) 1523 { 1524 Window::DataChanged( rDCEvt ); 1525 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 1526 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1527 { 1528 InitImageList(); 1529 const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); 1530 Color aBgColor = rStyleSettings.GetFaceColor(); 1531 Wallpaper aBack( aBgColor ); 1532 SetBackground( aBack ); 1533 } 1534 } 1535 /* -----------------------------06.05.2002 10:07------------------------------ 1536 1537 ---------------------------------------------------------------------------*/ 1538 void SwNavigationPI::InitImageList() 1539 { 1540 sal_uInt16 k; 1541 1542 ImageList& rImgLst = aContentToolBox.GetSettings().GetStyleSettings().GetHighContrastMode() ? 1543 aContentImageListH : aContentImageList; 1544 for( k = 0; k < aContentToolBox.GetItemCount(); k++) 1545 aContentToolBox.SetItemImage(aContentToolBox.GetItemId(k), 1546 rImgLst.GetImage(aContentToolBox.GetItemId(k))); 1547 1548 for( k = 0; k < aGlobalToolBox.GetItemCount(); k++) 1549 aGlobalToolBox.SetItemImage(aGlobalToolBox.GetItemId(k), 1550 rImgLst.GetImage(aGlobalToolBox.GetItemId(k))); 1551 1552 sal_uInt16 nDropId = FN_DROP_REGION; 1553 if(nRegionMode == REGION_MODE_LINK) 1554 nDropId = FN_DROP_REGION_LINK; 1555 else if(nRegionMode == REGION_MODE_EMBEDDED) 1556 nDropId = FN_DROP_REGION_COPY; 1557 aContentToolBox.SetItemImage( FN_DROP_REGION, 1558 rImgLst.GetImage(nDropId)); 1559 } 1560 1561