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