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 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_sd.hxx" 24 25 #include <sal/types.h> 26 #include <sot/formats.hxx> 27 #include <sot/storage.hxx> 28 #include <vcl/msgbox.hxx> 29 #include <svl/urihelper.hxx> 30 #include <svx/svditer.hxx> 31 #include <sfx2/docfile.hxx> 32 #include <svx/svdoole2.hxx> 33 #include <vcl/svapp.hxx> 34 #include "cusshow.hxx" 35 #include <sfx2/childwin.hxx> 36 37 #include <sfx2/viewfrm.hxx> 38 39 #include "strmname.h" 40 #include "sdtreelb.hxx" 41 #include "DrawDocShell.hxx" 42 #include "drawdoc.hxx" 43 #include "sdpage.hxx" 44 #include "sdresid.hxx" 45 #include "navigatr.hxx" 46 #ifndef _SD_CFGID_HXX 47 #include "strings.hrc" 48 #endif 49 #include "res_bmp.hrc" 50 #include "ViewShell.hxx" 51 #include "DrawController.hxx" 52 #include "ViewShellBase.hxx" 53 54 #include <com/sun/star/embed/XEmbedPersist.hpp> 55 #include <com/sun/star/frame/XDesktop.hpp> 56 #include <com/sun/star/frame/XFramesSupplier.hpp> 57 #include <svtools/embedtransfer.hxx> 58 #include <comphelper/processfactory.hxx> 59 #include <tools/diagnose_ex.h> 60 61 using namespace com::sun::star; 62 63 class SdPageObjsTLB::IconProvider 64 { 65 public: 66 IconProvider (void); 67 68 // Regular icons. 69 Image maImgPage; 70 Image maImgPageExcl; 71 Image maImgPageObjsExcl; 72 Image maImgPageObjs; 73 Image maImgObjects; 74 Image maImgGroup; 75 76 // High contrast icons. 77 Image maImgPageH; 78 Image maImgPageExclH; 79 Image maImgPageObjsExclH; 80 Image maImgPageObjsH; 81 Image maImgObjectsH; 82 Image maImgGroupH; 83 }; 84 85 sal_Bool SD_DLLPRIVATE SdPageObjsTLB::bIsInDrag = sal_False; 86 87 sal_Bool SdPageObjsTLB::IsInDrag() 88 { 89 return bIsInDrag; 90 } 91 92 sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::mnListBoxDropFormatId = SAL_MAX_UINT32; 93 94 // ----------------------------------------- 95 // - SdPageObjsTLB::SdPageObjsTransferable - 96 // ----------------------------------------- 97 98 SdPageObjsTLB::SdPageObjsTransferable::SdPageObjsTransferable( 99 SdPageObjsTLB& rParent, 100 const INetBookmark& rBookmark, 101 ::sd::DrawDocShell& rDocShell, 102 NavigatorDragType eDragType, 103 const ::com::sun::star::uno::Any& rTreeListBoxData ) 104 : SdTransferable(rDocShell.GetDoc(), NULL, sal_True), 105 mrParent( rParent ), 106 maBookmark( rBookmark ), 107 mrDocShell( rDocShell ), 108 meDragType( eDragType ), 109 maTreeListBoxData( rTreeListBoxData ) 110 { 111 } 112 113 SdPageObjsTLB::SdPageObjsTransferable::~SdPageObjsTransferable() 114 { 115 } 116 117 // ----------------------------------------------------------------------------- 118 119 void SdPageObjsTLB::SdPageObjsTransferable::AddSupportedFormats() 120 { 121 AddFormat(SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK); 122 AddFormat(SOT_FORMATSTR_ID_TREELISTBOX); 123 AddFormat(GetListBoxDropFormatId()); 124 } 125 126 // ----------------------------------------------------------------------------- 127 128 sal_Bool SdPageObjsTLB::SdPageObjsTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) 129 { 130 sal_uLong nFormatId = SotExchange::GetFormat( rFlavor ); 131 switch (nFormatId) 132 { 133 case SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK: 134 SetINetBookmark( maBookmark, rFlavor ); 135 return sal_True; 136 137 case SOT_FORMATSTR_ID_TREELISTBOX: 138 SetAny(maTreeListBoxData, rFlavor); 139 return sal_True; 140 141 default: 142 return sal_False; 143 } 144 } 145 146 // ----------------------------------------------------------------------------- 147 148 void SdPageObjsTLB::SdPageObjsTransferable::DragFinished( sal_Int8 nDropAction ) 149 { 150 mrParent.OnDragFinished( nDropAction ); 151 SdTransferable::DragFinished(nDropAction); 152 } 153 154 // ----------------------------------------------------------------------------- 155 156 ::sd::DrawDocShell& SdPageObjsTLB::SdPageObjsTransferable::GetDocShell() const 157 { 158 return mrDocShell; 159 } 160 161 // ----------------------------------------------------------------------------- 162 163 NavigatorDragType SdPageObjsTLB::SdPageObjsTransferable::GetDragType() const 164 { 165 return meDragType; 166 } 167 168 // ----------------------------------------------------------------------------- 169 170 sal_Int64 SAL_CALL SdPageObjsTLB::SdPageObjsTransferable::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw( ::com::sun::star::uno::RuntimeException ) 171 { 172 sal_Int64 nRet; 173 174 if( ( rId.getLength() == 16 ) && 175 ( 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), rId.getConstArray(), 16 ) ) ) 176 { 177 nRet = (sal_Int64)(sal_IntPtr)this; 178 } 179 else 180 nRet = SdTransferable::getSomething(rId); 181 182 return nRet; 183 } 184 185 // ----------------------------------------------------------------------------- 186 187 const ::com::sun::star::uno::Sequence< sal_Int8 >& SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId() 188 { 189 static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq; 190 191 if( !aSeq.getLength() ) 192 { 193 static osl::Mutex aCreateMutex; 194 osl::MutexGuard aGuard( aCreateMutex ); 195 196 aSeq.realloc( 16 ); 197 rtl_createUuid( reinterpret_cast< sal_uInt8* >( aSeq.getArray() ), 0, sal_True ); 198 } 199 200 return aSeq; 201 } 202 203 // ----------------------------------------------------------------------------- 204 205 SdPageObjsTLB::SdPageObjsTransferable* SdPageObjsTLB::SdPageObjsTransferable::getImplementation( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& rxData ) 206 throw() 207 { 208 try 209 { 210 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XUnoTunnel > xUnoTunnel( rxData, ::com::sun::star::uno::UNO_QUERY_THROW ); 211 212 return reinterpret_cast<SdPageObjsTLB::SdPageObjsTransferable*>( 213 sal::static_int_cast<sal_uIntPtr>( 214 xUnoTunnel->getSomething( SdPageObjsTLB::SdPageObjsTransferable::getUnoTunnelId()) ) ); 215 } 216 catch( const ::com::sun::star::uno::Exception& ) 217 { 218 } 219 return 0; 220 } 221 222 sal_uInt32 SdPageObjsTLB::SdPageObjsTransferable::GetListBoxDropFormatId (void) 223 { 224 if (mnListBoxDropFormatId == SAL_MAX_UINT32) 225 mnListBoxDropFormatId = SotExchange::RegisterFormatMimeType( 226 ::rtl::OUString::createFromAscii( 227 "application/x-openoffice-treelistbox-moveonly;" 228 "windows_formatname=\"SV_LBOX_DD_FORMAT_MOVE\"")); 229 return mnListBoxDropFormatId; 230 } 231 232 /************************************************************************* 233 |* Ctor1 SdPageObjsTLB 234 \************************************************************************/ 235 236 SdPageObjsTLB::SdPageObjsTLB( Window* pParentWin, const SdResId& rSdResId ) 237 : SvTreeListBox ( pParentWin, rSdResId ) 238 , bisInSdNavigatorWin ( sal_False ) 239 , mpParent ( pParentWin ) 240 , mpDoc ( NULL ) 241 , mpBookmarkDoc ( NULL ) 242 , mpMedium ( NULL ) 243 , mpOwnMedium ( NULL ) 244 , maImgOle ( BitmapEx( SdResId( BMP_OLE ) ) ) 245 , maImgGraphic ( BitmapEx( SdResId( BMP_GRAPHIC ) ) ) 246 , maImgOleH ( BitmapEx( SdResId( BMP_OLE_H ) ) ) 247 , maImgGraphicH ( BitmapEx( SdResId( BMP_GRAPHIC_H ) ) ) 248 , mbLinkableSelected ( sal_False ) 249 , mpDropNavWin ( NULL ) 250 , mbShowAllShapes ( false ) 251 , mbShowAllPages ( false ) 252 { 253 // Tree-ListBox mit Linien versehen 254 SetStyle( GetStyle() | WB_TABSTOP | WB_BORDER | WB_HASLINES | 255 WB_HASBUTTONS | // WB_HASLINESATROOT | 256 WB_HSCROLL | // #31562# 257 WB_HASBUTTONSATROOT | 258 WB_QUICK_SEARCH /* i31275 */ ); 259 SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND ) ), 260 Bitmap( SdResId( BMP_COLLAPSE ) ) ); 261 262 SetNodeBitmaps( Bitmap( SdResId( BMP_EXPAND_H ) ), 263 Bitmap( SdResId( BMP_COLLAPSE_H ) ), 264 BMP_COLOR_HIGHCONTRAST ); 265 266 SetDragDropMode( 267 SV_DRAGDROP_CTRL_MOVE | SV_DRAGDROP_CTRL_COPY | 268 SV_DRAGDROP_APP_MOVE | SV_DRAGDROP_APP_COPY | SV_DRAGDROP_APP_DROP ); 269 } 270 271 /************************************************************************* 272 |* Dtor SdPageObjsTLB 273 \************************************************************************/ 274 275 SdPageObjsTLB::~SdPageObjsTLB() 276 { 277 if ( mpBookmarkDoc ) 278 CloseBookmarkDoc(); 279 else 280 // no document was created from mpMedium, so this object is still the owner of it 281 delete mpMedium; 282 } 283 284 // helper function for GetEntryAltText and GetEntryLongDescription 285 String SdPageObjsTLB::getAltLongDescText( SvLBoxEntry* pEntry , sal_Bool isAltText) const 286 { 287 sal_uInt16 maxPages = mpDoc->GetPageCount(); 288 sal_uInt16 pageNo; 289 SdrObject* pObj = NULL; 290 SdPage* pPage = NULL; 291 292 String ParentName = GetEntryText( GetRootLevelParent( pEntry ) ); 293 294 for( pageNo = 0; pageNo < maxPages; pageNo++ ) 295 { 296 pPage = (SdPage*) mpDoc->GetPage( pageNo ); 297 if( pPage->GetPageKind() != PK_STANDARD ) continue; 298 if( pPage->GetName() != ParentName ) continue; 299 SdrObjListIter aIter( *pPage, IM_FLAT ); 300 while( aIter.IsMore() ) 301 { 302 pObj = aIter.Next(); 303 if( GetEntryText(pEntry) == GetObjectName( pObj ) ) 304 { 305 if( isAltText ) 306 return pObj->GetTitle(); 307 else 308 return pObj->GetDescription(); 309 } 310 } 311 } 312 return String(); 313 314 } 315 316 String SdPageObjsTLB::GetEntryAltText( SvLBoxEntry* pEntry ) const 317 { 318 return getAltLongDescText( pEntry, sal_True ); 319 } 320 321 String SdPageObjsTLB::GetEntryLongDescription( SvLBoxEntry* pEntry ) const 322 { 323 return getAltLongDescText( pEntry, sal_False); 324 } 325 326 void SdPageObjsTLB::MarkCurEntry( const String& rName ) 327 { 328 329 if( rName.Len() ) 330 { 331 SvLBoxEntry* pCurEntry =GetCurEntry(); 332 SvLBoxEntry* pEntry =NULL; 333 String aTmp1; 334 String aTmp2; 335 336 if( GetParent(pCurEntry)==NULL ) 337 { 338 aTmp1 = GetEntryText( pCurEntry ); 339 for( pEntry = First(); pEntry ; pEntry = Next( pEntry ) ) 340 { 341 if(GetParent( pEntry )==NULL) 342 continue; 343 aTmp2 = GetEntryText( GetParent( pEntry )); 344 if( aTmp1 != aTmp2) 345 { 346 // IA2 CWS. MT: Removed in SvLBoxEntry for now - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this 347 pEntry->SetMarked(sal_False); 348 } 349 } 350 351 } 352 else 353 { 354 for( pEntry = First(); pEntry ; pEntry = Next( pEntry ) ) 355 { 356 aTmp2 = GetEntryText( pEntry ); 357 if( aTmp2 == rName) 358 { 359 pEntry->SetMarked(sal_True); 360 } 361 else 362 { 363 pEntry->SetMarked(sal_False); 364 } 365 } 366 } 367 } 368 Invalidate(); 369 } 370 371 void SdPageObjsTLB:: FreshCurEntry() 372 { 373 SvLBoxEntry* pEntry =NULL; 374 for( pEntry = First(); pEntry ; pEntry = Next( pEntry ) ) 375 { 376 pEntry->SetMarked(sal_False); 377 } 378 Invalidate(); 379 } 380 381 class SdContentLBoxString : public SvLBoxString 382 { 383 public: 384 SdContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, 385 const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {} 386 387 virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 388 SvLBoxEntry* pEntry); 389 }; 390 391 void SdPageObjsTLB::InitEntry(SvLBoxEntry* pEntry, 392 const XubString& rStr ,const Image& rImg1,const Image& rImg2,SvLBoxButtonKind eButtonKind) 393 { 394 sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2" 395 SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); 396 SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite ); 397 SdContentLBoxString* pStr = new SdContentLBoxString( pEntry, 0, pCol->GetText() ); 398 pEntry->ReplaceItem( pStr, nColToHilite ); 399 } 400 401 void SdContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 402 SvLBoxEntry* pEntry ) 403 { 404 // IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this 405 /* 406 if (pEntry->IsMarked()) 407 { 408 rDev.DrawText( rPos, GetText() ); 409 XubString str; 410 str = XubString::CreateFromAscii("*"); 411 Point rPosStar(rPos.X()-6,rPos.Y()); 412 Font aOldFont( rDev.GetFont()); 413 Font aFont(aOldFont); 414 Color aCol( aOldFont.GetColor() ); 415 aCol.DecreaseLuminance( 200 ); 416 aFont.SetColor( aCol ); 417 rDev.SetFont( aFont ); 418 rDev.DrawText( rPosStar, str); 419 rDev.SetFont( aOldFont ); 420 } 421 else 422 */ 423 SvLBoxString::Paint( rPos, rDev, nFlags, pEntry); 424 425 } 426 427 void SdPageObjsTLB::SaveExpandedTreeItemState(SvLBoxEntry* pEntry, vector<String>& vectTreeItem) 428 { 429 if (pEntry) 430 { 431 SvLBoxEntry* pListEntry = pEntry; 432 while (pListEntry) 433 { 434 if (pListEntry->HasChilds()) 435 { 436 if (IsExpanded(pListEntry)) 437 vectTreeItem.push_back(GetEntryText(pListEntry)); 438 SvLBoxEntry* pChildEntry = FirstChild(pListEntry); 439 SaveExpandedTreeItemState(pChildEntry, vectTreeItem); 440 } 441 pListEntry = NextSibling(pListEntry); 442 } 443 } 444 } 445 void SdPageObjsTLB::Clear() 446 { 447 // Save the expanded tree item 448 if (mbSaveTreeItemState) 449 { 450 maSelectionEntryText = String(); 451 maTreeItem.clear(); 452 if (GetCurEntry()) 453 maSelectionEntryText = GetSelectEntry(); 454 SvLBoxEntry* pEntry = FirstChild(NULL); 455 SaveExpandedTreeItemState(pEntry, maTreeItem); 456 } 457 return SvTreeListBox::Clear(); 458 } 459 /************************************************************************* 460 |* return name of object 461 \************************************************************************/ 462 463 String SdPageObjsTLB::GetObjectName( 464 const SdrObject* pObject, 465 const bool bCreate) const 466 { 467 String aRet; 468 469 if ( pObject ) 470 { 471 aRet = pObject->GetName(); 472 473 if( !aRet.Len() && pObject->ISA( SdrOle2Obj ) ) 474 aRet = static_cast< const SdrOle2Obj* >( pObject )->GetPersistName(); 475 } 476 477 if (bCreate 478 && mbShowAllShapes 479 && aRet.Len() == 0 480 && pObject!=NULL) 481 { 482 aRet = SdResId(STR_NAVIGATOR_SHAPE_BASE_NAME); 483 aRet.SearchAndReplaceAscii("%1", String::CreateFromInt32(pObject->GetOrdNum() + 1)); 484 } 485 486 return aRet; 487 } 488 489 /************************************************************************* 490 |* In TreeLB Eintrag selektieren 491 \************************************************************************/ 492 493 sal_Bool SdPageObjsTLB::SelectEntry( const String& rName ) 494 { 495 sal_Bool bFound = sal_False; 496 497 if( rName.Len() ) 498 { 499 SvLBoxEntry* pEntry = NULL; 500 String aTmp; 501 502 for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) ) 503 { 504 aTmp = GetEntryText( pEntry ); 505 if( aTmp == rName ) 506 { 507 bFound = sal_True; 508 SetCurEntry( pEntry ); 509 } 510 } 511 } 512 return( bFound ); 513 } 514 515 /************************************************************************* 516 |* Gibt zurück, ob Childs des übergebenen Strings selektiert sind 517 \************************************************************************/ 518 519 sal_Bool SdPageObjsTLB::HasSelectedChilds( const String& rName ) 520 { 521 sal_Bool bFound = sal_False; 522 sal_Bool bChilds = sal_False; 523 524 if( rName.Len() ) 525 { 526 SvLBoxEntry* pEntry = NULL; 527 String aTmp; 528 529 for( pEntry = First(); pEntry && !bFound; pEntry = Next( pEntry ) ) 530 { 531 aTmp = GetEntryText( pEntry ); 532 if( aTmp == rName ) 533 { 534 bFound = sal_True; 535 sal_Bool bExpanded = IsExpanded( pEntry ); 536 long nCount = GetChildSelectionCount( pEntry ); 537 if( bExpanded && nCount > 0 ) 538 bChilds = sal_True; 539 } 540 } 541 } 542 return( bChilds ); 543 } 544 545 /************************************************************************* 546 |* TreeLB mit Seiten und Objekten füllen 547 \************************************************************************/ 548 549 void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, sal_Bool bAllPages, 550 const String& rDocName) 551 { 552 String aSelection; 553 if( GetSelectionCount() > 0 ) 554 { 555 aSelection = GetSelectEntry(); 556 Clear(); 557 } 558 559 mpDoc = pInDoc; 560 maDocName = rDocName; 561 mbShowAllPages = (bAllPages == sal_True); 562 mpMedium = NULL; 563 564 SdPage* pPage = NULL; 565 566 IconProvider aIconProvider; 567 568 // first insert all pages including objects 569 sal_uInt16 nPage = 0; 570 const sal_uInt16 nMaxPages = mpDoc->GetPageCount(); 571 572 while( nPage < nMaxPages ) 573 { 574 pPage = (SdPage*) mpDoc->GetPage( nPage ); 575 if( (mbShowAllPages || pPage->GetPageKind() == PK_STANDARD) 576 && !(pPage->GetPageKind()==PK_HANDOUT) ) //#94954# never list the normal handout page ( handout-masterpage is used instead ) 577 { 578 sal_Bool bPageExluded = pPage->IsExcluded(); 579 580 bool bPageBelongsToShow = PageBelongsToCurrentShow (pPage); 581 bPageExluded |= !bPageBelongsToShow; 582 583 AddShapeList(*pPage, NULL, pPage->GetName(), bPageExluded, NULL, aIconProvider); 584 } 585 nPage++; 586 } 587 588 // dann alle MasterPages incl. Objekte einfügen 589 if( mbShowAllPages ) 590 { 591 nPage = 0; 592 const sal_uInt16 nMaxMasterPages = mpDoc->GetMasterPageCount(); 593 594 while( nPage < nMaxMasterPages ) 595 { 596 pPage = (SdPage*) mpDoc->GetMasterPage( nPage ); 597 AddShapeList(*pPage, NULL, pPage->GetName(), false, NULL, aIconProvider); 598 nPage++; 599 } 600 } 601 if( aSelection.Len() ) 602 SelectEntry( aSelection ); 603 else if (mbSaveTreeItemState && maSelectionEntryText.Len()) 604 { 605 SelectEntry(maSelectionEntryText); 606 } 607 } 608 609 /************************************************************************* 610 |* Es wird nur der erste Eintrag eingefügt. Childs werden OnDemand erzeugt 611 \************************************************************************/ 612 613 void SdPageObjsTLB::Fill( const SdDrawDocument* pInDoc, SfxMedium* pInMedium, 614 const String& rDocName ) 615 { 616 mpDoc = pInDoc; 617 618 // this object now owns the Medium 619 mpMedium = pInMedium; 620 maDocName = rDocName; 621 622 Image aImgDocOpen=Image( BitmapEx( SdResId( BMP_DOC_OPEN ) ) ); 623 Image aImgDocClosed=Image( BitmapEx( SdResId( BMP_DOC_CLOSED ) ) ); 624 Image aImgDocOpenH=Image( BitmapEx( SdResId( BMP_DOC_OPEN_H ) ) ); 625 Image aImgDocClosedH=Image( BitmapEx( SdResId( BMP_DOC_CLOSED_H ) ) ); 626 627 // Dokumentnamen einfügen 628 SvLBoxEntry* pFileEntry = InsertEntry( maDocName, 629 aImgDocOpen, 630 aImgDocClosed, 631 NULL, 632 sal_True, 633 LIST_APPEND, 634 reinterpret_cast< void* >( 1 ) ); 635 636 SetExpandedEntryBmp( pFileEntry, aImgDocOpenH, BMP_COLOR_HIGHCONTRAST ); 637 SetCollapsedEntryBmp( pFileEntry, aImgDocClosedH, BMP_COLOR_HIGHCONTRAST ); 638 } 639 640 void SdPageObjsTLB::AddShapeList ( 641 const SdrObjList& rList, 642 SdrObject* pShape, 643 const ::rtl::OUString& rsName, 644 const bool bIsExcluded, 645 SvLBoxEntry* pParentEntry, 646 const IconProvider& rIconProvider) 647 { 648 Image aIcon (rIconProvider.maImgPage); 649 if (bIsExcluded) 650 aIcon = rIconProvider.maImgPageExcl; 651 else if (pShape != NULL) 652 aIcon = rIconProvider.maImgGroup; 653 654 void* pUserData (reinterpret_cast<void*>(1)); 655 if (pShape != NULL) 656 pUserData = pShape; 657 658 SvLBoxEntry* pEntry = InsertEntry( 659 rsName, 660 aIcon, 661 aIcon, 662 pParentEntry, 663 sal_False, 664 LIST_APPEND, 665 pUserData); 666 667 SetExpandedEntryBmp( 668 pEntry, 669 bIsExcluded ? rIconProvider.maImgPageExclH : rIconProvider.maImgPageH, 670 BMP_COLOR_HIGHCONTRAST ); 671 SetCollapsedEntryBmp( 672 pEntry, 673 bIsExcluded ? rIconProvider.maImgPageExclH : rIconProvider.maImgPageH, 674 BMP_COLOR_HIGHCONTRAST ); 675 676 SdrObjListIter aIter( 677 rList, 678 !rList.HasObjectNavigationOrder() /* use navigation order, if available */, 679 IM_FLAT, 680 sal_False /*not reverse*/); 681 682 sal_Bool bMarked=sal_False; 683 if(bisInSdNavigatorWin) 684 { 685 Window* pWindow=NULL; 686 SdNavigatorWin* pSdNavigatorWin=NULL; 687 sd::DrawDocShell* pSdDrawDocShell = NULL; 688 if(pEntry) 689 pWindow=(Window*)GetParent(pEntry); 690 if(pWindow) 691 pSdNavigatorWin = (SdNavigatorWin*)pWindow; 692 if( pSdNavigatorWin ) 693 pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc); 694 if(pSdDrawDocShell) 695 bMarked=pSdDrawDocShell->IsMarked(pShape); 696 if(pEntry) 697 { 698 if(bMarked) 699 pEntry->SetMarked(sal_True); 700 else 701 pEntry->SetMarked( sal_False ); 702 } 703 } 704 while( aIter.IsMore() ) 705 { 706 SdrObject* pObj = aIter.Next(); 707 OSL_ASSERT(pObj!=NULL); 708 709 // Get the shape name. 710 String aStr (GetObjectName( pObj ) ); 711 712 if( aStr.Len() ) 713 { 714 if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 ) 715 { 716 SvLBoxEntry* pNewEntry = InsertEntry( aStr, maImgOle, maImgOle, pEntry, 717 sal_False, LIST_APPEND, pObj); 718 if(bisInSdNavigatorWin) 719 { 720 Window* pWindow=NULL; 721 SdNavigatorWin* pSdNavigatorWin=NULL; 722 sd::DrawDocShell* pSdDrawDocShell = NULL; 723 if(pNewEntry) 724 pWindow=(Window*)GetParent(pNewEntry); 725 if(pWindow) 726 pSdNavigatorWin = (SdNavigatorWin*)pWindow; 727 if( pSdNavigatorWin ) 728 pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc); 729 if(pSdDrawDocShell) 730 bMarked=pSdDrawDocShell->IsMarked((SdrObject*)pObj); 731 if(pNewEntry) 732 { 733 if(bMarked) 734 pNewEntry->SetMarked(sal_True); 735 else 736 pNewEntry->SetMarked( sal_False ); 737 } 738 } 739 SetExpandedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST ); 740 SetCollapsedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST ); 741 } 742 else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF ) 743 { 744 SvLBoxEntry* pNewEntry = InsertEntry( aStr, maImgGraphic, maImgGraphic, pEntry, 745 sal_False, LIST_APPEND, pObj ); 746 if(bisInSdNavigatorWin) 747 { 748 Window* pWindow=NULL; 749 SdNavigatorWin* pSdNavigatorWin=NULL; 750 sd::DrawDocShell* pSdDrawDocShell = NULL; 751 if(pNewEntry) 752 pWindow=(Window*)GetParent(pNewEntry); 753 if(pWindow) 754 pSdNavigatorWin = (SdNavigatorWin*)pWindow; 755 if( pSdNavigatorWin ) 756 pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc); 757 if(pSdDrawDocShell) 758 bMarked=pSdDrawDocShell->IsMarked((SdrObject*)pObj); 759 if(pNewEntry) 760 { 761 if(bMarked) 762 { 763 pNewEntry->SetMarked(sal_True); 764 } 765 else 766 { 767 pNewEntry->SetMarked( sal_False ); 768 } 769 } 770 } 771 SetExpandedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST ); 772 SetCollapsedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST ); 773 } 774 else if (pObj->IsGroupObject()) 775 { 776 AddShapeList( 777 *pObj->GetSubList(), 778 pObj, 779 aStr, 780 false, 781 pEntry, 782 rIconProvider); 783 } 784 else 785 { 786 SvLBoxEntry* pNewEntry = InsertEntry( aStr, rIconProvider.maImgObjects, rIconProvider.maImgObjects, pEntry, 787 sal_False, LIST_APPEND, pObj ); 788 if(bisInSdNavigatorWin) 789 { 790 Window* pWindow=NULL; 791 SdNavigatorWin* pSdNavigatorWin=NULL; 792 sd::DrawDocShell* pSdDrawDocShell = NULL; 793 if(pNewEntry) 794 pWindow=(Window*)GetParent(pNewEntry); 795 if(pWindow) 796 pSdNavigatorWin = (SdNavigatorWin*)pWindow; 797 if( pSdNavigatorWin ) 798 pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc); 799 if(pSdDrawDocShell) 800 bMarked=pSdDrawDocShell->IsMarked((SdrObject*)pObj); 801 if(pNewEntry) 802 { 803 if(bMarked) 804 { 805 pNewEntry->SetMarked(sal_True); 806 } 807 else 808 { 809 pNewEntry->SetMarked( sal_False ); 810 } 811 } 812 } 813 SetExpandedEntryBmp( pNewEntry, rIconProvider.maImgObjectsH, BMP_COLOR_HIGHCONTRAST ); 814 SetCollapsedEntryBmp( pNewEntry, rIconProvider.maImgObjectsH, BMP_COLOR_HIGHCONTRAST ); 815 } 816 } 817 } 818 819 if( pEntry->HasChilds() ) 820 { 821 SetExpandedEntryBmp( 822 pEntry, 823 bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs); 824 SetCollapsedEntryBmp( 825 pEntry, 826 bIsExcluded ? rIconProvider.maImgPageObjsExcl : rIconProvider.maImgPageObjs); 827 SetExpandedEntryBmp( 828 pEntry, 829 bIsExcluded ? rIconProvider.maImgPageObjsExclH : rIconProvider.maImgPageObjsH, 830 BMP_COLOR_HIGHCONTRAST); 831 SetCollapsedEntryBmp( 832 pEntry, 833 bIsExcluded ? rIconProvider.maImgPageObjsExclH : rIconProvider.maImgPageObjsH, 834 BMP_COLOR_HIGHCONTRAST); 835 if (mbSaveTreeItemState) 836 { 837 vector<String>:: iterator iteStart = maTreeItem.begin(); 838 while (iteStart != maTreeItem.end()) 839 { 840 String strEntry = GetEntryText(pEntry); 841 if (*iteStart == strEntry) 842 { 843 Expand( pEntry ); 844 break; 845 } 846 ++iteStart; 847 } 848 } 849 else 850 Expand( pEntry ); 851 } 852 } 853 854 void SdPageObjsTLB::SetShowAllShapes ( 855 const bool bShowAllShapes, 856 const bool bFillList) 857 { 858 mbShowAllShapes = bShowAllShapes; 859 if (bFillList) 860 { 861 if (mpMedium == NULL) 862 Fill(mpDoc, mbShowAllPages, maDocName); 863 else 864 Fill(mpDoc, mpMedium, maDocName); 865 } 866 } 867 868 bool SdPageObjsTLB::GetShowAllShapes (void) const 869 { 870 return mbShowAllShapes; 871 } 872 873 /************************************************************************* 874 |* Prüft, ob die Seiten (PK_STANDARD) und die darauf befindlichen Objekte 875 |* des Docs und der TreeLB identisch sind. 876 |* Wird ein Doc übergeben, wird dieses zum aktuellem Doc (Wichtig bei 877 |* mehreren Dokumenten). 878 \************************************************************************/ 879 880 sal_Bool SdPageObjsTLB::IsEqualToDoc( const SdDrawDocument* pInDoc ) 881 { 882 if( pInDoc ) 883 mpDoc = pInDoc; 884 885 if( !mpDoc ) 886 return( sal_False ); 887 888 SdrObject* pObj = NULL; 889 SdPage* pPage = NULL; 890 SvLBoxEntry* pEntry = First(); 891 String aName; 892 893 // Alle Pages incl. Objekte vergleichen 894 sal_uInt16 nPage = 0; 895 const sal_uInt16 nMaxPages = mpDoc->GetPageCount(); 896 897 while( nPage < nMaxPages ) 898 { 899 pPage = (SdPage*) mpDoc->GetPage( nPage ); 900 if( pPage->GetPageKind() == PK_STANDARD ) 901 { 902 if( !pEntry ) 903 return( sal_False ); 904 aName = GetEntryText( pEntry ); 905 906 if( pPage->GetName() != aName ) 907 return( sal_False ); 908 909 pEntry = Next( pEntry ); 910 911 SdrObjListIter aIter( 912 *pPage, 913 !pPage->HasObjectNavigationOrder() /* use navigation order, if available */, 914 IM_DEEPWITHGROUPS ); 915 916 while( aIter.IsMore() ) 917 { 918 pObj = aIter.Next(); 919 920 const String aObjectName( GetObjectName( pObj ) ); 921 922 if( aObjectName.Len() ) 923 { 924 if( !pEntry ) 925 return( sal_False ); 926 927 aName = GetEntryText( pEntry ); 928 929 if( aObjectName != aName ) 930 return( sal_False ); 931 932 pEntry = Next( pEntry ); 933 } 934 } 935 } 936 nPage++; 937 } 938 // Wenn noch Einträge in der Listbox vorhanden sind, wurden 939 // Objekte (mit Namen) oder Seiten gelöscht 940 return( !pEntry ); 941 } 942 943 /************************************************************************* 944 |* Selectierten String zurückgeben 945 \************************************************************************/ 946 947 String SdPageObjsTLB::GetSelectEntry() 948 { 949 return( GetEntryText( GetCurEntry() ) ); 950 } 951 952 /************************************************************************* 953 |* Selektierte Eintrage zurückgeben 954 |* nDepth == 0 -> Seiten 955 |* nDepth == 1 -> Objekte 956 \************************************************************************/ 957 958 List* SdPageObjsTLB::GetSelectEntryList( sal_uInt16 nDepth ) 959 { 960 List* pList = NULL; 961 SvLBoxEntry* pEntry = FirstSelected(); 962 963 while( pEntry ) 964 { 965 sal_uInt16 nListDepth = GetModel()->GetDepth( pEntry ); 966 if( nListDepth == nDepth ) 967 { 968 if( !pList ) 969 pList = new List(); 970 971 const String aEntryText( GetEntryText( pEntry ) ); 972 pList->Insert( new String( aEntryText ), LIST_APPEND ); 973 } 974 pEntry = NextSelected( pEntry ); 975 } 976 977 return( pList ); 978 } 979 980 /************************************************************************* 981 |* Einträge werden erst auf Anforderung (Doppelklick) eingefügt 982 \************************************************************************/ 983 984 void SdPageObjsTLB::RequestingChilds( SvLBoxEntry* pFileEntry ) 985 { 986 if( !pFileEntry->HasChilds() ) 987 { 988 if( GetBookmarkDoc() ) 989 { 990 SdrObject* pObj = NULL; 991 SdPage* pPage = NULL; 992 SvLBoxEntry* pPageEntry = NULL; 993 994 Image aImgPage=Image( BitmapEx( SdResId( BMP_PAGE ) ) ); 995 Image aImgPageObjs=Image( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ); 996 Image aImgObjects=Image( BitmapEx( SdResId( BMP_OBJECTS ) ) ); 997 Image aImgPageH=Image( BitmapEx( SdResId( BMP_PAGE_H ) ) ); 998 Image aImgPageObjsH=Image( BitmapEx( SdResId( BMP_PAGEOBJS_H ) ) ); 999 Image aImgObjectsH=Image( BitmapEx( SdResId( BMP_OBJECTS_H ) ) ); 1000 1001 // document name already inserted 1002 1003 // only insert all "normal" ? slides with objects 1004 sal_uInt16 nPage = 0; 1005 const sal_uInt16 nMaxPages = mpBookmarkDoc->GetPageCount(); 1006 1007 while( nPage < nMaxPages ) 1008 { 1009 pPage = (SdPage*) mpBookmarkDoc->GetPage( nPage ); 1010 if( pPage->GetPageKind() == PK_STANDARD ) 1011 { 1012 pPageEntry = InsertEntry( pPage->GetName(), 1013 aImgPage, 1014 aImgPage, 1015 pFileEntry, 1016 sal_False, 1017 LIST_APPEND, 1018 reinterpret_cast< void* >( 1 ) ); 1019 1020 SetExpandedEntryBmp( pPageEntry, aImgPageH, BMP_COLOR_HIGHCONTRAST ); 1021 SetCollapsedEntryBmp( pPageEntry, aImgPageH, BMP_COLOR_HIGHCONTRAST ); 1022 1023 SdrObjListIter aIter( *pPage, IM_DEEPWITHGROUPS ); 1024 1025 while( aIter.IsMore() ) 1026 { 1027 pObj = aIter.Next(); 1028 String aStr( GetObjectName( pObj ) ); 1029 if( aStr.Len() ) 1030 { 1031 if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_OLE2 ) 1032 { 1033 SvLBoxEntry* pNewEntry = InsertEntry(aStr, maImgOle, maImgOle, pPageEntry); 1034 1035 SetExpandedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST ); 1036 SetCollapsedEntryBmp( pNewEntry, maImgOleH, BMP_COLOR_HIGHCONTRAST ); 1037 } 1038 else if( pObj->GetObjInventor() == SdrInventor && pObj->GetObjIdentifier() == OBJ_GRAF ) 1039 { 1040 SvLBoxEntry* pNewEntry = InsertEntry(aStr, maImgGraphic, maImgGraphic, pPageEntry); 1041 1042 SetExpandedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST ); 1043 SetCollapsedEntryBmp( pNewEntry, maImgGraphicH, BMP_COLOR_HIGHCONTRAST ); 1044 } 1045 else 1046 { 1047 SvLBoxEntry* pNewEntry = InsertEntry(aStr, aImgObjects, aImgObjects, pPageEntry); 1048 1049 SetExpandedEntryBmp( pNewEntry, aImgObjectsH, BMP_COLOR_HIGHCONTRAST ); 1050 SetCollapsedEntryBmp( pNewEntry, aImgObjectsH, BMP_COLOR_HIGHCONTRAST ); 1051 } 1052 } 1053 } 1054 if( pPageEntry->HasChilds() ) 1055 { 1056 SetExpandedEntryBmp( pPageEntry, aImgPageObjs ); 1057 SetCollapsedEntryBmp( pPageEntry, aImgPageObjs ); 1058 SetExpandedEntryBmp( pPageEntry, aImgPageObjsH, BMP_COLOR_HIGHCONTRAST ); 1059 SetCollapsedEntryBmp( pPageEntry, aImgPageObjsH, BMP_COLOR_HIGHCONTRAST ); 1060 } 1061 } 1062 nPage++; 1063 } 1064 } 1065 } 1066 else 1067 SvTreeListBox::RequestingChilds( pFileEntry ); 1068 } 1069 1070 /************************************************************************* 1071 |* Prüft, ob es sich um eine Draw-Datei handelt und öffnet anhand des 1072 |* übergebenen Docs das BookmarkDoc 1073 \************************************************************************/ 1074 1075 SdDrawDocument* SdPageObjsTLB::GetBookmarkDoc(SfxMedium* pMed) 1076 { 1077 if ( 1078 !mpBookmarkDoc || 1079 (pMed && (!mpOwnMedium || mpOwnMedium->GetName() != pMed->GetName())) 1080 ) 1081 { 1082 // create a new BookmarkDoc if now one exists or if a new Medium is provided 1083 if (mpOwnMedium != pMed) 1084 { 1085 CloseBookmarkDoc(); 1086 } 1087 1088 if (pMed) 1089 { 1090 // it looks like it is undefined if a Medium was set by Fill() already 1091 DBG_ASSERT( !mpMedium, "SfxMedium confusion!" ); 1092 delete mpMedium; 1093 mpMedium = NULL; 1094 1095 // take over this Medium (currently used only be Navigator) 1096 mpOwnMedium = pMed; 1097 } 1098 1099 DBG_ASSERT( mpMedium || pMed, "No SfxMedium provided!" ); 1100 1101 if( pMed ) 1102 { 1103 // in this mode the document is also owned and controlled by this instance 1104 mxBookmarkDocShRef = new ::sd::DrawDocShell(SFX_CREATE_MODE_STANDARD, sal_True); 1105 if (mxBookmarkDocShRef->DoLoad(pMed)) 1106 mpBookmarkDoc = mxBookmarkDocShRef->GetDoc(); 1107 else 1108 mpBookmarkDoc = NULL; 1109 } 1110 else if ( mpMedium ) 1111 // in this mode the document is owned and controlled by the SdDrawDocument 1112 // it can be released by calling the corresponding CloseBookmarkDoc method 1113 // successful creation of a document makes this the owner of the medium 1114 mpBookmarkDoc = ((SdDrawDocument*) mpDoc)->OpenBookmarkDoc(*mpMedium); 1115 1116 if ( !mpBookmarkDoc ) 1117 { 1118 ErrorBox aErrorBox( this, WB_OK, String( SdResId( STR_READ_DATA_ERROR ) ) ); 1119 aErrorBox.Execute(); 1120 mpMedium = 0; //On failure the SfxMedium is invalid 1121 } 1122 } 1123 1124 return( mpBookmarkDoc ); 1125 } 1126 1127 /************************************************************************* 1128 |* Bookmark-Dokument schließen und löschen 1129 \************************************************************************/ 1130 1131 void SdPageObjsTLB::CloseBookmarkDoc() 1132 { 1133 if (mxBookmarkDocShRef.Is()) 1134 { 1135 mxBookmarkDocShRef->DoClose(); 1136 mxBookmarkDocShRef.Clear(); 1137 1138 // Medium is owned by document, so it's destroyed already 1139 mpOwnMedium = 0; 1140 } 1141 else if ( mpBookmarkDoc ) 1142 { 1143 DBG_ASSERT( !mpOwnMedium, "SfxMedium confusion!" ); 1144 if ( mpDoc ) 1145 { 1146 // The document owns the Medium, so the Medium will be invalid after closing the document 1147 ((SdDrawDocument*) mpDoc)->CloseBookmarkDoc(); 1148 mpMedium = 0; 1149 } 1150 } 1151 else 1152 { 1153 // perhaps mpOwnMedium provided, but no successful creation of BookmarkDoc 1154 delete mpOwnMedium; 1155 mpOwnMedium = NULL; 1156 } 1157 1158 mpBookmarkDoc = NULL; 1159 } 1160 1161 /************************************************************************* 1162 |* 1163 \************************************************************************/ 1164 1165 void SdPageObjsTLB::SelectHdl() 1166 { 1167 SvLBoxEntry* pEntry = FirstSelected(); 1168 1169 mbLinkableSelected = sal_True; 1170 1171 while( pEntry && mbLinkableSelected ) 1172 { 1173 if( NULL == pEntry->GetUserData() ) 1174 mbLinkableSelected = sal_False; 1175 1176 pEntry = NextSelected( pEntry ); 1177 } 1178 1179 SvTreeListBox::SelectHdl(); 1180 } 1181 1182 /************************************************************************* 1183 |* Überlädt RETURN mit der Funktionsweise von DoubleClick 1184 \************************************************************************/ 1185 1186 void SdPageObjsTLB::KeyInput( const KeyEvent& rKEvt ) 1187 { 1188 if( rKEvt.GetKeyCode().GetCode() == KEY_RETURN ) 1189 { 1190 // Auskommentierter Code aus svtools/source/contnr/svimpbox.cxx 1191 SvLBoxEntry* pCursor = GetCurEntry(); 1192 if( pCursor->HasChilds() || pCursor->HasChildsOnDemand() ) 1193 { 1194 if( IsExpanded( pCursor ) ) 1195 Collapse( pCursor ); 1196 else 1197 Expand( pCursor ); 1198 } 1199 1200 DoubleClickHdl(); 1201 } 1202 else if (rKEvt.GetKeyCode().GetCode() == KEY_SPACE) 1203 { 1204 if(bisInSdNavigatorWin) 1205 { 1206 sal_Bool bMarked=sal_False; 1207 SvLBoxEntry* pNewEntry = GetCurEntry(); 1208 if( GetParent(pNewEntry) == NULL ) 1209 return; 1210 String aStr=GetSelectEntry(); 1211 Window* pWindow=NULL; 1212 SdNavigatorWin* pSdNavigatorWin=NULL; 1213 sd::DrawDocShell* pSdDrawDocShell = NULL; 1214 if(pNewEntry) 1215 pWindow=(Window*)GetParent(pNewEntry); 1216 if(pWindow) 1217 pSdNavigatorWin = (SdNavigatorWin*)pWindow; 1218 if( pSdNavigatorWin ) 1219 pSdDrawDocShell = pSdNavigatorWin->GetDrawDocShell(mpDoc); 1220 if(pSdDrawDocShell) 1221 { 1222 pSdDrawDocShell->GotoTreeBookmark(aStr); 1223 bMarked=pSdDrawDocShell->GetObjectIsmarked(aStr); 1224 } 1225 // Removed by yanjun for sym2_6385 1226 // The symphony2.0 can support more than one level tree list, also support to select tow or more items in different level. 1227 /* 1228 SvLBoxEntry* pBeginEntry = First(); 1229 if( pBeginEntry ) 1230 { 1231 if( GetParent(pBeginEntry) != GetParent(pNewEntry) ) 1232 pBeginEntry->SetMarked( sal_False ); 1233 SvLBoxEntry* pNextEntry = Next( pBeginEntry ); 1234 while( pNextEntry ) 1235 { 1236 if( GetParent(pNextEntry) != GetParent(pNewEntry) ) 1237 pNextEntry->SetMarked( sal_False ); 1238 pNextEntry = Next( pNextEntry ); 1239 } 1240 } 1241 End*/ 1242 if(pNewEntry) 1243 { 1244 if(bMarked) 1245 { 1246 pNewEntry->SetMarked(sal_True); 1247 } 1248 else 1249 { 1250 pNewEntry->SetMarked( sal_False ); 1251 } 1252 } 1253 Invalidate(); 1254 } 1255 } 1256 else 1257 SvTreeListBox::KeyInput( rKEvt ); 1258 } 1259 1260 /************************************************************************* 1261 |* StartDrag-Request 1262 \************************************************************************/ 1263 1264 void SdPageObjsTLB::StartDrag( sal_Int8 nAction, const Point& rPosPixel) 1265 { 1266 (void)nAction; 1267 (void)rPosPixel; 1268 1269 SdNavigatorWin* pNavWin = NULL; 1270 SvLBoxEntry* pEntry = GetEntry(rPosPixel); 1271 1272 if( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) 1273 pNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ); 1274 1275 if (pEntry != NULL 1276 && pNavWin !=NULL 1277 && pNavWin == mpParent 1278 && pNavWin->GetNavigatorDragType() != NAVIGATOR_DRAGTYPE_NONE ) 1279 { 1280 // Mark only the children of the page under the mouse as drop 1281 // targets. This prevents moving shapes from one page to another. 1282 1283 // Select all entries and disable them as drop targets. 1284 SetSelectionMode(MULTIPLE_SELECTION); 1285 SetCursor(NULL, sal_False); 1286 SelectAll(sal_True, sal_False); 1287 EnableSelectionAsDropTarget(sal_False, sal_True); 1288 1289 // Enable only the entries as drop targets that are children of the 1290 // page under the mouse. 1291 SvLBoxEntry* pParent = GetRootLevelParent(pEntry); 1292 if (pParent != NULL) 1293 { 1294 SelectAll(sal_False, sal_False); 1295 Select(pParent, sal_True); 1296 //for (SvLBoxEntry*pChild=FirstChild(pParent); pChild!=NULL; pChild=NextSibling(pChild)) 1297 //Select(pChild, sal_True); 1298 EnableSelectionAsDropTarget(sal_True, sal_True);//sal_False); 1299 } 1300 1301 // Set selection back to the entry under the mouse. 1302 SelectAll(sal_False,sal_False); 1303 SetSelectionMode(SINGLE_SELECTION); 1304 Select(pEntry, sal_True); 1305 1306 // Aus dem ExecuteDrag heraus kann der Navigator gelöscht werden 1307 // (beim Umschalten auf einen anderen Dokument-Typ), das würde aber 1308 // den StarView MouseMove-Handler, der Command() aufruft, umbringen. 1309 // Deshalb Drag&Drop asynchron: 1310 Application::PostUserEvent( STATIC_LINK( this, SdPageObjsTLB, ExecDragHdl ) ); 1311 } 1312 } 1313 1314 /************************************************************************* 1315 |* Begin drag 1316 \************************************************************************/ 1317 1318 void SdPageObjsTLB::DoDrag() 1319 { 1320 mpDropNavWin = ( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) ? 1321 (SdNavigatorWin*)( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ) : 1322 NULL; 1323 1324 if( mpDropNavWin ) 1325 { 1326 ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh(); 1327 String aURL = INetURLObject( pDocShell->GetMedium()->GetPhysicalName(), INET_PROT_FILE ).GetMainURL( INetURLObject::NO_DECODE ); 1328 NavigatorDragType eDragType = mpDropNavWin->GetNavigatorDragType(); 1329 1330 aURL.Append( '#' ); 1331 aURL.Append( GetSelectEntry() ); 1332 1333 INetBookmark aBookmark( aURL, GetSelectEntry() ); 1334 sal_Int8 nDNDActions = DND_ACTION_COPYMOVE; 1335 1336 if( eDragType == NAVIGATOR_DRAGTYPE_LINK ) 1337 nDNDActions = DND_ACTION_LINK; // #93240# Either COPY *or* LINK, never both! 1338 else if (mpDoc->GetSdPageCount(PK_STANDARD) == 1) 1339 { 1340 // Can not move away the last slide in a document. 1341 nDNDActions = DND_ACTION_COPY; 1342 } 1343 1344 SvTreeListBox::ReleaseMouse(); 1345 1346 bIsInDrag = sal_True; 1347 1348 SvLBoxDDInfo aDDInfo; 1349 memset(&aDDInfo,0,sizeof(SvLBoxDDInfo)); 1350 aDDInfo.pApp = GetpApp(); 1351 aDDInfo.pSource = this; 1352 // aDDInfo.pDDStartEntry = pEntry; 1353 ::com::sun::star::uno::Sequence<sal_Int8> aSequence (sizeof(SvLBoxDDInfo)); 1354 memcpy(aSequence.getArray(), (sal_Char*)&aDDInfo, sizeof(SvLBoxDDInfo)); 1355 ::com::sun::star::uno::Any aTreeListBoxData (aSequence); 1356 1357 // object is destroyed by internal reference mechanism 1358 SdTransferable* pTransferable = new SdPageObjsTLB::SdPageObjsTransferable( 1359 *this, aBookmark, *pDocShell, eDragType, aTreeListBoxData); 1360 1361 // Get the view. 1362 ::sd::ViewShell* pViewShell = GetViewShellForDocShell(*pDocShell); 1363 if (pViewShell == NULL) 1364 { 1365 OSL_ASSERT(pViewShell!=NULL); 1366 return; 1367 } 1368 sd::View* pView = pViewShell->GetView(); 1369 if (pView == NULL) 1370 { 1371 OSL_ASSERT(pView!=NULL); 1372 return; 1373 } 1374 1375 SdrObject* pObject = NULL; 1376 void* pUserData = GetCurEntry()->GetUserData(); 1377 if (pUserData != NULL && pUserData != (void*)1) 1378 pObject = reinterpret_cast<SdrObject*>(pUserData); 1379 if (pObject != NULL) 1380 { 1381 // For shapes without a user supplied name (the automatically 1382 // created name does not count), a different drag and drop technique 1383 // is used. 1384 if (GetObjectName(pObject, false).Len() == 0) 1385 { 1386 AddShapeToTransferable(*pTransferable, *pObject); 1387 pTransferable->SetView(pView); 1388 SD_MOD()->pTransferDrag = pTransferable; 1389 } 1390 1391 // Unnamed shapes have to be selected to be recognized by the 1392 // current drop implementation. In order to have a consistent 1393 // behavior for all shapes, every shape that is to be dragged is 1394 // selected first. 1395 SdrPageView* pPageView = pView->GetSdrPageView(); 1396 pView->UnmarkAllObj(pPageView); 1397 pView->MarkObj(pObject, pPageView); 1398 } 1399 else 1400 { 1401 pTransferable->SetView(pView); 1402 SD_MOD()->pTransferDrag = pTransferable; 1403 } 1404 1405 pTransferable->StartDrag( this, nDNDActions ); 1406 } 1407 } 1408 1409 /************************************************************************* 1410 |* Drag finished 1411 \************************************************************************/ 1412 1413 void SdPageObjsTLB::OnDragFinished( sal_uInt8 ) 1414 { 1415 if( mpFrame->HasChildWindow( SID_NAVIGATOR ) ) 1416 { 1417 SdNavigatorWin* pNewNavWin = (SdNavigatorWin*) ( mpFrame->GetChildWindow( SID_NAVIGATOR )->GetContextWindow( SD_MOD() ) ); 1418 1419 if( mpDropNavWin == pNewNavWin) 1420 { 1421 MouseEvent aMEvt( mpDropNavWin->GetPointerPosPixel() ); 1422 SvTreeListBox::MouseButtonUp( aMEvt ); 1423 } 1424 } 1425 1426 mpDropNavWin = NULL; 1427 bIsInDrag = sal_False; 1428 } 1429 1430 /************************************************************************* 1431 |* AcceptDrop-Event 1432 \************************************************************************/ 1433 1434 sal_Int8 SdPageObjsTLB::AcceptDrop (const AcceptDropEvent& rEvent) 1435 { 1436 sal_Int8 nResult (DND_ACTION_NONE); 1437 1438 if ( !bIsInDrag && IsDropFormatSupported( FORMAT_FILE ) ) 1439 { 1440 nResult = rEvent.mnAction; 1441 } 1442 else 1443 { 1444 SvLBoxEntry* pEntry = GetDropTarget(rEvent.maPosPixel); 1445 if (rEvent.mbLeaving || !CheckDragAndDropMode( this, rEvent.mnAction )) 1446 { 1447 ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1448 } 1449 else if( !nDragDropMode ) 1450 { 1451 DBG_ERRORFILE( "SdPageObjsTLB::AcceptDrop(): no target" ); 1452 } 1453 else if (IsDropAllowed(pEntry)) 1454 { 1455 nResult = DND_ACTION_MOVE; 1456 1457 // Draw emphasis. 1458 if (pEntry != pTargetEntry || !(nImpFlags & SVLBOX_TARGEMPH_VIS)) 1459 { 1460 ImplShowTargetEmphasis( pTargetEntry, sal_False ); 1461 pTargetEntry = pEntry; 1462 ImplShowTargetEmphasis( pTargetEntry, sal_True ); 1463 } 1464 } 1465 } 1466 1467 // Hide emphasis when there is no valid drop action. 1468 if (nResult == DND_ACTION_NONE) 1469 ImplShowTargetEmphasis(pTargetEntry, sal_False); 1470 1471 return nResult; 1472 } 1473 1474 /************************************************************************* 1475 |* ExecuteDrop-Event 1476 \************************************************************************/ 1477 1478 sal_Int8 SdPageObjsTLB::ExecuteDrop( const ExecuteDropEvent& rEvt ) 1479 { 1480 sal_Int8 nRet = DND_ACTION_NONE; 1481 1482 try 1483 { 1484 if( !bIsInDrag ) 1485 { 1486 SdNavigatorWin* pNavWin = NULL; 1487 sal_uInt16 nId = SID_NAVIGATOR; 1488 1489 if( mpFrame->HasChildWindow( nId ) ) 1490 pNavWin = (SdNavigatorWin*)( mpFrame->GetChildWindow( nId )->GetContextWindow( SD_MOD() ) ); 1491 1492 if( pNavWin && ( pNavWin == mpParent ) ) 1493 { 1494 TransferableDataHelper aDataHelper( rEvt.maDropEvent.Transferable ); 1495 String aFile; 1496 1497 if( aDataHelper.GetString( FORMAT_FILE, aFile ) && 1498 ( (SdNavigatorWin*) mpParent)->InsertFile( aFile ) ) 1499 { 1500 nRet = rEvt.mnAction; 1501 } 1502 } 1503 } 1504 } 1505 catch (com::sun::star::uno::Exception&) 1506 { 1507 DBG_UNHANDLED_EXCEPTION(); 1508 } 1509 1510 if (nRet == DND_ACTION_NONE) 1511 SvTreeListBox::ExecuteDrop(rEvt, this); 1512 1513 return nRet; 1514 } 1515 1516 /************************************************************************* 1517 |* Handler for dragging 1518 \************************************************************************/ 1519 1520 IMPL_STATIC_LINK(SdPageObjsTLB, ExecDragHdl, void*, EMPTYARG) 1521 { 1522 // als Link, damit asynchron ohne ImpMouseMoveMsg auf dem Stack auch der 1523 // Navigator gelöscht werden darf 1524 pThis->DoDrag(); 1525 return 0; 1526 } 1527 1528 bool SdPageObjsTLB::PageBelongsToCurrentShow (const SdPage* pPage) const 1529 { 1530 // Return <TRUE/> as default when there is no custom show or when none 1531 // is used. The page does then belong to the standard show. 1532 bool bBelongsToShow = true; 1533 1534 if (mpDoc->getPresentationSettings().mbCustomShow) 1535 { 1536 // Get the current custom show. 1537 SdCustomShow* pCustomShow = NULL; 1538 List* pShowList = const_cast<SdDrawDocument*>(mpDoc)->GetCustomShowList(); 1539 if (pShowList != NULL) 1540 { 1541 sal_uLong nCurrentShowIndex = pShowList->GetCurPos(); 1542 void* pObject = pShowList->GetObject(nCurrentShowIndex); 1543 pCustomShow = static_cast<SdCustomShow*>(pObject); 1544 } 1545 1546 // Check whether the given page is part of that custom show. 1547 if (pCustomShow != NULL) 1548 { 1549 bBelongsToShow = false; 1550 sal_uLong nPageCount = pCustomShow->Count(); 1551 for (sal_uInt16 i=0; i<nPageCount && !bBelongsToShow; i++) 1552 if (pPage == static_cast<SdPage*>(pCustomShow->GetObject (i))) 1553 bBelongsToShow = true; 1554 } 1555 } 1556 1557 return bBelongsToShow; 1558 } 1559 1560 sal_Bool SdPageObjsTLB::NotifyMoving( 1561 SvLBoxEntry* pTarget, 1562 SvLBoxEntry* pEntry, 1563 SvLBoxEntry*& rpNewParent, 1564 sal_uLong& rNewChildPos) 1565 { 1566 SvLBoxEntry* pDestination = pTarget; 1567 while (GetParent(pDestination) != NULL && GetParent(GetParent(pDestination)) != NULL) 1568 pDestination = GetParent(pDestination); 1569 1570 SdrObject* pTargetObject = reinterpret_cast<SdrObject*>(pDestination->GetUserData()); 1571 SdrObject* pSourceObject = reinterpret_cast<SdrObject*>(pEntry->GetUserData()); 1572 if (pSourceObject == reinterpret_cast<SdrObject*>(1)) 1573 pSourceObject = NULL; 1574 1575 if (pTargetObject != NULL && pSourceObject != NULL) 1576 { 1577 SdrPage* pObjectList = pSourceObject->GetPage(); 1578 if (pObjectList != NULL) 1579 { 1580 sal_uInt32 nNewPosition; 1581 if (pTargetObject == reinterpret_cast<SdrObject*>(1)) 1582 nNewPosition = 0; 1583 else 1584 nNewPosition = pTargetObject->GetNavigationPosition() + 1; 1585 pObjectList->SetObjectNavigationPosition(*pSourceObject, nNewPosition); 1586 } 1587 1588 // Update the tree list. 1589 if (pTarget == NULL) 1590 { 1591 rpNewParent = 0; 1592 rNewChildPos = 0; 1593 return sal_True; 1594 } 1595 else if (GetParent(pDestination) == NULL) 1596 { 1597 rpNewParent = pDestination; 1598 rNewChildPos = 0; 1599 } 1600 else 1601 { 1602 rpNewParent = GetParent(pDestination); 1603 rNewChildPos = pModel->GetRelPos(pDestination) + 1; 1604 rNewChildPos += nCurEntrySelPos; 1605 nCurEntrySelPos++; 1606 } 1607 return sal_True; 1608 } 1609 else 1610 return sal_False; 1611 } 1612 1613 SvLBoxEntry* SdPageObjsTLB::GetDropTarget (const Point& rLocation) 1614 { 1615 SvLBoxEntry* pEntry = SvTreeListBox::GetDropTarget(rLocation); 1616 if (pEntry == NULL) 1617 return NULL; 1618 1619 if (GetParent(pEntry) == NULL) 1620 { 1621 // Use page entry as insertion position. 1622 } 1623 else 1624 { 1625 // Go to second hierarchy level, i.e. top level shapes, 1626 // i.e. children of pages. 1627 while (GetParent(pEntry) != NULL && GetParent(GetParent(pEntry)) != NULL) 1628 pEntry = GetParent(pEntry); 1629 1630 // Advance to next sibling. 1631 SvLBoxEntry* pNext; 1632 sal_uInt16 nDepth (0); 1633 while (pEntry != NULL) 1634 { 1635 pNext = dynamic_cast<SvLBoxEntry*>(NextVisible(pEntry, &nDepth)); 1636 if (pNext != NULL && nDepth > 0 && nDepth!=0xffff) 1637 pEntry = pNext; 1638 else 1639 break; 1640 } 1641 } 1642 1643 return pEntry; 1644 } 1645 1646 bool SdPageObjsTLB::IsDropAllowed (SvLBoxEntry* pEntry) 1647 { 1648 if (pEntry == NULL) 1649 return false; 1650 1651 if ( ! IsDropFormatSupported(SdPageObjsTransferable::GetListBoxDropFormatId())) 1652 return false; 1653 1654 if ((pEntry->GetFlags() & SV_ENTRYFLAG_DISABLE_DROP) != 0) 1655 return false; 1656 1657 return true; 1658 } 1659 1660 void SdPageObjsTLB::AddShapeToTransferable ( 1661 SdTransferable& rTransferable, 1662 SdrObject& rObject) const 1663 { 1664 TransferableObjectDescriptor aObjectDescriptor; 1665 bool bIsDescriptorFillingPending (true); 1666 1667 const SdrOle2Obj* pOleObject = dynamic_cast<const SdrOle2Obj*>(&rObject); 1668 if (pOleObject != NULL && pOleObject->GetObjRef().is()) 1669 { 1670 // If object has no persistence it must be copied as part of the document 1671 try 1672 { 1673 uno::Reference< embed::XEmbedPersist > xPersObj (pOleObject->GetObjRef(), uno::UNO_QUERY ); 1674 if (xPersObj.is() && xPersObj->hasEntry()) 1675 { 1676 SvEmbedTransferHelper::FillTransferableObjectDescriptor( 1677 aObjectDescriptor, 1678 pOleObject->GetObjRef(), 1679 pOleObject->GetGraphic(), 1680 pOleObject->GetAspect()); 1681 bIsDescriptorFillingPending = false; 1682 } 1683 } 1684 catch( uno::Exception& ) 1685 { 1686 } 1687 } 1688 1689 ::sd::DrawDocShell* pDocShell = mpDoc->GetDocSh(); 1690 if (bIsDescriptorFillingPending && pDocShell!=NULL) 1691 { 1692 bIsDescriptorFillingPending = false; 1693 pDocShell->FillTransferableObjectDescriptor(aObjectDescriptor); 1694 } 1695 1696 Point aDragPos (rObject.GetCurrentBoundRect().Center()); 1697 //Point aDragPos (0,0); 1698 aObjectDescriptor.maDragStartPos = aDragPos; 1699 // aObjectDescriptor.maSize = GetAllMarkedRect().GetSize(); 1700 if (pDocShell != NULL) 1701 aObjectDescriptor.maDisplayName = pDocShell->GetMedium()->GetURLObject().GetURLNoPass(); 1702 else 1703 aObjectDescriptor.maDisplayName = String(); 1704 aObjectDescriptor.mbCanLink = sal_False; 1705 1706 rTransferable.SetStartPos(aDragPos); 1707 rTransferable.SetObjectDescriptor( aObjectDescriptor ); 1708 } 1709 1710 ::sd::ViewShell* SdPageObjsTLB::GetViewShellForDocShell (::sd::DrawDocShell& rDocShell) 1711 { 1712 { 1713 ::sd::ViewShell* pViewShell = rDocShell.GetViewShell(); 1714 if (pViewShell != NULL) 1715 return pViewShell; 1716 } 1717 1718 try 1719 { 1720 // Get a component enumeration from the desktop and search it for documents. 1721 uno::Reference<lang::XMultiServiceFactory> xFactory ( 1722 ::comphelper::getProcessServiceFactory ()); 1723 if ( ! xFactory.is()) 1724 return NULL; 1725 1726 uno::Reference<frame::XDesktop> xDesktop (xFactory->createInstance ( 1727 ::rtl::OUString::createFromAscii("com.sun.star.frame.Desktop")), uno::UNO_QUERY); 1728 if ( ! xDesktop.is()) 1729 return NULL; 1730 1731 uno::Reference<frame::XFramesSupplier> xFrameSupplier (xDesktop, uno::UNO_QUERY); 1732 if ( ! xFrameSupplier.is()) 1733 return NULL; 1734 1735 uno::Reference<container::XIndexAccess> xFrameAccess (xFrameSupplier->getFrames(), uno::UNO_QUERY); 1736 if ( ! xFrameAccess.is()) 1737 return NULL; 1738 1739 for (sal_Int32 nIndex=0,nCount=xFrameAccess->getCount(); nIndex<nCount; ++nIndex) 1740 { 1741 uno::Reference<frame::XFrame> xFrame; 1742 if ( ! (xFrameAccess->getByIndex(nIndex) >>= xFrame)) 1743 continue; 1744 1745 ::sd::DrawController* pController = dynamic_cast<sd::DrawController*>(xFrame->getController().get()); 1746 if (pController == NULL) 1747 continue; 1748 ::sd::ViewShellBase* pBase = pController->GetViewShellBase(); 1749 if (pBase == NULL) 1750 continue; 1751 if (pBase->GetDocShell() != &rDocShell) 1752 continue; 1753 1754 const ::boost::shared_ptr<sd::ViewShell> pViewShell (pBase->GetMainViewShell()); 1755 if (pViewShell) 1756 return pViewShell.get(); 1757 } 1758 } 1759 catch (uno::Exception e) 1760 { 1761 // When there is an exception then simply use the default value of 1762 // bIsEnabled and disable the controls. 1763 } 1764 return NULL; 1765 } 1766 1767 //===== IconProvider ========================================================== 1768 1769 SdPageObjsTLB::IconProvider::IconProvider (void) 1770 : maImgPage( BitmapEx( SdResId( BMP_PAGE ) ) ), 1771 maImgPageExcl( BitmapEx( SdResId( BMP_PAGE_EXCLUDED ) ) ), 1772 maImgPageObjsExcl( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED ) ) ), 1773 maImgPageObjs( BitmapEx( SdResId( BMP_PAGEOBJS ) ) ), 1774 maImgObjects( BitmapEx( SdResId( BMP_OBJECTS ) ) ), 1775 maImgGroup( BitmapEx( SdResId( BMP_GROUP ) ) ), 1776 1777 maImgPageH( BitmapEx( SdResId( BMP_PAGE_H ) ) ), 1778 maImgPageExclH( BitmapEx( SdResId( BMP_PAGE_EXCLUDED_H ) ) ), 1779 maImgPageObjsExclH( BitmapEx( SdResId( BMP_PAGEOBJS_EXCLUDED_H ) ) ), 1780 maImgPageObjsH( BitmapEx( SdResId( BMP_PAGEOBJS_H ) ) ), 1781 maImgObjectsH( BitmapEx( SdResId( BMP_OBJECTS_H ) ) ), 1782 maImgGroupH( BitmapEx( SdResId( BMP_GROUP_H ) ) ) 1783 { 1784 } 1785 1786 /* vim: set noet sw=4 ts=4: */ 1787