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_sd.hxx" 26 27 28 #include <tools/urlobj.hxx> 29 #include <unotools/localfilehelper.hxx> 30 #include <sfx2/imgmgr.hxx> 31 #include <sfx2/fcontnr.hxx> 32 #include <svl/eitem.hxx> 33 #include <svl/stritem.hxx> 34 #include <sfx2/docfilt.hxx> 35 #include <sfx2/docfile.hxx> 36 #include <svl/intitem.hxx> 37 #include <sfx2/dispatch.hxx> 38 #include <svx/svxids.hrc> 39 #include <vcl/menu.hxx> 40 41 #include <sfx2/viewfrm.hxx> 42 #include <sfx2/dockwin.hxx> 43 #include <sfx2/sfxresid.hxx> 44 45 #include "pres.hxx" 46 #include "navigatr.hxx" 47 #include "navigatr.hrc" 48 #include "pgjump.hxx" 49 #include "app.hrc" 50 #include "strings.hrc" 51 #include "res_bmp.hrc" 52 #include "drawdoc.hxx" 53 #include "DrawDocShell.hxx" 54 #include "sdresid.hxx" 55 #include "ViewShell.hxx" 56 #include "ViewShellBase.hxx" 57 #include "DrawViewShell.hxx" 58 #include "slideshow.hxx" 59 #include "FrameView.hxx" 60 #include "helpids.h" 61 62 namespace { 63 static const sal_uInt16 nShowNamedShapesFilter=1; 64 static const sal_uInt16 nShowAllShapesFilter=2; 65 } 66 67 /************************************************************************* 68 |* SdNavigatorWin - FloatingWindow 69 \************************************************************************/ 70 71 SdNavigatorWin::SdNavigatorWin( 72 ::Window* pParent, 73 ::sd::NavigatorChildWindow* pChWinCtxt, 74 const SdResId& rSdResId, 75 SfxBindings* pInBindings, 76 const UpdateRequestFunctor& rUpdateRequest) 77 : ::Window( pParent, rSdResId ), 78 maToolbox ( this, SdResId( 1 ) ), 79 maTlbObjects( this, SdResId( TLB_OBJECTS ) ), 80 maLbDocs ( this, SdResId( LB_DOCS ) ), 81 mpChildWinContext( pChWinCtxt ), 82 mbDocImported ( sal_False ), 83 // Bei Aenderung des DragTypes: SelectionMode der TLB anpassen! 84 meDragType ( NAVIGATOR_DRAGTYPE_EMBEDDED ), 85 mpBindings ( pInBindings ), 86 maImageList ( SdResId( IL_NAVIGATR ) ), 87 maImageListH ( SdResId( ILH_NAVIGATR ) ) 88 { 89 maTlbObjects.SetViewFrame( mpBindings->GetDispatcher()->GetFrame() ); 90 91 FreeResource(); 92 93 maTlbObjects.SetAccessibleName(String(SdResId(STR_OBJECTS_TREE))); 94 95 mpNavigatorCtrlItem = new SdNavigatorControllerItem( SID_NAVIGATOR_STATE, this, mpBindings, rUpdateRequest); 96 mpPageNameCtrlItem = new SdPageNameControllerItem( SID_NAVIGATOR_PAGENAME, this, mpBindings, rUpdateRequest); 97 mpDocList = new List(); 98 99 ApplyImageList(); // load images *before* calculating sizes to get something useful !!! 100 101 Size aTbxSize( maToolbox.CalcWindowSizePixel() ); 102 maToolbox.SetOutputSizePixel( aTbxSize ); 103 maToolbox.SetSelectHdl( LINK( this, SdNavigatorWin, SelectToolboxHdl ) ); 104 maToolbox.SetClickHdl( LINK( this, SdNavigatorWin, ClickToolboxHdl ) ); 105 maToolbox.SetDropdownClickHdl( LINK(this, SdNavigatorWin, DropdownClickToolBoxHdl) ); 106 maToolbox.SetItemBits( TBI_DRAGTYPE, maToolbox.GetItemBits( TBI_DRAGTYPE ) | TIB_DROPDOWNONLY ); 107 108 // Shape filter drop down menu. 109 maToolbox.SetItemBits(TBI_SHAPE_FILTER, 110 maToolbox.GetItemBits(TBI_SHAPE_FILTER) | TIB_DROPDOWNONLY); 111 112 // TreeListBox 113 // set position below toolbox 114 long nListboxYPos = maToolbox.GetPosPixel().Y() + maToolbox.GetSizePixel().Height() + 4; 115 maTlbObjects.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y ); 116 maTlbObjects.SetDoubleClickHdl( LINK( this, SdNavigatorWin, ClickObjectHdl ) ); 117 maTlbObjects.SetSelectionMode( SINGLE_SELECTION ); 118 // set focus to listbox, otherwise it is in the toolbox which is only useful 119 // for keyboard navigation 120 maTlbObjects.GrabFocus(); 121 122 // DragTypeListBox 123 maLbDocs.SetSelectHdl( LINK( this, SdNavigatorWin, SelectDocumentHdl ) ); 124 // set position below treelistbox 125 nListboxYPos = maTlbObjects.GetPosPixel().Y() + maTlbObjects.GetSizePixel().Height() + 4; 126 maLbDocs.SetPosSizePixel( 0, nListboxYPos, 0, 0, WINDOW_POSSIZE_Y ); 127 128 // set min outputsize after all sizes are known 129 long nFullHeight = nListboxYPos + maLbDocs.GetSizePixel().Height() + 4; 130 maSize = GetOutputSizePixel(); 131 if( maSize.Height() < nFullHeight ) 132 { 133 maSize.Height() = nFullHeight; 134 SetOutputSizePixel( maSize ); 135 } 136 maMinSize = maSize; 137 long nMinWidth = 2*maToolbox.GetPosPixel().X() + aTbxSize.Width(); // never clip the toolbox 138 if( nMinWidth > maMinSize.Width() ) 139 maMinSize.Width() = nMinWidth; 140 maMinSize.Height() -= 40; 141 SfxDockingWindow* pDockingParent = dynamic_cast<SfxDockingWindow*>(GetParent()); 142 if (pDockingParent != NULL) 143 pDockingParent->SetMinOutputSizePixel( maMinSize ); 144 145 // InitTlb; Wird ueber Slot initiiert 146 if (rUpdateRequest) 147 rUpdateRequest(); 148 } 149 150 // ----------------------------------------------------------------------- 151 152 SdNavigatorWin::~SdNavigatorWin() 153 { 154 delete mpNavigatorCtrlItem; 155 delete mpPageNameCtrlItem; 156 157 // Liste der DocInfos loeschen 158 long nCount = mpDocList->Count(); 159 while( nCount-- ) 160 delete (NavDocInfo*) mpDocList->Remove( (sal_uLong)0 ); 161 162 delete mpDocList; 163 } 164 165 // ----------------------------------------------------------------------- 166 167 void SdNavigatorWin::InitTreeLB( const SdDrawDocument* pDoc ) 168 { 169 SdDrawDocument* pNonConstDoc = (SdDrawDocument*) pDoc; // const as const can... 170 ::sd::DrawDocShell* pDocShell = pNonConstDoc->GetDocSh(); 171 String aDocShName( pDocShell->GetName() ); 172 ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 173 174 // Restore the 'ShowAllShapes' flag from the last time (in this session) 175 // that the navigator was shown. 176 if (pViewShell != NULL) 177 { 178 ::sd::FrameView* pFrameView = pViewShell->GetFrameView(); 179 if (pFrameView != NULL) 180 maTlbObjects.SetShowAllShapes(pFrameView->IsNavigatorShowingAllShapes(), false); 181 } 182 183 // Disable the shape filter drop down menu when there is a running slide 184 // show. 185 if (pViewShell!=NULL && sd::SlideShow::IsRunning( pViewShell->GetViewShellBase() )) 186 maToolbox.EnableItem(TBI_SHAPE_FILTER, sal_False); 187 else 188 maToolbox.EnableItem(TBI_SHAPE_FILTER); 189 190 if( !maTlbObjects.IsEqualToDoc( pDoc ) ) 191 { 192 String aDocName = pDocShell->GetMedium()->GetName(); 193 maTlbObjects.Clear(); 194 maTlbObjects.Fill( pDoc, (sal_Bool) sal_False, aDocName ); // Nur normale Seiten 195 196 RefreshDocumentLB(); 197 maLbDocs.SelectEntry( aDocShName ); 198 } 199 else 200 { 201 maLbDocs.SetNoSelection(); 202 maLbDocs.SelectEntry( aDocShName ); 203 204 // auskommentiert um 30246 zu fixen 205 // if( maLbDocs.GetSelectEntryCount() == 0 ) 206 { 207 RefreshDocumentLB(); 208 maLbDocs.SelectEntry( aDocShName ); 209 } 210 } 211 212 SfxViewFrame* pViewFrame = ( ( pViewShell && pViewShell->GetViewFrame() ) ? pViewShell->GetViewFrame() : SfxViewFrame::Current() ); 213 if( pViewFrame ) 214 pViewFrame->GetBindings().Invalidate(SID_NAVIGATOR_PAGENAME, sal_True, sal_True); 215 } 216 217 /************************************************************************* 218 |* 219 |* DragType wird in Abhaengigkeit davon gesetzt, ob ein Drag ueberhaupt 220 |* moeglich ist. Graphiken duerfen beispielsweise unter gewissen Umstaenden 221 |* nicht gedragt werden (#31038#). 222 |* 223 \************************************************************************/ 224 225 NavigatorDragType SdNavigatorWin::GetNavigatorDragType() 226 { 227 NavigatorDragType eDT = meDragType; 228 NavDocInfo* pInfo = GetDocInfo(); 229 230 if( ( eDT == NAVIGATOR_DRAGTYPE_LINK ) && ( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() ) ) 231 eDT = NAVIGATOR_DRAGTYPE_NONE; 232 233 return( eDT ); 234 } 235 236 // ----------------------------------------------------------------------- 237 238 239 IMPL_LINK( SdNavigatorWin, SelectToolboxHdl, void *, EMPTYARG ) 240 { 241 sal_uInt16 nId = maToolbox.GetCurItemId(); 242 sal_uInt16 nSId = 0; 243 PageJump ePage = PAGE_NONE; 244 245 switch( nId ) 246 { 247 case TBI_PEN: 248 { 249 if( nId == TBI_PEN ) 250 { 251 nSId = SID_NAVIGATOR_PEN; 252 } 253 254 if( nSId > 0 ) 255 { 256 SfxBoolItem aItem( nSId, sal_True ); 257 mpBindings->GetDispatcher()->Execute( 258 nSId, SFX_CALLMODE_SLOT |SFX_CALLMODE_RECORD, &aItem, 0L ); 259 } 260 } 261 break; 262 263 case TBI_FIRST: 264 case TBI_PREVIOUS: 265 case TBI_NEXT: 266 case TBI_LAST: 267 { 268 if( nId == TBI_FIRST ) 269 ePage = PAGE_FIRST; 270 else if( nId == TBI_PREVIOUS ) 271 ePage = PAGE_PREVIOUS; 272 else if( nId == TBI_NEXT ) 273 ePage = PAGE_NEXT; 274 else if( nId == TBI_LAST ) 275 ePage = PAGE_LAST; 276 277 if( ePage != PAGE_NONE ) 278 { 279 SfxUInt16Item aItem( SID_NAVIGATOR_PAGE, (sal_uInt16)ePage ); 280 mpBindings->GetDispatcher()->Execute( 281 SID_NAVIGATOR_PAGE, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L ); 282 } 283 } 284 break; 285 } 286 return 0; 287 } 288 289 // ----------------------------------------------------------------------- 290 291 292 IMPL_LINK( SdNavigatorWin, ClickToolboxHdl, ToolBox*, EMPTYARG ) 293 { 294 return 0; 295 } 296 297 // ----------------------------------------------------------------------- 298 299 IMPL_LINK( SdNavigatorWin, DropdownClickToolBoxHdl, ToolBox*, pBox ) 300 { 301 sal_uInt16 nId = maToolbox.GetCurItemId(); 302 303 switch( nId ) 304 { 305 case TBI_DRAGTYPE: 306 { 307 // Popup-Menu wird in Abhaengigkeit davon erzeugt, ob Dokument 308 // gespeichert ist oder nicht 309 PopupMenu *pMenu = new PopupMenu; 310 311 static const char* aHIDs[] = 312 { 313 HID_SD_NAVIGATOR_MENU1, 314 HID_SD_NAVIGATOR_MENU2, 315 HID_SD_NAVIGATOR_MENU3, 316 0 317 }; 318 319 for( sal_uInt16 nID = NAVIGATOR_DRAGTYPE_URL; 320 nID < NAVIGATOR_DRAGTYPE_COUNT; 321 nID++ ) 322 { 323 sal_uInt16 nRId = GetDragTypeSdResId( (NavigatorDragType)nID ); 324 if( nRId > 0 ) 325 { 326 DBG_ASSERT(aHIDs[nID-NAVIGATOR_DRAGTYPE_URL],"HelpId not added!"); 327 pMenu->InsertItem( nID, String( SdResId( nRId ) ) ); 328 pMenu->SetHelpId( nID, aHIDs[nID - NAVIGATOR_DRAGTYPE_URL] ); 329 } 330 331 } 332 NavDocInfo* pInfo = GetDocInfo(); 333 334 if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() ) 335 { 336 pMenu->EnableItem( NAVIGATOR_DRAGTYPE_LINK, sal_False ); 337 pMenu->EnableItem( NAVIGATOR_DRAGTYPE_URL, sal_False ); 338 meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED; 339 } 340 341 pMenu->CheckItem( (sal_uInt16)meDragType ); 342 pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, MenuSelectHdl ) ); 343 344 pMenu->Execute( this, maToolbox.GetItemRect( nId ), POPUPMENU_EXECUTE_DOWN ); 345 pBox->EndSelection(); 346 delete pMenu; 347 } 348 break; 349 350 case TBI_SHAPE_FILTER: 351 { 352 PopupMenu *pMenu = new PopupMenu; 353 354 pMenu->InsertItem( 355 nShowNamedShapesFilter, 356 String(SdResId(STR_NAVIGATOR_SHOW_NAMED_SHAPES))); 357 pMenu->InsertItem( 358 nShowAllShapesFilter, 359 String(SdResId(STR_NAVIGATOR_SHOW_ALL_SHAPES))); 360 361 if (maTlbObjects.GetShowAllShapes()) 362 pMenu->CheckItem(nShowAllShapesFilter); 363 else 364 pMenu->CheckItem(nShowNamedShapesFilter); 365 pMenu->SetSelectHdl( LINK( this, SdNavigatorWin, ShapeFilterCallback ) ); 366 367 pMenu->Execute( this, maToolbox.GetItemRect( nId ), POPUPMENU_EXECUTE_DOWN ); 368 pBox->EndSelection(); 369 delete pMenu; 370 } 371 break; 372 } 373 return 0; 374 } 375 376 // ----------------------------------------------------------------------- 377 378 IMPL_LINK( SdNavigatorWin, ClickObjectHdl, void *, EMPTYARG ) 379 { 380 if( !mbDocImported || maLbDocs.GetSelectEntryPos() != 0 ) 381 { 382 NavDocInfo* pInfo = GetDocInfo(); 383 384 // Nur wenn es sich um das aktive Fenster handelt, wird 385 // auf die Seite gesprungen 386 if( pInfo && pInfo->IsActive() ) 387 { 388 String aStr( maTlbObjects.GetSelectEntry() ); 389 390 if( aStr.Len() > 0 ) 391 { 392 SfxStringItem aItem( SID_NAVIGATOR_OBJECT, aStr ); 393 mpBindings->GetDispatcher()->Execute( 394 SID_NAVIGATOR_OBJECT, SFX_CALLMODE_SLOT | SFX_CALLMODE_RECORD, &aItem, 0L ); 395 396 // #98821# moved here from SetGetFocusHdl. Reset the 397 // focus only if something has been selected in the 398 // document. 399 SfxViewShell* pCurSh = SfxViewShell::Current(); 400 401 if ( pCurSh ) 402 { 403 Window* pShellWnd = pCurSh->GetWindow(); 404 if ( pShellWnd ) 405 pShellWnd->GrabFocus(); 406 } 407 } 408 } 409 } 410 return( 0L ); 411 } 412 413 // ----------------------------------------------------------------------- 414 415 IMPL_LINK( SdNavigatorWin, SelectDocumentHdl, void *, EMPTYARG ) 416 { 417 String aStrLb = maLbDocs.GetSelectEntry(); 418 long nPos = maLbDocs.GetSelectEntryPos(); 419 sal_Bool bFound = sal_False; 420 ::sd::DrawDocShell* pDocShell = NULL; 421 NavDocInfo* pInfo = GetDocInfo(); 422 423 // Handelt es sich um ein gedragtes Objekt? 424 if( mbDocImported && nPos == 0 ) 425 { 426 // Dokument in TLB aufbauen 427 InsertFile( aStrLb ); 428 } 429 else if (pInfo) 430 { 431 pDocShell = pInfo->mpDocShell; 432 433 bFound = sal_True; 434 } 435 436 if( bFound ) 437 { 438 SdDrawDocument* pDoc = pDocShell->GetDoc(); 439 if( !maTlbObjects.IsEqualToDoc( pDoc ) ) 440 { 441 SdDrawDocument* pNonConstDoc = (SdDrawDocument*) pDoc; // const as const can... 442 ::sd::DrawDocShell* pNCDocShell = pNonConstDoc->GetDocSh(); 443 String aDocName = pNCDocShell->GetMedium()->GetName(); 444 maTlbObjects.Clear(); 445 maTlbObjects.Fill( pDoc, (sal_Bool) sal_False, aDocName ); // Nur normale Seiten 446 } 447 } 448 449 // Pruefen, ob Link oder URL moeglich ist 450 if( ( pInfo && !pInfo->HasName() ) || !maTlbObjects.IsLinkableSelected() || ( meDragType != NAVIGATOR_DRAGTYPE_EMBEDDED ) ) 451 { 452 meDragType = NAVIGATOR_DRAGTYPE_EMBEDDED; 453 SetDragImage(); 454 } 455 456 return( 0L ); 457 } 458 459 /************************************************************************* 460 |* 461 |* DrageType wird gesetzt und Image wird entspr. gesetzt. 462 |* Sollte Handler mit NULL gerufen werden, so wird der Default (URL) gesetzt. 463 |* 464 \************************************************************************/ 465 466 IMPL_LINK( SdNavigatorWin, MenuSelectHdl, Menu *, pMenu ) 467 { 468 sal_uInt16 nMenuId; 469 if( pMenu ) 470 nMenuId = pMenu->GetCurItemId(); 471 else 472 nMenuId = NAVIGATOR_DRAGTYPE_URL; 473 474 if( nMenuId != USHRT_MAX ) // Notwendig ? 475 { 476 NavigatorDragType eDT = (NavigatorDragType) nMenuId; 477 if( meDragType != eDT ) 478 { 479 meDragType = eDT; 480 SetDragImage(); 481 482 if( meDragType == NAVIGATOR_DRAGTYPE_URL ) 483 { 484 // Fix, um Endlosschleife zu unterbinden 485 if( maTlbObjects.GetSelectionCount() > 1 ) 486 maTlbObjects.SelectAll( sal_False ); 487 488 maTlbObjects.SetSelectionMode( SINGLE_SELECTION ); 489 } 490 else 491 maTlbObjects.SetSelectionMode( MULTIPLE_SELECTION ); 492 } 493 } 494 return( 0 ); 495 } 496 497 498 499 500 IMPL_LINK( SdNavigatorWin, ShapeFilterCallback, Menu *, pMenu ) 501 { 502 if (pMenu != NULL) 503 { 504 bool bShowAllShapes (maTlbObjects.GetShowAllShapes()); 505 sal_uInt16 nMenuId (pMenu->GetCurItemId()); 506 switch (nMenuId) 507 { 508 case nShowNamedShapesFilter: 509 bShowAllShapes = false; 510 break; 511 512 case nShowAllShapesFilter: 513 bShowAllShapes = true; 514 break; 515 516 default: 517 OSL_ENSURE( 518 false, "SdNavigatorWin::ShapeFilterCallback called for unknown menu entry"); 519 break; 520 } 521 522 maTlbObjects.SetShowAllShapes(bShowAllShapes, true); 523 524 // Remember the selection in the FrameView. 525 NavDocInfo* pInfo = GetDocInfo(); 526 if (pInfo != NULL) 527 { 528 ::sd::DrawDocShell* pDocShell = pInfo->mpDocShell; 529 if (pDocShell != NULL) 530 { 531 ::sd::ViewShell* pViewShell = pDocShell->GetViewShell(); 532 if (pViewShell != NULL) 533 { 534 ::sd::FrameView* pFrameView = pViewShell->GetFrameView(); 535 if (pFrameView != NULL) 536 { 537 pFrameView->SetIsNavigatorShowingAllShapes(bShowAllShapes); 538 } 539 } 540 } 541 } 542 } 543 544 return 0; 545 } 546 547 // ----------------------------------------------------------------------- 548 549 void SdNavigatorWin::Resize() 550 { 551 Size aWinSize( GetOutputSizePixel() ); 552 if( aWinSize.Height() >= maMinSize.Height() ) 553 //aWinSize.Width() >= maMinSize.Width() ) 554 { 555 Size aDiffSize; 556 aDiffSize.Width() = aWinSize.Width() - maSize.Width(); 557 aDiffSize.Height() = aWinSize.Height() - maSize.Height(); 558 559 // Umgroessern der Toolbox 560 Size aObjSize( maToolbox.GetOutputSizePixel() ); 561 aObjSize.Width() += aDiffSize.Width(); 562 maToolbox.SetOutputSizePixel( aObjSize ); 563 564 // Umgroessern der TreeLB 565 aObjSize = maTlbObjects.Control::GetOutputSizePixel(); 566 aObjSize.Width() += aDiffSize.Width(); 567 aObjSize.Height() += aDiffSize.Height(); 568 maTlbObjects.SetOutputSizePixel( aObjSize ); 569 570 Point aPt( 0, aDiffSize.Height() ); 571 572 // Verschieben der anderen Controls (DocumentLB) 573 maLbDocs.Hide(); 574 aObjSize = maLbDocs.GetOutputSizePixel(); 575 aObjSize.Width() += aDiffSize.Width(); 576 maLbDocs.SetPosPixel( maLbDocs.GetPosPixel() + aPt ); 577 maLbDocs.SetOutputSizePixel( aObjSize ); 578 maLbDocs.Show(); 579 580 maSize = aWinSize; 581 } 582 Window::Resize(); 583 } 584 585 // ----------------------------------------------------------------------- 586 587 sal_Bool SdNavigatorWin::InsertFile(const String& rFileName) 588 { 589 INetURLObject aURL( rFileName ); 590 sal_Bool bReturn = sal_True; 591 592 if( aURL.GetProtocol() == INET_PROT_NOT_VALID ) 593 { 594 String aURLStr; 595 ::utl::LocalFileHelper::ConvertPhysicalNameToURL( rFileName, aURLStr ); 596 aURL = INetURLObject( aURLStr ); 597 } 598 599 // get adjusted FileName 600 String aFileName( aURL.GetMainURL( INetURLObject::NO_DECODE ) ); 601 602 if (!aFileName.Len()) 603 { 604 /********************************************************************** 605 * Wieder aktuelles Dokument anzeigen 606 **********************************************************************/ 607 maDropFileName = aFileName; 608 } 609 else 610 { 611 /********************************************************************** 612 * Hineingedraggtes Dokument anzeigen 613 **********************************************************************/ 614 const SfxFilter* pFilter = NULL; 615 ErrCode nErr = 0; 616 617 if (aFileName != maDropFileName) 618 { 619 SfxMedium aMed(aFileName, (STREAM_READ | STREAM_SHARE_DENYNONE), sal_False); 620 SfxFilterMatcher aMatch( String::CreateFromAscii("simpress") ); 621 aMed.UseInteractionHandler( sal_True ); 622 nErr = aMatch.GuessFilter(aMed, &pFilter); 623 } 624 625 if ((pFilter && !nErr) || aFileName == maDropFileName) 626 { 627 // Das Medium muss ggf. mit READ/WRITE geoeffnet werden, daher wird 628 // ersteinmal nachgeschaut, ob es einen Storage enthaelt 629 SfxMedium* pMedium = new SfxMedium( aFileName, 630 STREAM_READ | STREAM_NOCREATE, 631 sal_True); // Download 632 633 if (pMedium->IsStorage()) 634 { 635 // Jetzt modusabhaengig: 636 // maTlbObjects.SetSelectionMode(MULTIPLE_SELECTION); 637 // Eigentuemeruebergabe von pMedium; 638 SdDrawDocument* pDropDoc = maTlbObjects.GetBookmarkDoc(pMedium); 639 640 if (pDropDoc) 641 { 642 maTlbObjects.Clear(); 643 maDropFileName = aFileName; 644 645 if( !maTlbObjects.IsEqualToDoc( pDropDoc ) ) 646 { 647 // Nur normale Seiten 648 maTlbObjects.Fill(pDropDoc, (sal_Bool) sal_False, maDropFileName); 649 RefreshDocumentLB( &maDropFileName ); 650 } 651 } 652 } 653 else 654 { 655 bReturn = sal_False; 656 delete pMedium; 657 } 658 } 659 else 660 { 661 bReturn = sal_False; 662 } 663 } 664 665 return (bReturn); 666 } 667 668 // ----------------------------------------------------------------------- 669 670 void SdNavigatorWin::RefreshDocumentLB( const String* pDocName ) 671 { 672 sal_uInt16 nPos = 0; 673 674 if( pDocName ) 675 { 676 if( mbDocImported ) 677 maLbDocs.RemoveEntry( 0 ); 678 679 maLbDocs.InsertEntry( *pDocName, 0 ); 680 mbDocImported = sal_True; 681 } 682 else 683 { 684 nPos = maLbDocs.GetSelectEntryPos(); 685 if( nPos == LISTBOX_ENTRY_NOTFOUND ) 686 nPos = 0; 687 688 String aStr; 689 if( mbDocImported ) 690 aStr = maLbDocs.GetEntry( 0 ); 691 692 maLbDocs.Clear(); 693 694 // Liste der DocInfos loeschen 695 long nCount = mpDocList->Count(); 696 while( nCount-- ) 697 delete (NavDocInfo*) mpDocList->Remove( (sal_uLong)0 ); 698 699 if( mbDocImported ) 700 maLbDocs.InsertEntry( aStr, 0 ); 701 702 ::sd::DrawDocShell* pCurrentDocShell = 703 PTR_CAST(::sd::DrawDocShell, SfxObjectShell::Current() ); 704 SfxObjectShell* pSfxDocShell = SfxObjectShell::GetFirst(0, sal_False); 705 while( pSfxDocShell ) 706 { 707 ::sd::DrawDocShell* pDocShell = PTR_CAST(::sd::DrawDocShell, pSfxDocShell ); 708 if( pDocShell && !pDocShell->IsInDestruction() && ( pDocShell->GetCreateMode() != SFX_CREATE_MODE_EMBEDDED ) ) 709 { 710 NavDocInfo* pInfo = new NavDocInfo(); 711 pInfo->mpDocShell = pDocShell; 712 713 aStr = pDocShell->GetMedium()->GetName(); 714 if( aStr.Len() ) 715 pInfo->SetName(); 716 else 717 pInfo->SetName( sal_False ); 718 // z.Z. wird wieder der Name der Shell genommen (also ohne Pfad) 719 // da Koose es als Fehler ansieht, wenn er Pfad in URL-Notation 720 // angezeigt wird! 721 aStr = pDocShell->GetName(); 722 723 maLbDocs.InsertEntry( aStr, LISTBOX_APPEND ); 724 725 // 726 if( pDocShell == pCurrentDocShell ) 727 pInfo->SetActive(); 728 else 729 pInfo->SetActive( sal_False ); 730 731 mpDocList->Insert( pInfo, LIST_APPEND ); 732 } 733 pSfxDocShell = SfxObjectShell::GetNext( *pSfxDocShell, 0 , sal_False ); 734 } 735 } 736 maLbDocs.SelectEntryPos( nPos ); 737 } 738 739 //------------------------------------------------------------------------ 740 741 sal_uInt16 SdNavigatorWin::GetDragTypeSdResId( NavigatorDragType eDT, sal_Bool bImage ) 742 { 743 switch( eDT ) 744 { 745 case NAVIGATOR_DRAGTYPE_NONE: 746 return( bImage ? 0 : STR_NONE ); 747 case NAVIGATOR_DRAGTYPE_URL: 748 return( bImage ? TBI_HYPERLINK : STR_DRAGTYPE_URL ); 749 case NAVIGATOR_DRAGTYPE_EMBEDDED: 750 return( bImage ? TBI_EMBEDDED : STR_DRAGTYPE_EMBEDDED ); 751 case NAVIGATOR_DRAGTYPE_LINK: 752 return( bImage ? TBI_LINK : STR_DRAGTYPE_LINK ); 753 default: DBG_ERROR( "Keine Resource fuer DragType vorhanden!" ); 754 } 755 return( 0 ); 756 } 757 758 //------------------------------------------------------------------------ 759 760 NavDocInfo* SdNavigatorWin::GetDocInfo() 761 { 762 long nPos = maLbDocs.GetSelectEntryPos(); 763 764 if( mbDocImported ) 765 { 766 if( nPos == 0 ) 767 { 768 return( NULL ); 769 } 770 nPos--; 771 } 772 773 NavDocInfo* pInfo = (NavDocInfo*)mpDocList->GetObject( nPos ); 774 775 return( pInfo ); 776 } 777 778 /************************************************************************* 779 |* 780 |* PreNotify 781 |* 782 \************************************************************************/ 783 784 long SdNavigatorWin::Notify(NotifyEvent& rNEvt) 785 { 786 const KeyEvent* pKEvt = rNEvt.GetKeyEvent(); 787 long nOK = sal_False; 788 789 if( pKEvt ) 790 { 791 if( KEY_ESCAPE == pKEvt->GetKeyCode().GetCode() ) 792 { 793 if( SdPageObjsTLB::IsInDrag() ) 794 { 795 // during drag'n'drop we just stop the drag but do not close the navigator 796 nOK = sal_True; 797 } 798 else 799 { 800 ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame()); 801 if( pBase ) 802 { 803 sd::SlideShow::Stop( *pBase ); 804 // Stopping the slide show may result in a synchronous 805 // deletion of the navigator window. Calling the 806 // parents Notify after this is unsafe. Therefore we 807 // return now. 808 return sal_True; 809 } 810 } 811 } 812 } 813 814 if( !nOK ) 815 nOK = Window::Notify( rNEvt ); 816 817 return( nOK ); 818 } 819 820 821 /************************************************************************* 822 |* 823 |* KeyInput: ESCAPE abfangen, um Show zu beenden 824 |* 825 \************************************************************************/ 826 827 void SdNavigatorWin::KeyInput( const KeyEvent& rKEvt ) 828 { 829 long nOK = sal_False; 830 831 if (rKEvt.GetKeyCode().GetCode() == KEY_ESCAPE) 832 { 833 if( SdPageObjsTLB::IsInDrag() ) 834 { 835 // during drag'n'drop we just stop the drag but do not close the navigator 836 nOK = sal_True; 837 } 838 else 839 { 840 ::sd::ViewShellBase* pBase = ::sd::ViewShellBase::GetViewShellBase( mpBindings->GetDispatcher()->GetFrame()); 841 if(pBase) 842 { 843 ::sd::SlideShow::Stop( *pBase ); 844 } 845 } 846 } 847 848 if (!nOK) 849 { 850 Window::KeyInput(rKEvt); 851 } 852 } 853 854 void SdNavigatorWin::DataChanged( const DataChangedEvent& rDCEvt ) 855 { 856 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 857 ApplyImageList(); 858 859 Window::DataChanged( rDCEvt ); 860 } 861 862 void SdNavigatorWin::SetDragImage() 863 { 864 maToolbox.SetItemImage( TBI_DRAGTYPE, maToolbox.GetImageList().GetImage( GetDragTypeSdResId( meDragType, sal_True ) ) ); 865 } 866 867 void SdNavigatorWin::ApplyImageList() 868 { 869 const bool bHighContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); 870 871 maToolbox.SetImageList( bHighContrast ? maImageListH : maImageList ); 872 873 maToolbox.SetItemImage(TBI_SHAPE_FILTER, BitmapEx(SdResId( bHighContrast ? BMP_GRAPHIC_H : BMP_GRAPHIC))); 874 875 SetDragImage(); 876 } 877 878 879 880 /************************************************************************* 881 |* 882 |* ControllerItem fuer Navigator 883 |* 884 \************************************************************************/ 885 886 SdNavigatorControllerItem::SdNavigatorControllerItem( 887 sal_uInt16 _nId, 888 SdNavigatorWin* pNavWin, 889 SfxBindings* _pBindings, 890 const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest) 891 : SfxControllerItem( _nId, *_pBindings ), 892 pNavigatorWin( pNavWin ), 893 maUpdateRequest(rUpdateRequest) 894 { 895 } 896 897 // ----------------------------------------------------------------------- 898 899 void SdNavigatorControllerItem::StateChanged( sal_uInt16 nSId, 900 SfxItemState eState, const SfxPoolItem* pItem ) 901 { 902 if( eState >= SFX_ITEM_AVAILABLE && nSId == SID_NAVIGATOR_STATE ) 903 { 904 const SfxUInt32Item* pStateItem = PTR_CAST( SfxUInt32Item, pItem ); 905 DBG_ASSERT( pStateItem, "SfxUInt16Item erwartet"); 906 sal_uInt32 nState = pStateItem->GetValue(); 907 908 // Stift 909 if( nState & NAVBTN_PEN_ENABLED && 910 !pNavigatorWin->maToolbox.IsItemEnabled( TBI_PEN ) ) 911 pNavigatorWin->maToolbox.EnableItem( TBI_PEN ); 912 if( nState & NAVBTN_PEN_DISABLED && 913 pNavigatorWin->maToolbox.IsItemEnabled( TBI_PEN ) ) 914 pNavigatorWin->maToolbox.EnableItem( TBI_PEN, sal_False ); 915 if( nState & NAVBTN_PEN_CHECKED && 916 !pNavigatorWin->maToolbox.IsItemChecked( TBI_PEN ) ) 917 pNavigatorWin->maToolbox.CheckItem( TBI_PEN ); 918 if( nState & NAVBTN_PEN_UNCHECKED && 919 pNavigatorWin->maToolbox.IsItemChecked( TBI_PEN ) ) 920 pNavigatorWin->maToolbox.CheckItem( TBI_PEN, sal_False ); 921 922 // Nur wenn Doc in LB das Aktive ist 923 NavDocInfo* pInfo = pNavigatorWin->GetDocInfo(); 924 if( pInfo && pInfo->IsActive() ) 925 { 926 // First 927 if( nState & NAVBTN_FIRST_ENABLED && 928 !pNavigatorWin->maToolbox.IsItemEnabled( TBI_FIRST ) ) 929 pNavigatorWin->maToolbox.EnableItem( TBI_FIRST ); 930 if( nState & NAVBTN_FIRST_DISABLED && 931 pNavigatorWin->maToolbox.IsItemEnabled( TBI_FIRST ) ) 932 pNavigatorWin->maToolbox.EnableItem( TBI_FIRST, sal_False ); 933 934 // Prev 935 if( nState & NAVBTN_PREV_ENABLED && 936 !pNavigatorWin->maToolbox.IsItemEnabled( TBI_PREVIOUS ) ) 937 pNavigatorWin->maToolbox.EnableItem( TBI_PREVIOUS ); 938 if( nState & NAVBTN_PREV_DISABLED && 939 pNavigatorWin->maToolbox.IsItemEnabled( TBI_PREVIOUS ) ) 940 pNavigatorWin->maToolbox.EnableItem( TBI_PREVIOUS, sal_False ); 941 942 // Last 943 if( nState & NAVBTN_LAST_ENABLED && 944 !pNavigatorWin->maToolbox.IsItemEnabled( TBI_LAST ) ) 945 pNavigatorWin->maToolbox.EnableItem( TBI_LAST ); 946 if( nState & NAVBTN_LAST_DISABLED && 947 pNavigatorWin->maToolbox.IsItemEnabled( TBI_LAST ) ) 948 pNavigatorWin->maToolbox.EnableItem( TBI_LAST, sal_False ); 949 950 // Next 951 if( nState & NAVBTN_NEXT_ENABLED && 952 !pNavigatorWin->maToolbox.IsItemEnabled( TBI_NEXT ) ) 953 pNavigatorWin->maToolbox.EnableItem( TBI_NEXT ); 954 if( nState & NAVBTN_NEXT_DISABLED && 955 pNavigatorWin->maToolbox.IsItemEnabled( TBI_NEXT ) ) 956 pNavigatorWin->maToolbox.EnableItem( TBI_NEXT, sal_False ); 957 958 if( nState & NAVTLB_UPDATE ) 959 { 960 // InitTlb; Wird ueber Slot initiiert 961 if (maUpdateRequest) 962 maUpdateRequest(); 963 } 964 } 965 } 966 } 967 968 /************************************************************************* 969 |* 970 |* ControllerItem fuer Navigator, um die Seite in der TreeLB anzuzeigen 971 |* 972 \************************************************************************/ 973 974 SdPageNameControllerItem::SdPageNameControllerItem( 975 sal_uInt16 _nId, 976 SdNavigatorWin* pNavWin, 977 SfxBindings* _pBindings, 978 const SdNavigatorWin::UpdateRequestFunctor& rUpdateRequest) 979 : SfxControllerItem( _nId, *_pBindings ), 980 pNavigatorWin( pNavWin ), 981 maUpdateRequest(rUpdateRequest) 982 { 983 } 984 985 // ----------------------------------------------------------------------- 986 987 void SdPageNameControllerItem::StateChanged( sal_uInt16 nSId, 988 SfxItemState eState, const SfxPoolItem* pItem ) 989 { 990 if( eState >= SFX_ITEM_AVAILABLE && nSId == SID_NAVIGATOR_PAGENAME ) 991 { 992 // Nur wenn Doc in LB das Aktive ist 993 NavDocInfo* pInfo = pNavigatorWin->GetDocInfo(); 994 if( pInfo && pInfo->IsActive() ) 995 { 996 const SfxStringItem* pStateItem = PTR_CAST( SfxStringItem, pItem ); 997 DBG_ASSERT( pStateItem, "SfxStringItem erwartet"); 998 String aPageName = pStateItem->GetValue(); 999 1000 if( !pNavigatorWin->maTlbObjects.HasSelectedChilds( aPageName ) ) 1001 { 1002 if( pNavigatorWin->maTlbObjects.GetSelectionMode() == MULTIPLE_SELECTION ) 1003 { 1004 // Weil sonst immer dazuselektiert wird 1005 pNavigatorWin->maTlbObjects.SelectAll( sal_False ); 1006 } 1007 pNavigatorWin->maTlbObjects.SelectEntry( aPageName ); 1008 } 1009 } 1010 } 1011 } 1012