1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #ifndef _SVSTDARR_HXX 28 #define _SVSTDARR_STRINGSDTOR 29 #include <svl/svstdarr.hxx> 30 #endif 31 #include <svl/urlbmk.hxx> 32 #include <tools/urlobj.hxx> 33 #include <sfx2/docfile.hxx> 34 #include <sfx2/dispatch.hxx> 35 #include <vcl/help.hxx> 36 #include <sot/formats.hxx> 37 #include <vcl/sound.hxx> 38 #include <uiitems.hxx> 39 #include <fmtinfmt.hxx> 40 #include <txtinet.hxx> 41 #include <fmtfld.hxx> 42 #include <swmodule.hxx> 43 #include <wrtsh.hxx> 44 #include <view.hxx> 45 #include <errhdl.hxx> 46 #include <docsh.hxx> 47 #include <content.hxx> 48 #include <frmfmt.hxx> 49 #include <fldbas.hxx> 50 #include <txtatr.hxx> 51 #include <IMark.hxx> 52 #include <section.hxx> 53 #include <tox.hxx> 54 #define NAVIPI_CXX 55 #include <navipi.hxx> 56 #include <navicont.hxx> 57 #include <navicfg.hxx> 58 #include <edtwin.hxx> 59 #include <doc.hxx> 60 #include <unotools.hxx> 61 #include <crsskip.hxx> 62 #include <cmdid.h> 63 #include <helpid.h> 64 #include <navipi.hrc> 65 #include <utlui.hrc> 66 #include <misc.hrc> 67 #include <comcore.hrc> 68 #include <com/sun/star/text/XTextSectionsSupplier.hpp> 69 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp> 70 #include <com/sun/star/text/XTextTablesSupplier.hpp> 71 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp> 72 #include <com/sun/star/text/XDocumentIndex.hpp> 73 #include <com/sun/star/text/XBookmarksSupplier.hpp> 74 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp> 75 #include <com/sun/star/text/XTextFramesSupplier.hpp> 76 #include <dcontact.hxx> 77 #include <svx/svdogrp.hxx> 78 #include <svx/svdmodel.hxx> 79 #include <svx/svdpage.hxx> 80 #include <svx/svdview.hxx> 81 #include <vcl/scrbar.hxx> 82 #include <comcore.hrc> 83 #include <SwRewriter.hxx> 84 #include <hints.hxx> 85 #include <numrule.hxx> 86 #include <swundo.hxx> 87 #include <ndtxt.hxx> 88 //#include <ndgrf.hxx> 89 #include <fmtcntnt.hxx> 90 #include <PostItMgr.hxx> 91 //#include <../../core/inc/flyfrm.hxx> 92 //#include <../../core/inc/cntfrm.hxx> 93 //#include <ndnotxt.hxx> 94 //#include <postit.hxx> 95 #include <postithelper.hxx> 96 #include <redline.hxx> 97 #include <docary.hxx> 98 99 #include "swabstdlg.hxx" 100 #include "globals.hrc" 101 #include <unomid.h> 102 103 104 #define CTYPE_CNT 0 105 #define CTYPE_CTT 1 106 107 using namespace ::std; 108 using namespace ::com::sun::star; 109 using namespace ::com::sun::star::text; 110 using namespace ::com::sun::star::uno; 111 using namespace ::com::sun::star::container; 112 113 114 #define NAVI_BOOKMARK_DELIM (sal_Unicode)1 115 116 /*************************************************************************** 117 118 ***************************************************************************/ 119 120 typedef SwContent* SwContentPtr; 121 SV_DECL_PTRARR_SORT_DEL( SwContentArr, SwContentPtr, 0,4) 122 SV_IMPL_OP_PTRARR_SORT(SwContentArr, SwContentPtr) 123 124 sal_Bool SwContentTree::bIsInDrag = sal_False; 125 126 127 namespace 128 { 129 static sal_Bool lcl_IsContent(SvLBoxEntry* pEntry) 130 { 131 return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CNT; 132 } 133 134 135 static sal_Bool lcl_IsContentType(SvLBoxEntry* pEntry) 136 { 137 return ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() == CTYPE_CTT; 138 } 139 140 141 static sal_Bool lcl_FindShell(SwWrtShell* pShell) 142 { 143 sal_Bool bFound = sal_False; 144 SwView *pView = SwModule::GetFirstView(); 145 while (pView) 146 { 147 if(pShell == &pView->GetWrtShell()) 148 { 149 bFound = sal_True; 150 break; 151 } 152 pView = SwModule::GetNextView(pView); 153 } 154 return bFound; 155 } 156 157 static bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark) 158 { 159 return IDocumentMarkAccess::GetType(*rpMark) == IDocumentMarkAccess::BOOKMARK; 160 } 161 } 162 163 /*************************************************************************** 164 Beschreibung: Inhalt, enthaelt Namen und Verweis auf den Inhalstyp 165 ***************************************************************************/ 166 167 168 SwContent::SwContent(const SwContentType* pCnt, const String& rName, long nYPos) : 169 SwTypeNumber(CTYPE_CNT), 170 pParent(pCnt), 171 sContentName(rName), 172 nYPosition(nYPos), 173 bInvisible(sal_False) 174 { 175 } 176 177 178 sal_uInt8 SwTypeNumber::GetTypeId() 179 { 180 return nTypeId; 181 } 182 183 SwTypeNumber::~SwTypeNumber() 184 { 185 } 186 187 sal_Bool SwContent::IsProtect() const 188 { 189 return sal_False; 190 } 191 192 sal_Bool SwPostItContent::IsProtect() const 193 { 194 if (mbPostIt) 195 return pFld->IsProtect(); 196 else 197 return false; 198 } 199 200 sal_Bool SwURLFieldContent::IsProtect() const 201 { 202 return pINetAttr->IsProtect(); 203 } 204 205 SwGraphicContent::~SwGraphicContent() 206 { 207 } 208 SwTOXBaseContent::~SwTOXBaseContent() 209 { 210 } 211 212 /*************************************************************************** 213 Beschreibung: Inhaltstyp, kennt seine Inhalte und die WrtShell 214 ***************************************************************************/ 215 216 217 SwContentType::SwContentType(SwWrtShell* pShell, sal_uInt16 nType, sal_uInt8 nLevel) : 218 SwTypeNumber(CTYPE_CTT), 219 pWrtShell(pShell), 220 pMember(0), 221 sContentTypeName(SW_RES(STR_CONTENT_TYPE_FIRST + nType)), 222 sSingleContentTypeName(SW_RES(STR_CONTENT_TYPE_SINGLE_FIRST + nType)), 223 nMemberCount(0), 224 nContentType(nType), 225 nOutlineLevel(nLevel), 226 bMemberFilled(sal_False), 227 bDataValid(sal_False), 228 bEdit(sal_False), 229 bDelete(sal_True) 230 { 231 Init(); 232 } 233 234 /*************************************************************************** 235 Beschreibung: Initialisierung 236 ***************************************************************************/ 237 238 239 void SwContentType::Init(sal_Bool* pbInvalidateWindow) 240 { 241 // wenn sich der MemberCount aendert ... 242 sal_uInt16 nOldMemberCount = nMemberCount; 243 nMemberCount = 0; 244 switch(nContentType) 245 { 246 case CONTENT_TYPE_OUTLINE : 247 { 248 sTypeToken = C2S(pMarkToOutline); 249 sal_uInt16 nOutlineCount = nMemberCount = 250 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()); 251 if(nOutlineLevel < MAXLEVEL) 252 { 253 for(sal_uInt16 j = 0; j < nOutlineCount; j++) 254 { 255 if(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(j) > nOutlineLevel ) 256 nMemberCount --; 257 } 258 } 259 bDelete = sal_False; 260 } 261 break; 262 263 case CONTENT_TYPE_TABLE : 264 sTypeToken = C2S(pMarkToTable); 265 nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True); 266 bEdit = sal_True; 267 break; 268 269 case CONTENT_TYPE_FRAME : 270 case CONTENT_TYPE_GRAPHIC : 271 case CONTENT_TYPE_OLE : 272 { 273 FlyCntType eType = FLYCNTTYPE_FRM; 274 sTypeToken = C2S(pMarkToFrame); 275 if(nContentType == CONTENT_TYPE_OLE) 276 { 277 eType = FLYCNTTYPE_OLE; 278 sTypeToken = C2S(pMarkToOLE); 279 } 280 else if(nContentType == CONTENT_TYPE_GRAPHIC) 281 { 282 eType = FLYCNTTYPE_GRF; 283 sTypeToken = C2S(pMarkToGraphic); 284 } 285 nMemberCount = pWrtShell->GetFlyCount(eType); 286 bEdit = sal_True; 287 } 288 break; 289 case CONTENT_TYPE_BOOKMARK: 290 { 291 IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess(); 292 nMemberCount = static_cast<sal_uInt16>(count_if( 293 pMarkAccess->getBookmarksBegin(), 294 pMarkAccess->getBookmarksEnd(), 295 &lcl_IsUiVisibleBookmark)); 296 sTypeToken = aEmptyStr; 297 bEdit = sal_True; 298 } 299 break; 300 case CONTENT_TYPE_REGION : 301 { 302 SwContentArr* pOldMember = 0; 303 sal_uInt16 nOldRegionCount = 0; 304 sal_Bool bInvalidate = sal_False; 305 if(!pMember) 306 pMember = new SwContentArr; 307 else if(pMember->Count()) 308 { 309 pOldMember = pMember; 310 nOldRegionCount = pOldMember->Count(); 311 pMember = new SwContentArr; 312 } 313 const Point aNullPt; 314 nMemberCount = pWrtShell->GetSectionFmtCount(); 315 for(sal_uInt16 i = 0; i < nMemberCount; i++) 316 { 317 const SwSectionFmt* pFmt; 318 SectionType eTmpType; 319 if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() && 320 (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION 321 && TOX_HEADER_SECTION != eTmpType ) 322 { 323 const String& rSectionName = 324 pFmt->GetSection()->GetSectionName(); 325 sal_uInt8 nLevel = 0; 326 SwSectionFmt* pParentFmt = pFmt->GetParent(); 327 while(pParentFmt) 328 { 329 nLevel++; 330 pParentFmt = pParentFmt->GetParent(); 331 } 332 333 SwContent* pCnt = new SwRegionContent(this, rSectionName, 334 nLevel, 335 pFmt->FindLayoutRect( sal_False, &aNullPt ).Top()); 336 337 SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 ); 338 if( !pFmt->GetInfo( aAskItem ) && 339 !aAskItem.pObject ) // not visible 340 pCnt->SetInvisible(); 341 pMember->Insert(pCnt);//, pMember->Count()); 342 343 sal_uInt16 nPos = pMember->Count() - 1; 344 if(nOldRegionCount > nPos && 345 (pOldMember->GetObject(nPos))->IsInvisible() 346 != pCnt->IsInvisible()) 347 bInvalidate = sal_True; 348 } 349 } 350 nMemberCount = pMember->Count(); 351 sTypeToken = C2S(pMarkToRegion); 352 bEdit = sal_True; 353 bDelete = sal_False; 354 if(pOldMember) 355 { 356 pOldMember->DeleteAndDestroy(0, pOldMember->Count()); 357 delete pOldMember; 358 if(pbInvalidateWindow && bInvalidate) 359 *pbInvalidateWindow = sal_True; 360 } 361 } 362 break; 363 case CONTENT_TYPE_INDEX: 364 { 365 nMemberCount = pWrtShell->GetTOXCount(); 366 bEdit = sal_True; 367 bDelete = sal_False; 368 } 369 break; 370 case CONTENT_TYPE_REFERENCE: 371 { 372 nMemberCount = pWrtShell->GetRefMarks( 0 ); 373 bDelete = sal_False; 374 } 375 break; 376 case CONTENT_TYPE_URLFIELD: 377 { 378 nMemberCount = 0; 379 if(!pMember) 380 pMember = new SwContentArr; 381 else if(pMember->Count()) 382 pMember->DeleteAndDestroy(0, pMember->Count()); 383 384 SwGetINetAttrs aArr; 385 nMemberCount = pWrtShell->GetINetAttrs( aArr ); 386 for( sal_uInt16 n = 0; n < nMemberCount; ++n ) 387 { 388 SwGetINetAttr* p = aArr[ n ]; 389 SwURLFieldContent* pCnt = new SwURLFieldContent( 390 this, 391 p->sText, 392 INetURLObject::decode( 393 p->rINetAttr.GetINetFmt().GetValue(), 394 INET_HEX_ESCAPE, 395 INetURLObject::DECODE_UNAMBIGUOUS, 396 RTL_TEXTENCODING_UTF8 ), 397 &p->rINetAttr, 398 n ); 399 pMember->Insert( pCnt );//, n ); 400 } 401 bEdit = sal_True; 402 nOldMemberCount = nMemberCount; 403 bDelete = sal_False; 404 } 405 break; 406 case CONTENT_TYPE_POSTIT: 407 { 408 nMemberCount = 0; 409 if(!pMember) 410 pMember = new SwContentArr; 411 else if(pMember->Count()) 412 pMember->DeleteAndDestroy(0, pMember->Count()); 413 414 SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr(); 415 if (aMgr) 416 { 417 for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) 418 { 419 if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit 420 { 421 SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster()); 422 if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && 423 (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) 424 { 425 String sEntry = aFmtFld->GetField()->GetPar2(); 426 RemoveNewline(sEntry); 427 SwPostItContent* pCnt = new SwPostItContent( 428 this, 429 sEntry, 430 (const SwFmtFld*)aFmtFld, 431 nMemberCount); 432 pMember->Insert(pCnt); 433 nMemberCount++; 434 } 435 } 436 } 437 } 438 // 439 sTypeToken = aEmptyStr; 440 bEdit = sal_True; 441 nOldMemberCount = nMemberCount; 442 } 443 break; 444 case CONTENT_TYPE_DRAWOBJECT: 445 { 446 sTypeToken = aEmptyStr; 447 nMemberCount = 0; 448 SdrModel* pModel = pWrtShell->getIDocumentDrawModelAccess()->GetDrawModel(); 449 if(pModel) 450 { 451 SdrPage* pPage = pModel->GetPage(0); 452 sal_uInt32 nCount = pPage->GetObjCount(); 453 for( sal_uInt32 i=0; i< nCount; i++ ) 454 { 455 SdrObject* pTemp = pPage->GetObj(i); 456 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now 457 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len()) 458 if ( pTemp->GetName().Len() ) 459 // <-- 460 nMemberCount++; 461 } 462 } 463 } 464 break; 465 } 466 // ... dann koennen die Daten auch nicht mehr gueltig sein 467 // abgesehen von denen, die schon korrigiert wurden, dann ist 468 // nOldMemberCount doch nicht so old 469 if( nOldMemberCount != nMemberCount ) 470 bDataValid = sal_False; 471 } 472 473 /*************************************************************************** 474 Beschreibung: 475 ***************************************************************************/ 476 477 478 SwContentType::~SwContentType() 479 { 480 delete pMember; 481 } 482 483 /*************************************************************************** 484 Beschreibung: Inhalt liefern, dazu gfs. die Liste fuellen 485 ***************************************************************************/ 486 487 488 const SwContent* SwContentType::GetMember(sal_uInt16 nIndex) 489 { 490 if(!bDataValid || !pMember) 491 { 492 FillMemberList(); 493 } 494 if(nIndex < pMember->Count()) 495 return pMember->GetObject(nIndex); 496 else 497 return 0; 498 499 } 500 501 502 /*************************************************************************** 503 Beschreibung: 504 ***************************************************************************/ 505 506 507 void SwContentType::Invalidate() 508 { 509 bDataValid = sal_False; 510 } 511 512 /*************************************************************************** 513 Beschreibung: Liste der Inhalte fuellen 514 ***************************************************************************/ 515 516 517 void SwContentType::FillMemberList(sal_Bool* pbLevelOrVisibiblityChanged) 518 { 519 SwContentArr* pOldMember = 0; 520 int nOldMemberCount = -1; 521 SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, 0 ); 522 if(pMember && pbLevelOrVisibiblityChanged) 523 { 524 pOldMember = pMember; 525 nOldMemberCount = pOldMember->Count(); 526 pMember = new SwContentArr; 527 *pbLevelOrVisibiblityChanged = sal_False; 528 } 529 else if(!pMember) 530 pMember = new SwContentArr; 531 else if(pMember->Count()) 532 pMember->DeleteAndDestroy(0, pMember->Count()); 533 switch(nContentType) 534 { 535 case CONTENT_TYPE_OUTLINE : 536 { 537 sal_uInt16 nOutlineCount = nMemberCount = 538 static_cast<sal_uInt16>(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()); 539 540 sal_uInt16 nPos = 0; 541 for (sal_uInt16 i = 0; i < nOutlineCount; ++i) 542 { 543 const sal_Int8 nLevel = (sal_Int8)pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineLevel(i); 544 if(nLevel >= nOutlineLevel ) 545 nMemberCount--; 546 else 547 { 548 String aEntry(pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(i)); 549 aEntry.EraseLeadingChars(); 550 SwNavigationPI::CleanEntry( aEntry ); 551 SwOutlineContent* pCnt = new SwOutlineContent(this, aEntry, i, nLevel, 552 pWrtShell->IsOutlineMovable( i ), nPos ); 553 pMember->Insert(pCnt);//, nPos); 554 // bei gleicher Anzahl und vorhandenem pOldMember wird die 555 // alte mit der neuen OutlinePos verglichen 556 // cast fuer Win16 557 if(nOldMemberCount > (int)nPos && 558 ((SwOutlineContent*)pOldMember->GetObject(nPos))->GetOutlineLevel() != nLevel) 559 *pbLevelOrVisibiblityChanged = sal_True; 560 561 nPos++; 562 } 563 } 564 565 } 566 break; 567 568 case CONTENT_TYPE_TABLE : 569 { 570 DBG_ASSERT(nMemberCount == 571 pWrtShell->GetTblFrmFmtCount(sal_True), 572 "MemberCount differiert"); 573 Point aNullPt; 574 nMemberCount = pWrtShell->GetTblFrmFmtCount(sal_True); 575 for(sal_uInt16 i = 0; i < nMemberCount; i++) 576 { 577 const SwFrmFmt& rTblFmt = pWrtShell->GetTblFrmFmt(i, sal_True); 578 String sTblName( rTblFmt.GetName() ); 579 580 SwContent* pCnt = new SwContent(this, sTblName, 581 rTblFmt.FindLayoutRect(sal_False, &aNullPt).Top() ); 582 if( !rTblFmt.GetInfo( aAskItem ) && 583 !aAskItem.pObject ) // not visible 584 pCnt->SetInvisible(); 585 586 pMember->Insert(pCnt);//, i); 587 588 if(nOldMemberCount > (int)i && 589 (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible()) 590 *pbLevelOrVisibiblityChanged = sal_True; 591 } 592 } 593 break; 594 case CONTENT_TYPE_OLE : 595 case CONTENT_TYPE_FRAME : 596 case CONTENT_TYPE_GRAPHIC : 597 { 598 FlyCntType eType = FLYCNTTYPE_FRM; 599 if(nContentType == CONTENT_TYPE_OLE) 600 eType = FLYCNTTYPE_OLE; 601 else if(nContentType == CONTENT_TYPE_GRAPHIC) 602 eType = FLYCNTTYPE_GRF; 603 DBG_ASSERT(nMemberCount == pWrtShell->GetFlyCount(eType), 604 "MemberCount differiert"); 605 Point aNullPt; 606 nMemberCount = pWrtShell->GetFlyCount(eType); 607 for(sal_uInt16 i = 0; i < nMemberCount; i++) 608 { 609 const SwFrmFmt* pFrmFmt = pWrtShell->GetFlyNum(i,eType); 610 String sFrmName = pFrmFmt->GetName(); 611 612 SwContent* pCnt; 613 if(CONTENT_TYPE_GRAPHIC == nContentType) 614 { 615 String sLink; 616 pWrtShell->GetGrfNms( &sLink, 0, (SwFlyFrmFmt*) pFrmFmt); 617 pCnt = new SwGraphicContent(this, sFrmName, 618 INetURLObject::decode( sLink, INET_HEX_ESCAPE, 619 INetURLObject::DECODE_UNAMBIGUOUS, 620 RTL_TEXTENCODING_UTF8 ), 621 pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top()); 622 } 623 else 624 { 625 pCnt = new SwContent(this, sFrmName, 626 pFrmFmt->FindLayoutRect(sal_False, &aNullPt).Top() ); 627 } 628 if( !pFrmFmt->GetInfo( aAskItem ) && 629 !aAskItem.pObject ) // not visible 630 pCnt->SetInvisible(); 631 pMember->Insert(pCnt);//, i); 632 if(nOldMemberCount > (int)i && 633 (pOldMember->GetObject(i))->IsInvisible() != pCnt->IsInvisible()) 634 *pbLevelOrVisibiblityChanged = sal_True; 635 } 636 } 637 break; 638 case CONTENT_TYPE_BOOKMARK: 639 { 640 IDocumentMarkAccess* const pMarkAccess = pWrtShell->getIDocumentMarkAccess(); 641 for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin(); 642 ppBookmark != pMarkAccess->getBookmarksEnd(); 643 ppBookmark++) 644 { 645 if(lcl_IsUiVisibleBookmark(*ppBookmark)) 646 { 647 const String& rBkmName = ppBookmark->get()->GetName(); 648 //nYPos von 0 -> text::Bookmarks werden nach Alphabet sortiert 649 SwContent* pCnt = new SwContent(this, rBkmName, 0); 650 pMember->Insert(pCnt);//, pMember->Count()); 651 } 652 } 653 } 654 break; 655 case CONTENT_TYPE_REGION : 656 { 657 const Point aNullPt; 658 nMemberCount = pWrtShell->GetSectionFmtCount(); 659 for(sal_uInt16 i = 0; i < nMemberCount; i++) 660 { 661 const SwSectionFmt* pFmt; 662 SectionType eTmpType; 663 if( (pFmt = &pWrtShell->GetSectionFmt(i))->IsInNodesArr() && 664 (eTmpType = pFmt->GetSection()->GetType()) != TOX_CONTENT_SECTION 665 && TOX_HEADER_SECTION != eTmpType ) 666 { 667 String sSectionName = pFmt->GetSection()->GetSectionName(); 668 669 sal_uInt8 nLevel = 0; 670 SwSectionFmt* pParentFmt = pFmt->GetParent(); 671 while(pParentFmt) 672 { 673 nLevel++; 674 pParentFmt = pParentFmt->GetParent(); 675 } 676 677 SwContent* pCnt = new SwRegionContent(this, sSectionName, 678 nLevel, 679 pFmt->FindLayoutRect( sal_False, &aNullPt ).Top()); 680 if( !pFmt->GetInfo( aAskItem ) && 681 !aAskItem.pObject ) // not visible 682 pCnt->SetInvisible(); 683 pMember->Insert(pCnt);//, pMember->Count()); 684 685 sal_uInt16 nPos = pMember->Count() - 1; 686 if(nOldMemberCount > nPos && 687 (pOldMember->GetObject(nPos))->IsInvisible() 688 != pCnt->IsInvisible()) 689 *pbLevelOrVisibiblityChanged = sal_True; 690 } 691 } 692 nMemberCount = pMember->Count(); 693 } 694 break; 695 case CONTENT_TYPE_REFERENCE: 696 { 697 SvStringsDtor aRefMarks; 698 nMemberCount = pWrtShell->GetRefMarks( &aRefMarks ); 699 700 for(sal_uInt16 i=0; i<nMemberCount; i++) 701 { 702 //Referenzen nach Alphabet sortiert 703 SwContent* pCnt = new SwContent( 704 this, *aRefMarks.GetObject(i), 0); 705 pMember->Insert(pCnt);//, i); 706 } 707 } 708 break; 709 case CONTENT_TYPE_URLFIELD: 710 { 711 SwGetINetAttrs aArr; 712 nMemberCount = pWrtShell->GetINetAttrs( aArr ); 713 for( sal_uInt16 n = 0; n < nMemberCount; ++n ) 714 { 715 SwGetINetAttr* p = aArr[ n ]; 716 SwURLFieldContent* pCnt = new SwURLFieldContent( 717 this, 718 p->sText, 719 INetURLObject::decode( 720 p->rINetAttr.GetINetFmt().GetValue(), 721 INET_HEX_ESCAPE, 722 INetURLObject::DECODE_UNAMBIGUOUS, 723 RTL_TEXTENCODING_UTF8 ), 724 &p->rINetAttr, 725 n ); 726 pMember->Insert( pCnt );//, n ); 727 } 728 } 729 break; 730 case CONTENT_TYPE_INDEX: 731 { 732 733 sal_uInt16 nCount = nMemberCount = pWrtShell->GetTOXCount(); 734 for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ ) 735 { 736 const SwTOXBase* pBase = pWrtShell->GetTOX( nTox ); 737 String sTOXNm( pBase->GetTOXName() ); 738 739 SwContent* pCnt = new SwTOXBaseContent( 740 this, sTOXNm, nTox, *pBase); 741 742 if( !pBase->GetInfo( aAskItem ) && 743 !aAskItem.pObject ) // not visible 744 pCnt->SetInvisible(); 745 746 pMember->Insert( pCnt );//, nTox ); 747 sal_uInt16 nPos = pMember->Count() - 1; 748 if(nOldMemberCount > nPos && 749 (pOldMember->GetObject(nPos))->IsInvisible() 750 != pCnt->IsInvisible()) 751 *pbLevelOrVisibiblityChanged = sal_True; 752 } 753 } 754 break; 755 case CONTENT_TYPE_POSTIT: 756 { 757 nMemberCount = 0; 758 if(!pMember) 759 pMember = new SwContentArr; 760 else if(pMember->Count()) 761 pMember->DeleteAndDestroy(0, pMember->Count()); 762 SwPostItMgr* aMgr = pWrtShell->GetView().GetPostItMgr(); 763 if (aMgr) 764 { 765 for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i) 766 { 767 if ( (*i)->GetBroadCaster()->ISA(SwFmtFld)) // SwPostit 768 { 769 SwFmtFld* aFmtFld = static_cast<SwFmtFld*>((*i)->GetBroadCaster()); 770 if (aFmtFld->GetTxtFld() && aFmtFld->IsFldInDoc() && 771 (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE ) 772 { 773 String sEntry = aFmtFld->GetField()->GetPar2(); 774 RemoveNewline(sEntry); 775 SwPostItContent* pCnt = new SwPostItContent( 776 this, 777 sEntry, 778 (const SwFmtFld*)aFmtFld, 779 nMemberCount); 780 pMember->Insert(pCnt); 781 nMemberCount++; 782 } 783 } 784 /* this code can be used once we want redline comments in the margin 785 else // redcomment 786 { 787 SwRedline* pRedline = static_cast<SwRedline*>((*i)->GetBroadCaster()); 788 if ( pRedline->GetComment() != String(::rtl::OUString::createFromAscii("")) ) 789 { 790 String sEntry = pRedline->GetComment(); 791 RemoveNewline(sEntry); 792 SwPostItContent* pCnt = new SwPostItContent( 793 this, 794 sEntry, 795 pRedline, 796 nMemberCount); 797 pMember->Insert(pCnt); 798 nMemberCount++; 799 } 800 } 801 */ 802 } 803 } 804 // 805 } 806 break; 807 case CONTENT_TYPE_DRAWOBJECT: 808 { 809 nMemberCount = 0; 810 if(!pMember) 811 pMember = new SwContentArr; 812 else if(pMember->Count()) 813 pMember->DeleteAndDestroy(0, pMember->Count()); 814 815 IDocumentDrawModelAccess* pIDDMA = pWrtShell->getIDocumentDrawModelAccess(); 816 SdrModel* pModel = pIDDMA->GetDrawModel(); 817 if(pModel) 818 { 819 SdrPage* pPage = pModel->GetPage(0); 820 sal_uInt32 nCount = pPage->GetObjCount(); 821 for( sal_uInt32 i=0; i< nCount; i++ ) 822 { 823 SdrObject* pTemp = pPage->GetObj(i); 824 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now 825 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName().Len()) 826 if ( pTemp->GetName().Len() ) 827 // <-- 828 { 829 SwContact* pContact = (SwContact*)pTemp->GetUserCall(); 830 long nYPos = 0; 831 const Point aNullPt; 832 if(pContact && pContact->GetFmt()) 833 nYPos = pContact->GetFmt()->FindLayoutRect(sal_False, &aNullPt).Top(); 834 SwContent* pCnt = new SwContent( 835 this, 836 pTemp->GetName(), 837 nYPos); 838 if(!pIDDMA->IsVisibleLayerId(pTemp->GetLayer())) 839 pCnt->SetInvisible(); 840 pMember->Insert(pCnt); 841 nMemberCount++; 842 if(nOldMemberCount > (int)i && 843 (pOldMember->GetObject((sal_uInt16)i))->IsInvisible() != pCnt->IsInvisible()) 844 *pbLevelOrVisibiblityChanged = sal_True; 845 } 846 } 847 } 848 } 849 break; 850 } 851 bDataValid = sal_True; 852 if(pOldMember) 853 pOldMember->DeleteAndDestroy(0, pOldMember->Count()); 854 855 } 856 857 /*************************************************************************** 858 Beschreibung: TreeListBox fuer Inhaltsanzeige 859 ***************************************************************************/ 860 861 862 SwContentTree::SwContentTree(Window* pParent, const ResId& rResId) : 863 SvTreeListBox( pParent, rResId ), 864 865 sSpace(C2S(" ")), 866 867 sRemoveIdx(SW_RES(ST_REMOVE_INDEX)), 868 sUpdateIdx(SW_RES(ST_UPDATE)), 869 sUnprotTbl(SW_RES(ST_REMOVE_TBL_PROTECTION)), 870 sRename(SW_RES(ST_RENAME)), 871 sReadonlyIdx(SW_RES(ST_READONLY_IDX)), 872 sInvisible(SW_RES(ST_INVISIBLE)), 873 874 sPostItShow(SW_RES(ST_POSTIT_SHOW)), 875 sPostItHide(SW_RES(ST_POSTIT_HIDE)), 876 sPostItDelete(SW_RES(ST_POSTIT_DELETE)), 877 878 pHiddenShell(0), 879 pActiveShell(0), 880 pConfig(SW_MOD()->GetNavigationConfig()), 881 882 nActiveBlock(0), 883 nHiddenBlock(0), 884 885 nRootType(USHRT_MAX), 886 nLastSelType(USHRT_MAX), 887 nOutlineLevel(MAXLEVEL), 888 889 bIsActive(sal_True), 890 bIsConstant(sal_False), 891 bIsHidden(sal_False), 892 bDocChgdInDragging(sal_False), 893 bIsInternalDrag(sal_False), 894 bIsRoot(sal_False), 895 bIsIdleClear(sal_False), 896 bIsLastReadOnly(sal_False), 897 bIsOutlineMoveable(sal_True), 898 bViewHasChanged(sal_False), 899 bIsImageListInitialized(sal_False), 900 bIsKeySpace(sal_False){ 901 sal_uInt16 i; 902 903 SetHelpId(HID_NAVIGATOR_TREELIST); 904 905 SetNodeDefaultImages(); 906 SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl)); 907 SetDragDropMode(SV_DRAGDROP_APP_COPY); 908 for( i = 0; i < CONTENT_TYPE_MAX; i++) 909 { 910 aActiveContentArr[i] = 0; 911 aHiddenContentArr[i] = 0; 912 } 913 for( i = 0; i < CONTEXT_COUNT; i++ ) 914 { 915 aContextStrings[i] = SW_RESSTR(i+ST_CONTEXT_FIRST); 916 } 917 nActiveBlock = pConfig->GetActiveBlock(); 918 aUpdTimer.SetTimeoutHdl(LINK(this, SwContentTree, TimerUpdate)); 919 aUpdTimer.SetTimeout(1000); 920 Clear(); 921 EnableContextMenuHandling(); 922 SetStyle( GetStyle() | WB_QUICK_SEARCH ); 923 } 924 925 /*************************************************************************** 926 Beschreibung: 927 ***************************************************************************/ 928 929 930 SwContentTree::~SwContentTree() 931 { 932 Clear(); // vorher gfs. Inhaltstypen loeschen 933 bIsInDrag = sal_False; 934 } 935 936 String SwContentTree::GetEntryAltText( SvLBoxEntry* pEntry ) const 937 { 938 if( pEntry == NULL) 939 return String(); 940 941 SwContent* pCnt = (SwContent*)pEntry->GetUserData(); 942 if( pCnt == NULL || pCnt->GetParent() == NULL) 943 return String(); 944 945 sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); 946 SdrObject* pTemp; 947 948 switch(nJumpType) 949 { 950 case CONTENT_TYPE_DRAWOBJECT: 951 { 952 SdrView* pDrawView = pActiveShell->GetDrawView(); 953 if (pDrawView) 954 { 955 SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); 956 SdrPage* pPage = pDrawModel->GetPage(0); 957 const sal_uInt32 nCount = pPage->GetObjCount(); 958 for( sal_uInt32 i=0; i< nCount; i++ ) 959 { 960 pTemp = pPage->GetObj(i); 961 sal_uInt16 nCmpId; 962 switch( pTemp->GetObjIdentifier() ) 963 { 964 case OBJ_GRUP: 965 case OBJ_TEXT: 966 case OBJ_TEXTEXT: 967 case OBJ_wegFITTEXT: 968 case OBJ_LINE: 969 case OBJ_RECT: 970 //caoxueqin added custom shape 971 case OBJ_CUSTOMSHAPE: 972 //end 2005/08/05 973 case OBJ_CIRC: 974 case OBJ_SECT: 975 case OBJ_CARC: 976 case OBJ_CCUT: 977 case OBJ_POLY: 978 case OBJ_PLIN: 979 case OBJ_PATHLINE: 980 case OBJ_PATHFILL: 981 case OBJ_FREELINE: 982 case OBJ_FREEFILL: 983 case OBJ_PATHPOLY: 984 case OBJ_PATHPLIN: 985 case OBJ_CAPTION: 986 nCmpId = OBJ_GRUP; 987 break; 988 default: 989 nCmpId = pTemp->GetObjIdentifier(); 990 } 991 if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName()) 992 { 993 return pTemp->GetTitle(); 994 } 995 //Commented End 996 } 997 } 998 } 999 break; 1000 case CONTENT_TYPE_GRAPHIC : 1001 { 1002 if( pActiveShell && pActiveShell->GetDoc() ) 1003 { 1004 const SwFlyFrmFmt* pFrmFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0); 1005 if( pFrmFmt ) 1006 { 1007 // SwNodeIndex aIdx( *(pFrmFmt->GetCntnt().GetCntntIdx()), 1 ); 1008 // const SwGrfNode* pGrfNd = aIdx.GetNode().GetGrfNode(); 1009 // if( pGrfNd ) 1010 // return pGrfNd->GetAlternateText(); 1011 return pFrmFmt->GetObjTitle(); 1012 } 1013 } 1014 } 1015 break; 1016 case CONTENT_TYPE_OLE : 1017 case CONTENT_TYPE_FRAME : 1018 { 1019 //Can't find the GetAlternateText function. Need to verify again. 1020 const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0); 1021 if( pFlyFmt ) 1022 return pFlyFmt->/*GetAlternateText*/GetName(); 1023 } 1024 break; 1025 } 1026 return String(); 1027 } 1028 1029 String SwContentTree::GetEntryLongDescription( SvLBoxEntry* pEntry ) const 1030 { 1031 if( pEntry == NULL) 1032 return String(); 1033 1034 SwContent* pCnt = (SwContent*)pEntry->GetUserData(); 1035 if( pCnt == NULL || pCnt->GetParent() == NULL) 1036 return String(); 1037 1038 sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); 1039 SdrObject* pTemp; 1040 1041 switch(nJumpType) 1042 { 1043 case CONTENT_TYPE_DRAWOBJECT: 1044 { 1045 SdrView* pDrawView = pActiveShell->GetDrawView(); 1046 if (pDrawView) 1047 { 1048 SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); 1049 SdrPage* pPage = pDrawModel->GetPage(0); 1050 sal_uInt32 nCount = pPage->GetObjCount(); 1051 for( sal_uInt32 i=0; i< nCount; i++ ) 1052 { 1053 pTemp = pPage->GetObj(i); 1054 sal_uInt16 nCmpId; 1055 switch( pTemp->GetObjIdentifier() ) 1056 { 1057 case OBJ_GRUP: 1058 case OBJ_TEXT: 1059 case OBJ_TEXTEXT: 1060 case OBJ_wegFITTEXT: 1061 case OBJ_LINE: 1062 case OBJ_RECT: 1063 //caoxueqin added custom shape 1064 case OBJ_CUSTOMSHAPE: 1065 //end 2005/08/05 1066 case OBJ_CIRC: 1067 case OBJ_SECT: 1068 case OBJ_CARC: 1069 case OBJ_CCUT: 1070 case OBJ_POLY: 1071 case OBJ_PLIN: 1072 case OBJ_PATHLINE: 1073 case OBJ_PATHFILL: 1074 case OBJ_FREELINE: 1075 case OBJ_FREEFILL: 1076 case OBJ_PATHPOLY: 1077 case OBJ_PATHPLIN: 1078 case OBJ_CAPTION: 1079 nCmpId = OBJ_GRUP; 1080 break; 1081 default: 1082 nCmpId = pTemp->GetObjIdentifier(); 1083 } 1084 if(nCmpId == OBJ_GRUP /*pTemp->ISA(SdrObjGroup)*/ && pTemp->GetName() == pCnt->GetName()) 1085 { 1086 return pTemp->GetDescription(); 1087 } 1088 //Commented End 1089 } 1090 } 1091 } 1092 break; 1093 case CONTENT_TYPE_GRAPHIC : 1094 case CONTENT_TYPE_OLE : 1095 case CONTENT_TYPE_FRAME : 1096 { 1097 //Can't find the function "GetLongDescription". Need to verify again. 1098 const SwFlyFrmFmt* pFlyFmt = pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName(), 0); 1099 if( pFlyFmt ) 1100 return pFlyFmt->GetDescription(); 1101 } 1102 break; 1103 } 1104 return String(); 1105 } 1106 1107 /*************************************************************************** 1108 Drag&Drop methods 1109 ***************************************************************************/ 1110 1111 void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel ) 1112 { 1113 if( !bIsRoot || nRootType != CONTENT_TYPE_OUTLINE ) 1114 { 1115 ReleaseMouse(); 1116 1117 TransferDataContainer* pContainer = new TransferDataContainer; 1118 uno::Reference< 1119 datatransfer::XTransferable > xRef( pContainer ); 1120 1121 sal_Int8 nDragMode = DND_ACTION_COPYMOVE | DND_ACTION_LINK; 1122 if( FillTransferData( *pContainer, nDragMode )) 1123 { 1124 SwContentTree::SetInDrag(sal_True); 1125 pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() ); 1126 } 1127 } 1128 else 1129 SvTreeListBox::StartDrag( nAction, rPosPixel ); 1130 } 1131 1132 void SwContentTree::DragFinished( sal_Int8 nAction ) 1133 { 1134 //to prevent the removing of the selected entry in external drag and drop 1135 // the drag action mustn't be MOVE 1136 SvTreeListBox::DragFinished( bIsInternalDrag ? nAction : DND_ACTION_COPY ); 1137 SwContentTree::SetInDrag(sal_False); 1138 bIsInternalDrag = sal_False; 1139 } 1140 1141 /*************************************************************************** 1142 Beschreibung: QueryDrop wird im Navigator ausgefuehrt 1143 ***************************************************************************/ 1144 sal_Int8 SwContentTree::AcceptDrop( const AcceptDropEvent& rEvt ) 1145 { 1146 sal_Int8 nRet = DND_ACTION_NONE; 1147 if( bIsRoot ) 1148 { 1149 if( bIsOutlineMoveable ) 1150 nRet = SvTreeListBox::AcceptDrop( rEvt ); 1151 } 1152 else if( !bIsInDrag ) 1153 nRet = GetParentWindow()->AcceptDrop( rEvt ); 1154 return nRet; 1155 } 1156 1157 /*************************************************************************** 1158 Beschreibung: Drop wird im Navigator ausgefuehrt 1159 ***************************************************************************/ 1160 sal_Int8 SwContentTree::ExecuteDrop( const ExecuteDropEvent& rEvt ) 1161 { 1162 if( bIsRoot ) 1163 return SvTreeListBox::ExecuteDrop( rEvt ); 1164 return bIsInDrag ? DND_ACTION_NONE : GetParentWindow()->ExecuteDrop(rEvt); 1165 } 1166 1167 1168 /*************************************************************************** 1169 Beschreibung: Handler fuer Dragging und ContextMenu 1170 ***************************************************************************/ 1171 PopupMenu* SwContentTree::CreateContextMenu( void ) 1172 { 1173 PopupMenu* pPop = new PopupMenu; 1174 PopupMenu* pSubPop1 = new PopupMenu; 1175 PopupMenu* pSubPop2 = new PopupMenu; 1176 PopupMenu* pSubPop3 = new PopupMenu; 1177 PopupMenu* pSubPop4 = new PopupMenu; // Edit 1178 1179 sal_uInt16 i; 1180 for(i = 1; i <= MAXLEVEL; i++ ) 1181 { 1182 pSubPop1->InsertItem( i + 100, String::CreateFromInt32(i)); 1183 } 1184 pSubPop1->CheckItem(100 + nOutlineLevel); 1185 for(i=0; i < 3; i++ ) 1186 { 1187 pSubPop2->InsertItem( i + 201, aContextStrings[ 1188 ST_HYPERLINK - ST_CONTEXT_FIRST + i]); 1189 } 1190 pSubPop2->CheckItem( 201 + 1191 GetParentWindow()->GetRegionDropMode()); 1192 //Liste der offenen Dateien einfuegen 1193 sal_uInt16 nId = 301; 1194 const SwView* pActiveView = ::GetActiveView(); 1195 SwView *pView = SwModule::GetFirstView(); 1196 while (pView) 1197 { 1198 String sInsert = pView->GetDocShell()->GetTitle(); 1199 if(pView == pActiveView) 1200 { 1201 sInsert += '('; 1202 sInsert += aContextStrings[ ST_ACTIVE - ST_CONTEXT_FIRST]; 1203 sInsert += ')'; 1204 } 1205 pSubPop3->InsertItem(nId, sInsert); 1206 if(bIsConstant && pActiveShell == &pView->GetWrtShell()) 1207 pSubPop3->CheckItem(nId); 1208 pView = SwModule::GetNextView(pView); 1209 nId++; 1210 } 1211 pSubPop3->InsertItem(nId++, aContextStrings[ST_ACTIVE_VIEW - ST_CONTEXT_FIRST]); 1212 if(pHiddenShell) 1213 { 1214 String sHiddenEntry = pHiddenShell->GetView().GetDocShell()->GetTitle(); 1215 sHiddenEntry += C2S(" ( "); 1216 sHiddenEntry += aContextStrings[ ST_HIDDEN - ST_CONTEXT_FIRST]; 1217 sHiddenEntry += C2S(" )"); 1218 pSubPop3->InsertItem(nId, sHiddenEntry); 1219 } 1220 1221 if(bIsActive) 1222 pSubPop3->CheckItem( --nId ); 1223 else if(bIsHidden) 1224 pSubPop3->CheckItem( nId ); 1225 1226 pPop->InsertItem( 1, aContextStrings[ST_OUTLINE_LEVEL - ST_CONTEXT_FIRST]); 1227 pPop->InsertItem(2, aContextStrings[ST_DRAGMODE - ST_CONTEXT_FIRST]); 1228 pPop->InsertItem(3, aContextStrings[ST_DISPLAY - ST_CONTEXT_FIRST]); 1229 //jetzt noch bearbeiten 1230 SvLBoxEntry* pEntry = 0; 1231 //Bearbeiten nur, wenn die angezeigten Inhalte aus der aktiven View kommen 1232 if((bIsActive || pActiveShell == pActiveView->GetWrtShellPtr()) 1233 && 0 != (pEntry = FirstSelected()) && lcl_IsContent(pEntry)) 1234 { 1235 const SwContentType* pContType = ((SwContent*)pEntry->GetUserData())->GetParent(); 1236 const sal_uInt16 nContentType = pContType->GetType(); 1237 sal_Bool bReadonly = pActiveShell->GetView().GetDocShell()->IsReadOnly(); 1238 sal_Bool bVisible = !((SwContent*)pEntry->GetUserData())->IsInvisible(); 1239 sal_Bool bProtected = ((SwContent*)pEntry->GetUserData())->IsProtect(); 1240 sal_Bool bEditable = pContType->IsEditable() && 1241 ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType); 1242 sal_Bool bDeletable = pContType->IsDeletable() && 1243 ((bVisible && !bProtected) ||CONTENT_TYPE_REGION == nContentType); 1244 sal_Bool bRenamable = bEditable && !bReadonly && 1245 (CONTENT_TYPE_TABLE == nContentType || 1246 CONTENT_TYPE_FRAME == nContentType || 1247 CONTENT_TYPE_GRAPHIC == nContentType || 1248 CONTENT_TYPE_OLE == nContentType || 1249 CONTENT_TYPE_BOOKMARK == nContentType || 1250 CONTENT_TYPE_REGION == nContentType|| 1251 CONTENT_TYPE_INDEX == nContentType); 1252 1253 if(!bReadonly && (bEditable || bDeletable)) 1254 { 1255 sal_Bool bSubPop4 = sal_False; 1256 if(CONTENT_TYPE_INDEX == nContentType) 1257 { 1258 bSubPop4 = sal_True; 1259 pSubPop4->InsertItem(401, sRemoveIdx); 1260 pSubPop4->InsertItem(402, sUpdateIdx); 1261 1262 const SwTOXBase* pBase = ((SwTOXBaseContent*)pEntry->GetUserData())->GetTOXBase(); 1263 if(!pBase->IsTOXBaseInReadonly()) 1264 pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); 1265 pSubPop4->InsertItem(405, sReadonlyIdx); 1266 1267 pSubPop4->CheckItem( 405, pActiveShell->IsTOXBaseReadonly(*pBase)); 1268 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); 1269 } 1270 else if(CONTENT_TYPE_TABLE == nContentType && !bReadonly) 1271 { 1272 bSubPop4 = sal_True; 1273 pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); 1274 pSubPop4->InsertItem(404, sUnprotTbl); 1275 sal_Bool bFull = sal_False; 1276 String sTblName = ((SwContent*)pEntry->GetUserData())->GetName(); 1277 sal_Bool bProt =pActiveShell->HasTblAnyProtection( &sTblName, &bFull ); 1278 pSubPop4->EnableItem(403, !bFull ); 1279 pSubPop4->EnableItem(404, bProt ); 1280 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); 1281 } 1282 else if(bEditable || bDeletable) 1283 { 1284 1285 if(bEditable && bDeletable) 1286 { 1287 pSubPop4->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); 1288 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); 1289 bSubPop4 = sal_True; 1290 } 1291 else if(bEditable) 1292 pPop->InsertItem(403, aContextStrings[ST_EDIT_ENTRY - ST_CONTEXT_FIRST]); 1293 else if(bDeletable) 1294 { 1295 pSubPop4->InsertItem(501, aContextStrings[ST_DELETE_ENTRY - ST_CONTEXT_FIRST]); 1296 } 1297 } 1298 //Rename object 1299 if(bRenamable) 1300 { 1301 if(bSubPop4) 1302 pSubPop4->InsertItem(502, sRename); 1303 else 1304 pPop->InsertItem(502, sRename); 1305 } 1306 1307 if(bSubPop4) 1308 { 1309 pPop->InsertItem(4, pContType->GetSingleName()); 1310 pPop->SetPopupMenu(4, pSubPop4); 1311 } 1312 } 1313 } 1314 else if( pEntry ) 1315 { 1316 SwContentType* pType = (SwContentType*)pEntry->GetUserData(); 1317 if ( (pType->GetType() == CONTENT_TYPE_POSTIT) && (!pActiveShell->GetView().GetDocShell()->IsReadOnly()) && ( pType->GetMemberCount() > 0) ) 1318 { 1319 pSubPop4->InsertItem(600, sPostItShow ); 1320 pSubPop4->InsertItem(601, sPostItHide ); 1321 pSubPop4->InsertItem(602, sPostItDelete ); 1322 /* 1323 pSubPop4->InsertItem(603,rtl::OUString::createFromAscii("Sort")); 1324 PopupMenu* pMenuSort = new PopupMenu; 1325 pMenuSort->InsertItem(604,rtl::OUString::createFromAscii("By Position")); 1326 pMenuSort->InsertItem(605,rtl::OUString::createFromAscii("By Author")); 1327 pMenuSort->InsertItem(606,rtl::OUString::createFromAscii("By Date")); 1328 pSubPop4->SetPopupMenu(603, pMenuSort); 1329 */ 1330 pPop->InsertItem(4, pType->GetSingleName()); 1331 pPop->SetPopupMenu(4, pSubPop4); 1332 } 1333 } 1334 1335 pPop->SetPopupMenu( 1, pSubPop1 ); 1336 pPop->SetPopupMenu( 2, pSubPop2 ); 1337 pPop->SetPopupMenu( 3, pSubPop3 ); 1338 return pPop; 1339 1340 } 1341 /*************************************************************************** 1342 Beschreibung: Einrueckung fuer outlines (und sections) 1343 ***************************************************************************/ 1344 1345 1346 long SwContentTree::GetTabPos( SvLBoxEntry* pEntry, SvLBoxTab* pTab) 1347 { 1348 sal_uInt16 nLevel = 0; 1349 if(lcl_IsContent(pEntry)) 1350 { 1351 nLevel++; 1352 SwContent* pCnt = (SwContent *) pEntry->GetUserData(); 1353 const SwContentType* pParent; 1354 if(pCnt && 0 != (pParent = pCnt->GetParent())) 1355 { 1356 if(pParent->GetType() == CONTENT_TYPE_OUTLINE) 1357 nLevel = nLevel + ((SwOutlineContent*)pCnt)->GetOutlineLevel(); 1358 else if(pParent->GetType() == CONTENT_TYPE_REGION) 1359 nLevel = nLevel + ((SwRegionContent*)pCnt)->GetRegionLevel(); 1360 } 1361 } 1362 sal_uInt16 nBasis = bIsRoot ? 0 : 5; 1363 return nLevel * 10 + nBasis + pTab->GetPos(); //empirisch ermittelt 1364 } 1365 1366 /*************************************************************************** 1367 Beschreibung: Inhalte werden erst auf Anforderung in die Box eingefuegt 1368 ***************************************************************************/ 1369 1370 1371 void SwContentTree::RequestingChilds( SvLBoxEntry* pParent ) 1372 { 1373 // ist es ein Inhaltstyp? 1374 if(lcl_IsContentType(pParent)) 1375 { 1376 if(!pParent->HasChilds()) 1377 { 1378 DBG_ASSERT(pParent->GetUserData(), "keine UserData?"); 1379 SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); 1380 1381 sal_uInt16 nCount = pCntType->GetMemberCount(); 1382 for(sal_uInt16 i = 0; i < nCount; i++) 1383 { 1384 const SwContent* pCnt = pCntType->GetMember(i); 1385 if(pCnt) 1386 { 1387 String sEntry = pCnt->GetName(); 1388 if(!sEntry.Len()) 1389 sEntry = sSpace; 1390 SvLBoxEntry* pChild = InsertEntry(sEntry, pParent, 1391 sal_False, LIST_APPEND, (void*)pCnt); 1392 //Solution: If object is marked , the corresponding entry is set true , 1393 //else the corresponding entry is set false . 1394 //================================================== 1395 SdrObject * pObj = GetDrawingObjectsByContent(pCnt); 1396 if(pChild) 1397 pChild->SetMarked(sal_False); 1398 if(pObj) 1399 { 1400 SdrView* pDrawView = pActiveShell->GetDrawView(); 1401 SdrPageView* pPV = pDrawView->/*GetPageViewPvNum*/GetSdrPageView(/*0*/); 1402 if( pPV ) 1403 { 1404 sal_Bool Marked = pDrawView->IsObjMarked(pObj); 1405 if(Marked) 1406 { 1407 //sEntry += String::CreateFromAscii(" *"); 1408 pChild->SetMarked(sal_True); 1409 } 1410 1411 } 1412 } 1413 } 1414 } 1415 } 1416 } 1417 } 1418 /*************************************************************************** 1419 Beschreibung: Expand - Zustand fuer Inhaltstypen merken 1420 ***************************************************************************/ 1421 1422 //Solution: Get drawing Objects by content . 1423 SdrObject* SwContentTree::GetDrawingObjectsByContent(const SwContent *pCnt) 1424 { 1425 SdrObject *pRetObj = NULL; 1426 sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); 1427 switch(nJumpType) 1428 { 1429 case CONTENT_TYPE_DRAWOBJECT: 1430 { 1431 SdrView* pDrawView = pActiveShell->GetDrawView(); 1432 if (pDrawView) 1433 { 1434 SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); 1435 SdrPage* pPage = pDrawModel->GetPage(0); 1436 sal_uInt32 nCount = pPage->GetObjCount(); 1437 1438 for( sal_uInt32 i=0; i< nCount; i++ ) 1439 { 1440 SdrObject* pTemp = pPage->GetObj(i); 1441 if( pTemp->GetName() == pCnt->GetName()) 1442 { 1443 pRetObj = pTemp; 1444 break; 1445 } 1446 } 1447 } 1448 break; 1449 } 1450 default: 1451 pRetObj = NULL; 1452 } 1453 return pRetObj; 1454 } 1455 1456 sal_Bool SwContentTree::Expand( SvLBoxEntry* pParent ) 1457 { 1458 if(!bIsRoot) 1459 { 1460 if(lcl_IsContentType(pParent)) 1461 { 1462 SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); 1463 sal_uInt16 nOr = 1 << pCntType->GetType(); //linear -> Bitposition 1464 if(bIsActive || bIsConstant) 1465 { 1466 nActiveBlock |= nOr; 1467 pConfig->SetActiveBlock(nActiveBlock); 1468 } 1469 else 1470 nHiddenBlock |= nOr; 1471 } 1472 } 1473 return SvTreeListBox::Expand(pParent); 1474 } 1475 /*************************************************************************** 1476 Beschreibung: Collapse - Zustand fuer Inhaltstypen merken 1477 ***************************************************************************/ 1478 1479 1480 sal_Bool SwContentTree::Collapse( SvLBoxEntry* pParent ) 1481 { 1482 sal_Bool bRet; 1483 if(!bIsRoot) 1484 { 1485 if(lcl_IsContentType(pParent)) 1486 { 1487 SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); 1488 sal_uInt16 nAnd = 1 << pCntType->GetType(); 1489 nAnd = ~nAnd; 1490 if(bIsActive || bIsConstant) 1491 { 1492 nActiveBlock &= nAnd; 1493 pConfig->SetActiveBlock(nActiveBlock); 1494 } 1495 else 1496 nHiddenBlock &= nAnd; 1497 } 1498 bRet = SvTreeListBox::Collapse(pParent); 1499 } 1500 else 1501 bRet = sal_False; 1502 return bRet; 1503 } 1504 1505 1506 /*************************************************************************** 1507 Beschreibung: Auch auf Doppelclick wird zunaechst nur aufgeklappt 1508 ***************************************************************************/ 1509 1510 1511 IMPL_LINK( SwContentTree, ContentDoubleClickHdl, SwContentTree *, EMPTYARG ) 1512 { 1513 SvLBoxEntry* pEntry = GetCurEntry(); 1514 // ist es ein Inhaltstyp? 1515 DBG_ASSERT(pEntry, "kein aktueller Eintrag!"); 1516 if(pEntry) 1517 { 1518 if(lcl_IsContentType(pEntry)) 1519 RequestingChilds(pEntry); 1520 else if(bIsActive || bIsConstant) 1521 { 1522 if(bIsConstant) 1523 { 1524 pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop(); 1525 } 1526 //Inhaltstyp anspringen: 1527 SwContent* pCnt = (SwContent*)pEntry->GetUserData(); 1528 DBG_ASSERT( pCnt, "keine UserData"); 1529 GotoContent(pCnt); 1530 if(pCnt->GetParent()->GetType() == CONTENT_TYPE_FRAME) 1531 pActiveShell->EnterStdMode(); 1532 } 1533 } 1534 return 0; 1535 } 1536 1537 /*************************************************************************** 1538 Beschreibung: Anzeigen der Datei 1539 ***************************************************************************/ 1540 1541 1542 void SwContentTree::Display( sal_Bool bActive ) 1543 { 1544 if(!bIsImageListInitialized) 1545 { 1546 sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; 1547 aEntryImages = ImageList(SW_RES(nResId)); 1548 bIsImageListInitialized = sal_True; 1549 } 1550 // erst den selektierten Eintrag auslesen, um ihn spaeter evtl. wieder 1551 // zu selektieren -> die UserDaten sind hier nicht mehr gueltig! 1552 SvLBoxEntry* pOldSelEntry = FirstSelected(); 1553 String sEntryName; // Name des Eintrags 1554 sal_uInt16 nEntryRelPos = 0; // rel. Pos zu seinem Parent 1555 sal_uInt32 nOldEntryCount = GetEntryCount(); 1556 sal_Int32 nOldScrollPos = 0; 1557 if(pOldSelEntry) 1558 { 1559 ScrollBar* pVScroll = GetVScroll(); 1560 if(pVScroll && pVScroll->IsVisible()) 1561 nOldScrollPos = pVScroll->GetThumbPos(); 1562 1563 sEntryName = GetEntryText(pOldSelEntry); 1564 if(GetParent(pOldSelEntry)) 1565 { 1566 nEntryRelPos = (sal_uInt16)(GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(GetParent(pOldSelEntry))); 1567 } 1568 } 1569 Clear(); 1570 SetUpdateMode( sal_False ); 1571 if(bActive && !bIsConstant && !bIsActive) 1572 bIsActive = bActive; 1573 bIsHidden = !bActive; 1574 SwWrtShell* pShell = GetWrtShell(); 1575 sal_Bool bReadOnly = pShell ? pShell->GetView().GetDocShell()->IsReadOnly() : sal_True; 1576 if(bReadOnly != bIsLastReadOnly) 1577 { 1578 bIsLastReadOnly = bReadOnly; 1579 sal_Bool bDisable = pShell == 0 || bReadOnly; 1580 SwNavigationPI* pNavi = GetParentWindow(); 1581 pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , !bDisable); 1582 pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, !bDisable); 1583 pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, !bDisable); 1584 pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT, !bDisable); 1585 pNavi->aContentToolBox.EnableItem(FN_SELECT_SET_AUTO_BOOKMARK, !bDisable); 1586 } 1587 if(pShell) 1588 { 1589 SvLBoxEntry* pSelEntry = 0; 1590 if(nRootType == USHRT_MAX) 1591 { 1592 for(sal_uInt16 nCntType = CONTENT_TYPE_OUTLINE; 1593 nCntType <= CONTENT_TYPE_DRAWOBJECT; nCntType++ ) 1594 { 1595 SwContentType** ppContentT = bActive ? 1596 &aActiveContentArr[nCntType] : 1597 &aHiddenContentArr[nCntType]; 1598 if(!*ppContentT) 1599 (*ppContentT) = new SwContentType(pShell, nCntType, nOutlineLevel ); 1600 1601 1602 String sEntry = (*ppContentT)->GetName(); 1603 SvLBoxEntry* pEntry; 1604 const Image& rImage = aEntryImages.GetImage(SID_SW_START + nCntType); 1605 sal_Bool bChOnDemand = 0 != (*ppContentT)->GetMemberCount(); 1606 pEntry = InsertEntry(sEntry, rImage, rImage, 1607 0, bChOnDemand, LIST_APPEND, (*ppContentT)); 1608 if(nCntType == nLastSelType) 1609 pSelEntry = pEntry; 1610 sal_Int32 nExpandOptions = bIsActive || bIsConstant ? 1611 nActiveBlock : 1612 nHiddenBlock; 1613 if(nExpandOptions & (1 << nCntType)) 1614 { 1615 Expand(pEntry); 1616 if(nEntryRelPos && nCntType == nLastSelType) 1617 { 1618 // jetzt vielleicht noch ein Child selektieren 1619 SvLBoxEntry* pChild = pEntry; 1620 SvLBoxEntry* pTemp = 0; 1621 sal_uInt16 nPos = 1; 1622 while(0 != (pChild = Next(pChild))) 1623 { 1624 // der alte Text wird leicht bevorzugt 1625 if(sEntryName == GetEntryText(pChild) || 1626 nPos == nEntryRelPos ) 1627 { 1628 pSelEntry = pChild; 1629 break; 1630 } 1631 pTemp = pChild; 1632 nPos++; 1633 } 1634 if(!pSelEntry || lcl_IsContentType(pSelEntry)) 1635 pSelEntry = pTemp; 1636 } 1637 1638 } 1639 } 1640 if(pSelEntry) 1641 { 1642 MakeVisible(pSelEntry); 1643 Select(pSelEntry); 1644 } 1645 else 1646 nOldScrollPos = 0; 1647 } 1648 else 1649 { 1650 SwContentType** ppRootContentT = bActive ? 1651 &aActiveContentArr[nRootType] : 1652 &aHiddenContentArr[nRootType]; 1653 if(!(*ppRootContentT)) 1654 (*ppRootContentT) = new SwContentType(pShell, nRootType, nOutlineLevel ); 1655 const Image& rImage = aEntryImages.GetImage(20000 + nRootType); 1656 SvLBoxEntry* pParent = InsertEntry( 1657 (*ppRootContentT)->GetName(), rImage, rImage, 1658 0, sal_False, LIST_APPEND, *ppRootContentT); 1659 1660 for(sal_uInt16 i = 0; i < (*ppRootContentT)->GetMemberCount(); i++ ) 1661 { 1662 const SwContent* pCnt = (*ppRootContentT)->GetMember(i); 1663 if(pCnt) 1664 { 1665 String sEntry = pCnt->GetName(); 1666 if(!sEntry.Len()) 1667 sEntry = sSpace; 1668 InsertEntry( sEntry, pParent, 1669 sal_False, LIST_APPEND, (void*)pCnt); 1670 } 1671 } 1672 Expand(pParent); 1673 if( nRootType == CONTENT_TYPE_OUTLINE && bIsActive ) 1674 { 1675 //feststellen, wo der Cursor steht 1676 const sal_uInt16 nActPos = pShell->GetOutlinePos(MAXLEVEL); 1677 SvLBoxEntry* pEntry = First(); 1678 1679 while( 0 != (pEntry = Next(pEntry)) ) 1680 { 1681 if(((SwOutlineContent*)pEntry->GetUserData())->GetPos() == nActPos) 1682 { 1683 MakeVisible(pEntry); 1684 Select(pEntry); 1685 } 1686 } 1687 1688 } 1689 else 1690 { 1691 // jetzt vielleicht noch ein Child selektieren 1692 SvLBoxEntry* pChild = pParent; 1693 SvLBoxEntry* pTemp = 0; 1694 sal_uInt16 nPos = 1; 1695 while(0 != (pChild = Next(pChild))) 1696 { 1697 // der alte Text wird leicht bevorzugt 1698 if(sEntryName == GetEntryText(pChild) || 1699 nPos == nEntryRelPos ) 1700 { 1701 pSelEntry = pChild; 1702 break; 1703 } 1704 pTemp = pChild; 1705 nPos++; 1706 } 1707 if(!pSelEntry) 1708 pSelEntry = pTemp; 1709 if(pSelEntry) 1710 { 1711 MakeVisible(pSelEntry); 1712 Select(pSelEntry); 1713 } 1714 } 1715 } 1716 } 1717 SetUpdateMode( sal_True ); 1718 ScrollBar* pVScroll = GetVScroll(); 1719 if(GetEntryCount() == nOldEntryCount && 1720 nOldScrollPos && pVScroll && pVScroll->IsVisible() 1721 && pVScroll->GetThumbPos() != nOldScrollPos) 1722 { 1723 sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos; 1724 ScrollOutputArea( (short)nDelta ); 1725 } 1726 1727 } 1728 1729 /*************************************************************************** 1730 Beschreibung: Im Clear muessen auch die ContentTypes geloescht werden 1731 ***************************************************************************/ 1732 1733 1734 void SwContentTree::Clear() 1735 { 1736 SetUpdateMode(sal_False); 1737 SvTreeListBox::Clear(); 1738 SetUpdateMode(sal_True); 1739 } 1740 1741 /*************************************************************************** 1742 Beschreibung: 1743 ***************************************************************************/ 1744 1745 sal_Bool SwContentTree::FillTransferData( TransferDataContainer& rTransfer, 1746 sal_Int8& rDragMode ) 1747 { 1748 SwWrtShell* pWrtShell = GetWrtShell(); 1749 DBG_ASSERT(pWrtShell, "keine Shell!"); 1750 SvLBoxEntry* pEntry = GetCurEntry(); 1751 if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell) 1752 return sal_False; 1753 String sEntry; 1754 SwContent* pCnt = ((SwContent*)pEntry->GetUserData()); 1755 1756 sal_uInt16 nActType = pCnt->GetParent()->GetType(); 1757 String sUrl; 1758 sal_Bool bOutline = sal_False; 1759 String sOutlineText; 1760 switch( nActType ) 1761 { 1762 case CONTENT_TYPE_OUTLINE: 1763 { 1764 sal_uInt16 nPos = ((SwOutlineContent*)pCnt)->GetPos(); 1765 DBG_ASSERT(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(), 1766 "outlinecnt veraendert"); 1767 1768 // #100738# make sure outline may actually be copied 1769 if( pWrtShell->IsOutlineCopyable( nPos ) ) 1770 { 1771 const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule(); 1772 const SwTxtNode* pTxtNd = 1773 pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos); 1774 if( pTxtNd && pOutlRule && pTxtNd->IsNumbered()) 1775 { 1776 SwNumberTree::tNumberVector aNumVector = 1777 pTxtNd->GetNumberVector(); 1778 for( sal_Int8 nLevel = 0; 1779 nLevel <= pTxtNd->GetActualListLevel(); 1780 nLevel++ ) 1781 { 1782 sal_uInt16 nVal = (sal_uInt16)aNumVector[nLevel]; 1783 nVal ++; 1784 nVal = nVal - pOutlRule->Get(nLevel).GetStart(); 1785 sEntry += String::CreateFromInt32( nVal ); 1786 sEntry += '.'; 1787 } 1788 } 1789 sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, false); 1790 sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, true); 1791 bIsOutlineMoveable = ((SwOutlineContent*)pCnt)->IsMoveable(); 1792 bOutline = sal_True; 1793 } 1794 } 1795 break; 1796 case CONTENT_TYPE_POSTIT: 1797 case CONTENT_TYPE_INDEX: 1798 case CONTENT_TYPE_REFERENCE : 1799 // koennen weder als URL noch als Bereich eingefuegt werden 1800 break; 1801 case CONTENT_TYPE_URLFIELD: 1802 sUrl = ((SwURLFieldContent*)pCnt)->GetURL(); 1803 // kein break; 1804 case CONTENT_TYPE_OLE: 1805 case CONTENT_TYPE_GRAPHIC: 1806 if(GetParentWindow()->GetRegionDropMode() != REGION_MODE_NONE) 1807 break; 1808 else 1809 rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK ); 1810 default: 1811 sEntry = GetEntryText(pEntry); 1812 } 1813 1814 sal_Bool bRet = sal_False; 1815 if(sEntry.Len()) 1816 { 1817 const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell(); 1818 if(!sUrl.Len()) 1819 { 1820 if(pDocShell->HasName()) 1821 { 1822 SfxMedium* pMedium = pDocShell->GetMedium(); 1823 sUrl = pMedium->GetURLObject().GetURLNoMark(); 1824 // nur, wenn primaer ein Link eingefuegt werden soll 1825 bRet = sal_True; 1826 } 1827 else if( nActType == CONTENT_TYPE_REGION || 1828 nActType == CONTENT_TYPE_BOOKMARK ) 1829 { 1830 // fuer Bereich und Textmarken ist ein Link auch ohne 1831 // Dateiname ins eigene Dokument erlaubt 1832 bRet = sal_True; 1833 } 1834 else if(bIsConstant && 1835 ( !::GetActiveView() || 1836 pActiveShell != ::GetActiveView()->GetWrtShellPtr())) 1837 { 1838 // Urls von inaktiven Views ohne Dateinamen koennen auch nicht 1839 // gedraggt werden 1840 bRet = sal_False; 1841 } 1842 else 1843 { 1844 bRet = GetParentWindow()->GetRegionDropMode() == REGION_MODE_NONE; 1845 rDragMode = DND_ACTION_MOVE; 1846 } 1847 1848 const String& rToken = pCnt->GetParent()->GetTypeToken(); 1849 sUrl += '#'; 1850 sUrl += sEntry; 1851 if(rToken.Len()) 1852 { 1853 sUrl += cMarkSeperator; 1854 sUrl += rToken; 1855 } 1856 } 1857 else 1858 bRet = sal_True; 1859 1860 if( bRet ) 1861 { 1862 //fuer Outlines muss in die Description der Ueberschrifttext mit der echten Nummer 1863 if(bOutline) 1864 sEntry = sOutlineText; 1865 1866 { 1867 NaviContentBookmark aBmk( sUrl, sEntry, 1868 GetParentWindow()->GetRegionDropMode(), 1869 pDocShell); 1870 aBmk.Copy( rTransfer ); 1871 } 1872 1873 // fuer fremde DocShells muss eine INetBookmark 1874 // dazugeliefert werden 1875 if( pDocShell->HasName() ) 1876 { 1877 INetBookmark aBkmk( sUrl, sEntry ); 1878 rTransfer.CopyINetBookmark( aBkmk ); 1879 } 1880 } 1881 } 1882 return bRet; 1883 } 1884 /*************************************************************************** 1885 Beschreibung: Umschalten der Anzeige auf Root 1886 ***************************************************************************/ 1887 1888 1889 sal_Bool SwContentTree::ToggleToRoot() 1890 { 1891 if(!bIsRoot) 1892 { 1893 SvLBoxEntry* pEntry = GetCurEntry(); 1894 const SwContentType* pCntType; 1895 if(pEntry) 1896 { 1897 if(lcl_IsContentType(pEntry)) 1898 pCntType = (SwContentType*)pEntry->GetUserData(); 1899 else 1900 pCntType = ((SwContent*)pEntry->GetUserData())->GetParent(); 1901 nRootType = pCntType->GetType(); 1902 bIsRoot = sal_True; 1903 Display(bIsActive || bIsConstant); 1904 } 1905 } 1906 else 1907 { 1908 nRootType = USHRT_MAX; 1909 bIsRoot = sal_False; 1910 FindActiveTypeAndRemoveUserData(); 1911 Display(bIsActive || bIsConstant); 1912 } 1913 pConfig->SetRootType( nRootType ); 1914 GetParentWindow()->aContentToolBox.CheckItem(FN_SHOW_ROOT, bIsRoot); 1915 return bIsRoot; 1916 } 1917 1918 /*************************************************************************** 1919 Beschreibung: Angezeigten Inhalt auf Gueltigkeit pruefen 1920 ***************************************************************************/ 1921 1922 1923 sal_Bool SwContentTree::HasContentChanged() 1924 { 1925 /* 1926 -Parallel durch das lokale Array und die Treelistbox laufen. 1927 -Sind die Eintraege nicht expandiert, werden sie nur im Array verworfen 1928 und der Contenttype wird als UserData neu gesetzt. 1929 - ist der Root-Modus aktiv, wird nur dieser aktualisiert, 1930 fuer die nicht angezeigten Inhaltstypen gilt: 1931 die Memberliste wird geloescht und der Membercount aktualisiert 1932 Wenn Inhalte ueberprueft werden, werden gleichzeitig die vorhanden 1933 Memberlisten aufgefuellt. Sobald ein Unterschied auftritt wird nur noch 1934 gefuellt und nicht mehr ueberprueft. Abschliessend wird die Box neu gefuellt. 1935 1936 */ 1937 1938 sal_Bool bRepaint = sal_False; 1939 sal_Bool bInvalidate = sal_False; 1940 1941 if(!bIsActive && ! bIsConstant) 1942 { 1943 for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) 1944 { 1945 if(aActiveContentArr[i]) 1946 aActiveContentArr[i]->Invalidate(); 1947 } 1948 } 1949 else if(bIsRoot) 1950 { 1951 sal_Bool bOutline = sal_False; 1952 SvLBoxEntry* pEntry = First(); 1953 if(!pEntry) 1954 bRepaint = sal_True; 1955 else 1956 { 1957 sal_uInt16 nType = ((SwContentType*)pEntry->GetUserData())->GetType(); 1958 bOutline = nRootType == CONTENT_TYPE_OUTLINE; 1959 SwContentType* pArrType = aActiveContentArr[nType]; 1960 if(!pArrType) 1961 bRepaint = sal_True; 1962 else 1963 { 1964 sal_uInt16 nSelLevel = USHRT_MAX; 1965 1966 SvLBoxEntry* pFirstSel; 1967 if(bOutline && 1968 0 != ( pFirstSel = FirstSelected()) && 1969 lcl_IsContent(pFirstSel)) 1970 { 1971 nSelLevel = ((SwOutlineContent*)pFirstSel->GetUserData())->GetOutlineLevel(); 1972 SwWrtShell* pSh = GetWrtShell(); 1973 sal_uInt16 nOutlinePos = pSh->GetOutlinePos(MAXLEVEL); 1974 bRepaint |= nOutlinePos != USHRT_MAX && 1975 pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel; 1976 } 1977 1978 pArrType->Init(&bInvalidate); 1979 pArrType->FillMemberList(); 1980 pEntry->SetUserData((void*)pArrType); 1981 if(!bRepaint) 1982 { 1983 if(GetChildCount(pEntry) != pArrType->GetMemberCount()) 1984 bRepaint = sal_True; 1985 else 1986 { 1987 sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); 1988 for(sal_uInt16 j = 0; j < nChildCount; j++) 1989 { 1990 pEntry = Next(pEntry); 1991 const SwContent* pCnt = pArrType->GetMember(j); 1992 pEntry->SetUserData((void*)pCnt); 1993 String sEntryText = GetEntryText(pEntry); 1994 if( sEntryText != pCnt->GetName() && 1995 !(sEntryText == sSpace && !pCnt->GetName().Len())) 1996 bRepaint = sal_True; 1997 } 1998 } 1999 } 2000 } 2001 } 2002 if( !bRepaint && bOutline ) 2003 { 2004 //feststellen, wo der Cursor steht 2005 const sal_uInt16 nActPos = GetWrtShell()->GetOutlinePos(MAXLEVEL); 2006 SvLBoxEntry* pFirstEntry = First(); 2007 2008 while( 0 != (pFirstEntry = Next(pFirstEntry)) ) 2009 { 2010 if(((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos() == nActPos) 2011 { 2012 if(FirstSelected() != pFirstEntry) 2013 { 2014 Select(pFirstEntry); 2015 MakeVisible(pFirstEntry); 2016 } 2017 } 2018 } 2019 2020 } 2021 2022 } 2023 else 2024 { 2025 SvLBoxEntry* pEntry = First(); 2026 while ( pEntry ) 2027 { 2028 sal_Bool bNext = sal_True; // mindestens ein Next muss sein 2029 SwContentType* pTreeType = (SwContentType*)pEntry->GetUserData(); 2030 sal_uInt16 nType = pTreeType->GetType(); 2031 sal_uInt16 nTreeCount = pTreeType->GetMemberCount(); 2032 SwContentType* pArrType = aActiveContentArr[nType]; 2033 if(!pArrType) 2034 bRepaint = sal_True; 2035 else 2036 { 2037 pArrType->Init(&bInvalidate); 2038 pEntry->SetUserData((void*)pArrType); 2039 if(IsExpanded(pEntry)) 2040 { 2041 sal_Bool bLevelOrVisibiblityChanged = sal_False; 2042 // bLevelOrVisibiblityChanged is set if outlines have changed their level 2043 // or if the visibility of objects (frames, sections, tables) has changed 2044 // i.e. in header/footer 2045 pArrType->FillMemberList(&bLevelOrVisibiblityChanged); 2046 if(bLevelOrVisibiblityChanged) 2047 bInvalidate = sal_True; 2048 sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); 2049 if(bLevelOrVisibiblityChanged) 2050 bInvalidate = sal_True; 2051 2052 if(nChildCount != pArrType->GetMemberCount()) 2053 bRepaint = sal_True; 2054 else 2055 { 2056 for(sal_uInt16 j = 0; j < nChildCount; j++) 2057 { 2058 pEntry = Next(pEntry); 2059 bNext = sal_False; 2060 const SwContent* pCnt = pArrType->GetMember(j); 2061 pEntry->SetUserData((void*)pCnt); 2062 String sEntryText = GetEntryText(pEntry); 2063 if( sEntryText != pCnt->GetName() && 2064 !(sEntryText == sSpace && !pCnt->GetName().Len())) 2065 bRepaint = sal_True; 2066 } 2067 } 2068 2069 } 2070 else if(pEntry->HasChilds()) 2071 { 2072 //war der Eintrag einmal aufgeklappt, dann muessen auch 2073 // die unsichtbaren Eintraege geprueft werden. 2074 // zumindest muessen die Userdaten aktualisiert werden 2075 sal_Bool bLevelOrVisibiblityChanged = sal_False; 2076 // bLevelOrVisibiblityChanged is set if outlines have changed their level 2077 // or if the visibility of objects (frames, sections, tables) has changed 2078 // i.e. in header/footer 2079 pArrType->FillMemberList(&bLevelOrVisibiblityChanged); 2080 sal_Bool bRemoveChildren = sal_False; 2081 sal_uInt16 nChildCount = (sal_uInt16)GetChildCount(pEntry); 2082 if( nChildCount != pArrType->GetMemberCount() ) 2083 { 2084 bRemoveChildren = sal_True; 2085 } 2086 else 2087 { 2088 SvLBoxEntry* pChild = FirstChild(pEntry); 2089 for(sal_uInt16 j = 0; j < nChildCount; j++) 2090 { 2091 const SwContent* pCnt = pArrType->GetMember(j); 2092 pChild->SetUserData((void*)pCnt); 2093 String sEntryText = GetEntryText(pChild); 2094 if( sEntryText != pCnt->GetName() && 2095 !(sEntryText == sSpace && !pCnt->GetName().Len())) 2096 bRemoveChildren = sal_True; 2097 pChild = Next(pChild); 2098 } 2099 } 2100 if(bRemoveChildren) 2101 { 2102 SvLBoxEntry* pChild = FirstChild(pEntry); 2103 SvLBoxEntry* pRemove = pChild; 2104 for(sal_uInt16 j = 0; j < nChildCount; j++) 2105 { 2106 pChild = Next(pRemove); 2107 GetModel()->Remove(pRemove); 2108 pRemove = pChild; 2109 } 2110 } 2111 if(!nChildCount) 2112 { 2113 pEntry->EnableChildsOnDemand(sal_False); 2114 InvalidateEntry(pEntry); 2115 } 2116 2117 } 2118 else if((nTreeCount != 0) 2119 != (pArrType->GetMemberCount()!=0)) 2120 { 2121 bRepaint = sal_True; 2122 } 2123 } 2124 //hier muss noch der naechste Root-Entry gefunden werden 2125 while( pEntry && (bNext || GetParent(pEntry ) )) 2126 { 2127 pEntry = Next(pEntry); 2128 bNext = sal_False; 2129 } 2130 } 2131 } 2132 if(!bRepaint && bInvalidate) 2133 Invalidate(); 2134 return bRepaint; 2135 } 2136 2137 /*************************************************************************** 2138 Beschreibung: Bevor alle Daten geloescht werden, soll noch der letzte 2139 * aktive Eintrag festgestellt werden. Dann werden die 2140 * UserData geloescht 2141 ***************************************************************************/ 2142 void SwContentTree::FindActiveTypeAndRemoveUserData() 2143 { 2144 SvLBoxEntry* pEntry = FirstSelected(); 2145 if(pEntry) 2146 { 2147 // wird Clear ueber TimerUpdate gerufen, kann nur fuer die Root 2148 // die Gueltigkeit der UserData garantiert werden 2149 SvLBoxEntry* pParent; 2150 while(0 != (pParent = GetParent(pEntry))) 2151 pEntry = pParent; 2152 if(pEntry->GetUserData() && lcl_IsContentType(pEntry)) 2153 nLastSelType = ((SwContentType*)pEntry->GetUserData())->GetType(); 2154 } 2155 // else 2156 // nLastSelType = USHRT_MAX; 2157 pEntry = First(); 2158 while(pEntry) 2159 { 2160 pEntry->SetUserData(0); 2161 pEntry = Next(pEntry); 2162 } 2163 } 2164 2165 /*************************************************************************** 2166 Beschreibung: Nachdem ein File auf den Navigator gedroppt wurde, 2167 wird die neue Shell gesetzt 2168 ***************************************************************************/ 2169 2170 2171 void SwContentTree::SetHiddenShell(SwWrtShell* pSh) 2172 { 2173 pHiddenShell = pSh; 2174 bIsHidden = sal_True; 2175 bIsActive = bIsConstant = sal_False; 2176 FindActiveTypeAndRemoveUserData(); 2177 for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) 2178 { 2179 DELETEZ(aHiddenContentArr[i]); 2180 } 2181 Display(bIsActive); 2182 2183 GetParentWindow()->UpdateListBox(); 2184 } 2185 /*************************************************************************** 2186 Beschreibung: Dokumentwechsel - neue Shell setzen 2187 ***************************************************************************/ 2188 2189 2190 void SwContentTree::SetActiveShell(SwWrtShell* pSh) 2191 { 2192 if(bIsInternalDrag) 2193 bDocChgdInDragging = sal_True; 2194 sal_Bool bClear = pActiveShell != pSh; 2195 if(bIsActive && bClear) 2196 { 2197 pActiveShell = pSh; 2198 FindActiveTypeAndRemoveUserData(); 2199 Clear(); 2200 } 2201 else if(bIsConstant) 2202 { 2203 if(!lcl_FindShell(pActiveShell)) 2204 { 2205 pActiveShell = pSh; 2206 bIsActive = sal_True; 2207 bIsConstant = sal_False; 2208 bClear = sal_True; 2209 } 2210 } 2211 // nur wenn es die aktive View ist, wird das Array geloescht und 2212 // die Anzeige neu gefuellt 2213 if(bIsActive && bClear) 2214 { 2215 FindActiveTypeAndRemoveUserData(); 2216 for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) 2217 { 2218 DELETEZ(aActiveContentArr[i]); 2219 } 2220 Display(sal_True); 2221 } 2222 } 2223 2224 /*************************************************************************** 2225 Beschreibung: Eine offene View als aktiv festlegen 2226 ***************************************************************************/ 2227 2228 2229 void SwContentTree::SetConstantShell(SwWrtShell* pSh) 2230 { 2231 pActiveShell = pSh; 2232 bIsActive = sal_False; 2233 bIsConstant = sal_True; 2234 FindActiveTypeAndRemoveUserData(); 2235 for(sal_uInt16 i=0; i < CONTENT_TYPE_MAX; i++) 2236 { 2237 DELETEZ(aActiveContentArr[i]); 2238 } 2239 Display(sal_True); 2240 } 2241 /*************************************************************************** 2242 Beschreibung: Kommandos des Navigators ausfuehren 2243 ***************************************************************************/ 2244 2245 2246 void SwContentTree::ExecCommand(sal_uInt16 nCmd, sal_Bool bModifier) 2247 { 2248 sal_Bool nMove = sal_False; 2249 switch( nCmd ) 2250 { 2251 case FN_ITEM_DOWN: 2252 case FN_ITEM_UP: nMove = sal_True; 2253 case FN_ITEM_LEFT: 2254 case FN_ITEM_RIGHT: 2255 if( !GetWrtShell()->GetView().GetDocShell()->IsReadOnly() && 2256 (bIsActive || 2257 (bIsConstant && pActiveShell == GetParentWindow()->GetCreateView()->GetWrtShellPtr()))) 2258 { 2259 SwWrtShell* pShell = GetWrtShell(); 2260 sal_Int8 nActOutlineLevel = nOutlineLevel; 2261 sal_uInt16 nActPos = pShell->GetOutlinePos(nActOutlineLevel); 2262 SvLBoxEntry* pFirstEntry = FirstSelected(); 2263 if (pFirstEntry && lcl_IsContent(pFirstEntry)) 2264 { 2265 if((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE) || 2266 ((SwContent*)pFirstEntry->GetUserData())->GetParent()->GetType() 2267 == CONTENT_TYPE_OUTLINE) 2268 { 2269 nActPos = ((SwOutlineContent*)pFirstEntry->GetUserData())->GetPos(); 2270 } 2271 } 2272 if ( nActPos < USHRT_MAX && 2273 ( !nMove || pShell->IsOutlineMovable( nActPos )) ) 2274 { 2275 pShell->StartAllAction(); 2276 pShell->GotoOutline( nActPos); // Falls Textselektion != BoxSelektion 2277 pShell->Push(); 2278 pShell->MakeOutlineSel( nActPos, nActPos, 2279 bModifier); 2280 if( nMove ) 2281 { 2282 short nDir = nCmd == FN_ITEM_UP ? -1 : 1; 2283 if( !bModifier && ((nDir == -1 && nActPos > 0) || 2284 (nDir == 1 && nActPos < GetEntryCount() - 2 )) ) 2285 { 2286 pShell->MoveOutlinePara( nDir ); 2287 //Cursor wieder an die aktuelle Position setzen 2288 pShell->GotoOutline( nActPos + nDir); 2289 } 2290 else if(bModifier) 2291 { 2292 sal_uInt16 nActEndPos = nActPos; 2293 SvLBoxEntry* pEntry = pFirstEntry; 2294 sal_uInt16 nActLevel = ((SwOutlineContent*) 2295 pFirstEntry->GetUserData())->GetOutlineLevel(); 2296 pEntry = Next(pEntry); 2297 while( pEntry && CONTENT_TYPE_OUTLINE == 2298 ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId() ) 2299 { 2300 if(nActLevel >= ((SwOutlineContent*) 2301 pEntry->GetUserData())->GetOutlineLevel()) 2302 break; 2303 pEntry = Next(pEntry); 2304 nActEndPos++; 2305 } 2306 sal_uInt16 nDest; 2307 if(nDir == 1) 2308 { 2309 //Wenn der letzte Eintrag bewegt werden soll 2310 //ist Schluss 2311 if(pEntry && CONTENT_TYPE_OUTLINE == 2312 ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId()) 2313 { 2314 // pEntry zeigt jetzt auf den 2315 // dem letzten sel. Eintrag folgenden E. 2316 nDest = nActEndPos; 2317 nDest++; 2318 //hier muss der uebernaechste Eintrag 2319 //gefunden werden. Die Selektion muss davor eingefuegt 2320 //werden 2321 while(pEntry ) 2322 { 2323 pEntry = Next(pEntry); 2324 // nDest++ darf nur ausgefuehrt werden, 2325 // wenn pEntry != 0 2326 if(pEntry && nDest++ && 2327 ( nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()|| 2328 CONTENT_TYPE_OUTLINE != ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())) 2329 { 2330 nDest--; 2331 break; 2332 } 2333 } 2334 nDir = nDest - nActEndPos; 2335 //wenn kein Eintrag gefunden wurde, der der Bedingung 2336 //fuer das zuvor Einfuegen entspricht, muss etwas weniger 2337 //geschoben werden 2338 } 2339 else 2340 nDir = 0; 2341 } 2342 else 2343 { 2344 nDest = nActPos; 2345 pEntry = pFirstEntry; 2346 while(pEntry && nDest ) 2347 { 2348 nDest--; 2349 pEntry = Prev(pEntry); 2350 if(pEntry && 2351 (nActLevel >= ((SwOutlineContent*)pEntry->GetUserData())->GetOutlineLevel()|| 2352 CONTENT_TYPE_OUTLINE != 2353 ((SwTypeNumber*)pEntry->GetUserData())->GetTypeId())) 2354 { 2355 break; 2356 } 2357 } 2358 nDir = nDest - nActPos; 2359 } 2360 if(nDir) 2361 { 2362 pShell->MoveOutlinePara( nDir ); 2363 //Cursor wieder an die aktuelle Position setzen 2364 pShell->GotoOutline( nActPos + nDir); 2365 } 2366 } 2367 } 2368 else 2369 { 2370 if( pShell->IsProtectedOutlinePara() ) 2371 Sound::Beep(); //konnte nicht umgestuft werden 2372 else 2373 pShell->OutlineUpDown( nCmd == FN_ITEM_LEFT ? -1 : 1 ); 2374 } 2375 2376 pShell->ClearMark(); 2377 pShell->Pop(sal_False); //Cursor steht jetzt wieder an der akt. Ueberschrift 2378 pShell->EndAllAction(); 2379 if(aActiveContentArr[CONTENT_TYPE_OUTLINE]) 2380 aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); 2381 Display(sal_True); 2382 if(!bIsRoot) 2383 { 2384 const sal_uInt16 nCurrPos = pShell->GetOutlinePos(MAXLEVEL); 2385 SvLBoxEntry* pFirst = First(); 2386 2387 while( 0 != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst)) 2388 { 2389 if(((SwOutlineContent*)pFirst->GetUserData())->GetPos() == nCurrPos) 2390 { 2391 Select(pFirst); 2392 MakeVisible(pFirst); 2393 } 2394 } 2395 } 2396 } 2397 else 2398 Sound::Beep(); //konnte nicht verschoben werden 2399 } 2400 } 2401 } 2402 /*************************************************************************** 2403 Beschreibung: 2404 ***************************************************************************/ 2405 2406 2407 void SwContentTree::ShowTree() 2408 { 2409 aUpdTimer.Start(); 2410 SvTreeListBox::Show(); 2411 } 2412 2413 /*************************************************************************** 2414 Beschreibung: zusammengefaltet wird nicht geidlet 2415 ***************************************************************************/ 2416 2417 2418 void SwContentTree::HideTree() 2419 { 2420 aUpdTimer.Stop(); 2421 SvTreeListBox::Hide(); 2422 } 2423 2424 /*************************************************************************** 2425 Beschreibung: Kein Idle mit Focus oder waehrend des Dragging 2426 ***************************************************************************/ 2427 2428 2429 IMPL_LINK( SwContentTree, TimerUpdate, Timer*, EMPTYARG) 2430 { 2431 // kein Update waehrend D&D 2432 // Viewabfrage, da der Navigator zu spaet abgeraeumt wird 2433 SwView* pView = GetParentWindow()->GetCreateView(); 2434 if( (!HasFocus() || bViewHasChanged) && 2435 !bIsInDrag && !bIsInternalDrag && pView && 2436 pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() ) 2437 { 2438 bViewHasChanged = sal_False; 2439 bIsIdleClear = sal_False; 2440 SwWrtShell* pActShell = pView->GetWrtShellPtr(); 2441 if( bIsConstant && !lcl_FindShell( pActiveShell ) ) 2442 { 2443 SetActiveShell(pActShell); 2444 GetParentWindow()->UpdateListBox(); 2445 } 2446 2447 if(bIsActive && pActShell != GetWrtShell()) 2448 SetActiveShell(pActShell); 2449 else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) && 2450 HasContentChanged()) 2451 { 2452 FindActiveTypeAndRemoveUserData(); 2453 Display(sal_True); 2454 //Solution: Set focus 2455 if( bIsKeySpace ) 2456 { 2457 HideFocus(); 2458 ShowFocus( oldRectangle); 2459 bIsKeySpace = sal_False; 2460 } 2461 } 2462 } 2463 else if(!pView && bIsActive && !bIsIdleClear) 2464 { 2465 if(pActiveShell) 2466 SetActiveShell(0); 2467 Clear(); 2468 bIsIdleClear = sal_True; 2469 } 2470 return 0; 2471 } 2472 2473 /*************************************************************************** 2474 Beschreibung: 2475 ***************************************************************************/ 2476 2477 2478 DragDropMode SwContentTree::NotifyStartDrag( 2479 TransferDataContainer& rContainer, 2480 SvLBoxEntry* pEntry ) 2481 { 2482 DragDropMode eMode = (DragDropMode)0; 2483 if( bIsActive && nRootType == CONTENT_TYPE_OUTLINE && 2484 GetModel()->GetAbsPos( pEntry ) > 0 2485 && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly()) 2486 eMode = GetDragDropMode(); 2487 else if(!bIsActive && GetWrtShell()->GetView().GetDocShell()->HasName()) 2488 eMode = SV_DRAGDROP_APP_COPY; 2489 2490 sal_Int8 nDragMode; 2491 FillTransferData( rContainer, nDragMode ); 2492 bDocChgdInDragging = sal_False; 2493 bIsInternalDrag = sal_True; 2494 return eMode; 2495 } 2496 2497 2498 /*************************************************************************** 2499 Beschreibung : Nach dem Drag wird der aktuelle Absatz m i t 2500 Childs verschoben 2501 ***************************************************************************/ 2502 2503 2504 sal_Bool SwContentTree::NotifyMoving( SvLBoxEntry* pTarget, 2505 SvLBoxEntry* pEntry, SvLBoxEntry*& , sal_uLong& ) 2506 { 2507 if(!bDocChgdInDragging) 2508 { 2509 sal_uInt16 nTargetPos = 0; 2510 sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos(); 2511 if(!lcl_IsContent(pTarget)) 2512 nTargetPos = USHRT_MAX; 2513 else 2514 nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos(); 2515 if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt 2516 nTargetPos != USHRT_MAX) 2517 { 2518 SvLBoxEntry* pNext = Next(pTarget); 2519 if(pNext) 2520 nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() -1; 2521 else 2522 nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount())- 1; 2523 2524 } 2525 2526 DBG_ASSERT( pEntry && 2527 lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" ); 2528 GetParentWindow()->MoveOutline( nSourcePos, 2529 nTargetPos, 2530 sal_True); 2531 2532 aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); 2533 Display(sal_True); 2534 } 2535 //TreeListBox wird aus dem Dokument neu geladen 2536 return sal_False; 2537 } 2538 /*************************************************************************** 2539 Beschreibung : Nach dem Drag wird der aktuelle Absatz o h n e 2540 Childs verschoben 2541 ***************************************************************************/ 2542 2543 2544 sal_Bool SwContentTree::NotifyCopying( SvLBoxEntry* pTarget, 2545 SvLBoxEntry* pEntry, SvLBoxEntry*& , sal_uLong& ) 2546 { 2547 if(!bDocChgdInDragging) 2548 { 2549 sal_uInt16 nTargetPos = 0; 2550 sal_uInt16 nSourcePos = (( SwOutlineContent* )pEntry->GetUserData())->GetPos(); 2551 if(!lcl_IsContent(pTarget)) 2552 nTargetPos = USHRT_MAX; 2553 else 2554 nTargetPos = (( SwOutlineContent* )pTarget->GetUserData())->GetPos(); 2555 2556 if( MAXLEVEL > nOutlineLevel && // werden nicht alle Ebenen angezeigt 2557 nTargetPos != USHRT_MAX) 2558 { 2559 SvLBoxEntry* pNext = Next(pTarget); 2560 if(pNext) 2561 nTargetPos = (( SwOutlineContent* )pNext->GetUserData())->GetPos() - 1; 2562 else 2563 nTargetPos = static_cast<sal_uInt16>(GetWrtShell()->getIDocumentOutlineNodesAccess()->getOutlineNodesCount()) - 1; 2564 2565 } 2566 2567 2568 DBG_ASSERT( pEntry && 2569 lcl_IsContent(pEntry),"Source == 0 oder Source hat keinen Content" ); 2570 GetParentWindow()->MoveOutline( nSourcePos, nTargetPos, sal_False); 2571 2572 //TreeListBox wird aus dem Dokument neu geladen 2573 aActiveContentArr[CONTENT_TYPE_OUTLINE]->Invalidate(); 2574 Display(sal_True); 2575 } 2576 return sal_False; 2577 } 2578 2579 /*************************************************************************** 2580 Beschreibung: Kein Drop vor den ersten Eintrag - es ist ein SwContentType 2581 ***************************************************************************/ 2582 2583 sal_Bool SwContentTree::NotifyAcceptDrop( SvLBoxEntry* pEntry) 2584 { 2585 return pEntry != 0; 2586 } 2587 2588 2589 /*************************************************************************** 2590 Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt, 2591 * dann soll die Basisfunktion des Controls gerufen werden 2592 ***************************************************************************/ 2593 void SwContentTree::MouseButtonDown( const MouseEvent& rMEvt ) 2594 { 2595 Point aPos( rMEvt.GetPosPixel()); 2596 SvLBoxEntry* pEntry = GetEntry( aPos, sal_True ); 2597 if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0) 2598 Control::MouseButtonDown( rMEvt ); 2599 else 2600 SvTreeListBox::MouseButtonDown( rMEvt ); 2601 } 2602 2603 /*************************************************************************** 2604 Beschreibung: sofort aktualisieren 2605 ***************************************************************************/ 2606 2607 2608 void SwContentTree::GetFocus() 2609 { 2610 SwView* pActView = GetParentWindow()->GetCreateView(); 2611 if(pActView) 2612 { 2613 SwWrtShell* pActShell = pActView->GetWrtShellPtr(); 2614 if(bIsConstant && !lcl_FindShell(pActiveShell)) 2615 { 2616 SetActiveShell(pActShell); 2617 } 2618 2619 if(bIsActive && pActShell != GetWrtShell()) 2620 SetActiveShell(pActShell); 2621 else if( (bIsActive || (bIsConstant && pActShell == GetWrtShell())) && 2622 HasContentChanged()) 2623 { 2624 Display(sal_True); 2625 } 2626 } 2627 else if(bIsActive) 2628 Clear(); 2629 SvTreeListBox::GetFocus(); 2630 } 2631 2632 /*************************************************************************** 2633 Beschreibung: 2634 ***************************************************************************/ 2635 2636 2637 void SwContentTree::KeyInput(const KeyEvent& rEvent) 2638 { 2639 const KeyCode aCode = rEvent.GetKeyCode(); 2640 if(aCode.GetCode() == KEY_RETURN) 2641 { 2642 SvLBoxEntry* pEntry = FirstSelected(); 2643 if ( pEntry ) 2644 { 2645 switch(aCode.GetModifier()) 2646 { 2647 case KEY_MOD2: 2648 // Boxen umschalten 2649 GetParentWindow()->ToggleTree(); 2650 break; 2651 case KEY_MOD1: 2652 // RootModus umschalten 2653 ToggleToRoot(); 2654 break; 2655 case 0: 2656 if(lcl_IsContentType(pEntry)) 2657 { 2658 IsExpanded(pEntry) ? 2659 Collapse(pEntry) : 2660 Expand(pEntry); 2661 } 2662 else 2663 ContentDoubleClickHdl(0); 2664 break; 2665 } 2666 } 2667 } 2668 else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier()) 2669 { 2670 SvLBoxEntry* pEntry = FirstSelected(); 2671 if(pEntry && 2672 lcl_IsContent(pEntry) && 2673 ((SwContent*)pEntry->GetUserData())->GetParent()->IsDeletable() && 2674 !pActiveShell->GetView().GetDocShell()->IsReadOnly()) 2675 { 2676 EditEntry(pEntry, EDIT_MODE_DELETE); 2677 bViewHasChanged = sal_True; 2678 GetParentWindow()->UpdateListBox(); 2679 TimerUpdate(&aUpdTimer); 2680 GrabFocus(); 2681 } 2682 } 2683 //Solution: Make KEY_SPACE has same function as DoubleClick , 2684 //and realize multi-selection . 2685 else if(aCode.GetCode() == KEY_SPACE && 0 == aCode.GetModifier()) 2686 { 2687 2688 SvLBoxEntry* pEntry = GetCurEntry(); 2689 if( GetChildCount( pEntry ) == 0 ) 2690 bIsKeySpace = sal_True; 2691 Point tempPoint = GetEntryPosition( pEntry );//Change from "GetEntryPos" to "GetEntryPosition" for acc migration 2692 oldRectangle = GetFocusRect( pEntry,tempPoint.Y() ); 2693 2694 if(pEntry) 2695 { 2696 if(bIsActive || bIsConstant) 2697 { 2698 if(bIsConstant) 2699 { 2700 pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop(); 2701 } 2702 2703 SwContent* pCnt = (SwContent*)pEntry->GetUserData(); 2704 2705 sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); 2706 switch(nJumpType) 2707 { 2708 case CONTENT_TYPE_DRAWOBJECT: 2709 { 2710 SdrView* pDrawView = pActiveShell->GetDrawView(); 2711 if (pDrawView) 2712 { 2713 pDrawView->SdrEndTextEdit();//Change from "EndTextEdit" to "SdrEndTextEdit" for acc migration 2714 2715 SdrModel* pDrawModel = pActiveShell->GetDoc()->GetDrawModel(); 2716 SdrPage* pPage = pDrawModel->GetPage(0); 2717 sal_uInt32 nCount = pPage->GetObjCount(); 2718 sal_Bool hasObjectMarked = sal_False; 2719 2720 SdrObject* pObject = NULL; 2721 pObject = GetDrawingObjectsByContent( pCnt ); 2722 if( pObject ) 2723 { 2724 SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/); 2725 if( pPV ) 2726 { 2727 sal_Bool bUnMark = pDrawView->IsObjMarked(pObject); 2728 pDrawView->MarkObj( pObject, pPV, bUnMark); 2729 2730 } 2731 } 2732 for( sal_uInt32 i=0; i< nCount; i++ ) 2733 { 2734 SdrObject* pTemp = pPage->GetObj(i); 2735 sal_uInt16 nCmpId; 2736 sal_Bool bMark = pDrawView->IsObjMarked(pTemp); 2737 switch( pTemp->GetObjIdentifier() ) 2738 { 2739 case OBJ_GRUP: 2740 case OBJ_TEXT: 2741 case OBJ_TEXTEXT: 2742 case OBJ_wegFITTEXT: 2743 case OBJ_LINE: 2744 case OBJ_RECT: 2745 case OBJ_CIRC: 2746 case OBJ_SECT: 2747 case OBJ_CARC: 2748 case OBJ_CCUT: 2749 case OBJ_POLY: 2750 case OBJ_PLIN: 2751 case OBJ_PATHLINE: 2752 case OBJ_PATHFILL: 2753 case OBJ_FREELINE: 2754 case OBJ_FREEFILL: 2755 case OBJ_PATHPOLY: 2756 case OBJ_PATHPLIN: 2757 case OBJ_CAPTION: 2758 case OBJ_CUSTOMSHAPE: 2759 nCmpId = OBJ_GRUP; 2760 if( bMark ) 2761 hasObjectMarked = sal_True; 2762 break; 2763 default: 2764 nCmpId = pTemp->GetObjIdentifier(); 2765 if ( bMark ) 2766 { 2767 SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/); 2768 if (pPV) 2769 { 2770 pDrawView->MarkObj(pTemp, pPV, sal_True); 2771 } 2772 } 2773 } 2774 //mod end 2775 } 2776 if ( pActiveShell && !hasObjectMarked ) 2777 { 2778 SwEditWin& pEditWindow = 2779 pActiveShell->GetView().GetEditWin(); 2780 if( &pEditWindow ) 2781 { 2782 KeyCode tempKeycode( KEY_ESCAPE ); 2783 KeyEvent rKEvt( 0 , tempKeycode ); 2784 ((Window*)&pEditWindow)->KeyInput( rKEvt ); 2785 2786 } 2787 //rView.GetEditWin().GrabFocus(); 2788 } 2789 } 2790 } 2791 break; 2792 } 2793 2794 2795 bViewHasChanged = sal_True; 2796 } 2797 } 2798 2799 } 2800 else 2801 SvTreeListBox::KeyInput(rEvent); 2802 2803 } 2804 2805 /*************************************************************************** 2806 Beschreibung: 2807 ***************************************************************************/ 2808 2809 2810 void SwContentTree::RequestHelp( const HelpEvent& rHEvt ) 2811 { 2812 sal_Bool bCallBase = sal_True; 2813 if( rHEvt.GetMode() & HELPMODE_QUICK ) 2814 { 2815 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); 2816 SvLBoxEntry* pEntry = GetEntry( aPos ); 2817 if( pEntry ) 2818 { 2819 sal_uInt16 nType; 2820 sal_Bool bBalloon = sal_False; 2821 sal_Bool bContent = sal_False; 2822 void* pUserData = pEntry->GetUserData(); 2823 if(lcl_IsContentType(pEntry)) 2824 nType = ((SwContentType*)pUserData)->GetType(); 2825 else 2826 { 2827 nType = ((SwContent*)pUserData)->GetParent()->GetType(); 2828 bContent = sal_True; 2829 } 2830 String sEntry; 2831 sal_Bool bRet = sal_False; 2832 if(bContent) 2833 { 2834 switch( nType ) 2835 { 2836 case CONTENT_TYPE_URLFIELD: 2837 sEntry = ((SwURLFieldContent*)pUserData)->GetURL(); 2838 bRet = sal_True; 2839 break; 2840 2841 case CONTENT_TYPE_POSTIT: 2842 sEntry = ((SwPostItContent*)pUserData)->GetName(); 2843 bRet = sal_True; 2844 if(Help::IsBalloonHelpEnabled()) 2845 bBalloon = sal_True; 2846 break; 2847 case CONTENT_TYPE_OUTLINE: 2848 sEntry = ((SwOutlineContent*)pUserData)->GetName(); 2849 bRet = sal_True; 2850 break; 2851 case CONTENT_TYPE_GRAPHIC: 2852 sEntry = ((SwGraphicContent*)pUserData)->GetLink(); 2853 #if OSL_DEBUG_LEVEL > 1 2854 sEntry += ' '; 2855 sEntry += String::CreateFromInt32( 2856 ((SwGraphicContent*)pUserData)->GetYPos()); 2857 #endif 2858 bRet = sal_True; 2859 break; 2860 #if OSL_DEBUG_LEVEL > 1 2861 case CONTENT_TYPE_TABLE: 2862 case CONTENT_TYPE_FRAME: 2863 sEntry = String::CreateFromInt32( 2864 ((SwContent*)pUserData)->GetYPos() ); 2865 bRet = sal_True; 2866 break; 2867 #endif 2868 } 2869 if(((SwContent*)pUserData)->IsInvisible()) 2870 { 2871 if(sEntry.Len()) 2872 sEntry += C2S(", "); 2873 sEntry += sInvisible; 2874 bRet = sal_True; 2875 } 2876 } 2877 else 2878 { 2879 sal_uInt16 nMemberCount = ((SwContentType*)pUserData)->GetMemberCount(); 2880 sEntry = String::CreateFromInt32(nMemberCount); 2881 sEntry += ' '; 2882 sEntry += nMemberCount == 1 2883 ? ((SwContentType*)pUserData)->GetSingleName() 2884 : ((SwContentType*)pUserData)->GetName(); 2885 bRet = sal_True; 2886 } 2887 if(bRet) 2888 { 2889 SvLBoxTab* pTab; 2890 SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); 2891 if( pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA()) 2892 { 2893 aPos = GetEntryPosition( pEntry ); 2894 2895 aPos.X() = GetTabPos( pEntry, pTab ); 2896 Size aSize( pItem->GetSize( this, pEntry ) ); 2897 2898 if((aPos.X() + aSize.Width()) > GetSizePixel().Width()) 2899 aSize.Width() = GetSizePixel().Width() - aPos.X(); 2900 2901 aPos = OutputToScreenPixel(aPos); 2902 Rectangle aItemRect( aPos, aSize ); 2903 if(bBalloon) 2904 { 2905 aPos.X() += aSize.Width(); 2906 Help::ShowBalloon( this, aPos, aItemRect, sEntry ); 2907 } 2908 else 2909 Help::ShowQuickHelp( this, aItemRect, sEntry, 2910 QUICKHELP_LEFT|QUICKHELP_VCENTER ); 2911 bCallBase = sal_False; 2912 } 2913 } 2914 else 2915 { 2916 Help::ShowQuickHelp( this, Rectangle(), aEmptyStr, 0 ); 2917 bCallBase = sal_False; 2918 } 2919 } 2920 } 2921 if( bCallBase ) 2922 Window::RequestHelp( rHEvt ); 2923 } 2924 2925 /*************************************************************************** 2926 Beschreibung: 2927 ***************************************************************************/ 2928 2929 2930 void SwContentTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) 2931 { 2932 SvLBoxEntry* pFirst = FirstSelected(); 2933 switch( nSelectedPopupEntry ) 2934 { 2935 //Outlinelevel 2936 case 101: 2937 case 102: 2938 case 103: 2939 case 104: 2940 case 105: 2941 case 106: 2942 case 107: 2943 case 108: 2944 case 109: 2945 case 110: 2946 nSelectedPopupEntry -= 100; 2947 if(nOutlineLevel != nSelectedPopupEntry ) 2948 SetOutlineLevel((sal_Int8)nSelectedPopupEntry); 2949 break; 2950 case 201: 2951 case 202: 2952 case 203: 2953 GetParentWindow()->SetRegionDropMode(nSelectedPopupEntry - 201); 2954 break; 2955 case 401: 2956 case 402: 2957 EditEntry(pFirst, nSelectedPopupEntry == 401 ? EDIT_MODE_RMV_IDX : EDIT_MODE_UPD_IDX); 2958 break; 2959 // Eintrag bearbeiten 2960 case 403: 2961 EditEntry(pFirst, EDIT_MODE_EDIT); 2962 break; 2963 case 404: 2964 EditEntry(pFirst, EDIT_UNPROTECT_TABLE); 2965 break; 2966 case 405 : 2967 { 2968 const SwTOXBase* pBase = ((SwTOXBaseContent*)pFirst->GetUserData()) 2969 ->GetTOXBase(); 2970 pActiveShell->SetTOXBaseReadonly(*pBase, !pActiveShell->IsTOXBaseReadonly(*pBase)); 2971 } 2972 break; 2973 case 4: 2974 break; 2975 case 501: 2976 EditEntry(pFirst, EDIT_MODE_DELETE); 2977 break; 2978 case 502 : 2979 EditEntry(pFirst, EDIT_MODE_RENAME); 2980 break; 2981 case 600: 2982 pActiveShell->GetView().GetPostItMgr()->Show(); 2983 break; 2984 case 601: 2985 pActiveShell->GetView().GetPostItMgr()->Hide(); 2986 break; 2987 case 602: 2988 { 2989 pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0); 2990 pActiveShell->GetView().GetPostItMgr()->Delete(); 2991 break; 2992 } 2993 //Anzeige 2994 default: // nSelectedPopupEntry > 300 2995 if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400) 2996 { 2997 nSelectedPopupEntry -= 300; 2998 SwView *pView = SwModule::GetFirstView(); 2999 while (pView) 3000 { 3001 nSelectedPopupEntry --; 3002 if(nSelectedPopupEntry == 0) 3003 { 3004 SetConstantShell(&pView->GetWrtShell()); 3005 break; 3006 } 3007 pView = SwModule::GetNextView(pView); 3008 } 3009 if(nSelectedPopupEntry) 3010 { 3011 bViewHasChanged = bIsActive = nSelectedPopupEntry == 1; 3012 bIsConstant = sal_False; 3013 Display(nSelectedPopupEntry == 1); 3014 } 3015 } 3016 } 3017 GetParentWindow()->UpdateListBox(); 3018 } 3019 3020 /*************************************************************************** 3021 Beschreibung: 3022 ***************************************************************************/ 3023 3024 3025 void SwContentTree::SetOutlineLevel(sal_uInt8 nSet) 3026 { 3027 nOutlineLevel = nSet; 3028 pConfig->SetOutlineLevel( nOutlineLevel ); 3029 SwContentType** ppContentT = bIsActive ? 3030 &aActiveContentArr[CONTENT_TYPE_OUTLINE] : 3031 &aHiddenContentArr[CONTENT_TYPE_OUTLINE]; 3032 if(*ppContentT) 3033 { 3034 (*ppContentT)->SetOutlineLevel(nOutlineLevel); 3035 (*ppContentT)->Init(); 3036 } 3037 Display(bIsActive); 3038 } 3039 3040 /*************************************************************************** 3041 Beschreibung: Moduswechsel: gedropptes Doc anzeigen 3042 ***************************************************************************/ 3043 3044 3045 void SwContentTree::ShowHiddenShell() 3046 { 3047 if(pHiddenShell) 3048 { 3049 bIsConstant = sal_False; 3050 bIsActive = sal_False; 3051 Display(sal_False); 3052 } 3053 } 3054 3055 /*************************************************************************** 3056 Beschreibung: Moduswechsel: aktive Sicht anzeigen 3057 ***************************************************************************/ 3058 3059 3060 void SwContentTree::ShowActualView() 3061 { 3062 bIsActive = sal_True; 3063 bIsConstant = sal_False; 3064 Display(sal_True); 3065 GetParentWindow()->UpdateListBox(); 3066 } 3067 3068 /*-----------------20.11.96 13.34------------------- 3069 Beschreibung: Hier sollen die Buttons zum Verschieben von 3070 Outlines en-/disabled werden 3071 --------------------------------------------------*/ 3072 3073 sal_Bool SwContentTree::Select( SvLBoxEntry* pEntry, sal_Bool bSelect ) 3074 { 3075 if(!pEntry) 3076 return sal_False; 3077 sal_Bool bEnable = sal_False; 3078 SvLBoxEntry* pParentEntry = GetParent(pEntry); 3079 if(!bIsLastReadOnly && (!IsVisible() || 3080 ((bIsRoot && nRootType == CONTENT_TYPE_OUTLINE && pParentEntry) || 3081 (lcl_IsContent(pEntry) && ((SwContentType*)pParentEntry->GetUserData())->GetType() == CONTENT_TYPE_OUTLINE)))) 3082 bEnable = sal_True; 3083 SwNavigationPI* pNavi = GetParentWindow(); 3084 pNavi->aContentToolBox.EnableItem(FN_ITEM_UP , bEnable); 3085 pNavi->aContentToolBox.EnableItem(FN_ITEM_DOWN, bEnable); 3086 pNavi->aContentToolBox.EnableItem(FN_ITEM_LEFT, bEnable); 3087 pNavi->aContentToolBox.EnableItem(FN_ITEM_RIGHT,bEnable); 3088 3089 return SvTreeListBox::Select(pEntry, bSelect); 3090 } 3091 3092 /*-----------------27.11.96 12.56------------------- 3093 3094 --------------------------------------------------*/ 3095 3096 void SwContentTree::SetRootType(sal_uInt16 nType) 3097 { 3098 nRootType = nType; 3099 bIsRoot = sal_True; 3100 pConfig->SetRootType( nRootType ); 3101 } 3102 3103 /*-----------------10.01.97 12.19------------------- 3104 3105 --------------------------------------------------*/ 3106 3107 void SwContentType::RemoveNewline(String& rEntry) 3108 { 3109 sal_Unicode* pStr = rEntry.GetBufferAccess(); 3110 for(xub_StrLen i = rEntry.Len(); i; --i, ++pStr ) 3111 { 3112 if( *pStr == 10 || *pStr == 13 ) 3113 *pStr = 0x20; 3114 } 3115 } 3116 3117 /*-----------------14.01.97 16.38------------------- 3118 3119 --------------------------------------------------*/ 3120 3121 void SwContentTree::EditEntry(SvLBoxEntry* pEntry, sal_uInt8 nMode) 3122 { 3123 SwContent* pCnt = (SwContent*)pEntry->GetUserData(); 3124 GotoContent(pCnt); 3125 sal_uInt16 nType = pCnt->GetParent()->GetType(); 3126 sal_uInt16 nSlot = 0; 3127 3128 uno::Reference< container::XNameAccess > xNameAccess, xSecond, xThird; 3129 switch(nType) 3130 { 3131 case CONTENT_TYPE_TABLE : 3132 if(nMode == EDIT_UNPROTECT_TABLE) 3133 { 3134 pActiveShell->GetView().GetDocShell()-> 3135 GetDoc()->UnProtectCells( pCnt->GetName()); 3136 } 3137 else if(nMode == EDIT_MODE_DELETE) 3138 { 3139 pActiveShell->StartAction(); 3140 String sTable = SW_RES(STR_TABLE_NAME); 3141 SwRewriter aRewriterTableName; 3142 aRewriterTableName.AddRule(UNDO_ARG1, SW_RES(STR_START_QUOTE)); 3143 aRewriterTableName.AddRule(UNDO_ARG2, pCnt->GetName()); 3144 aRewriterTableName.AddRule(UNDO_ARG3, SW_RES(STR_END_QUOTE)); 3145 sTable = aRewriterTableName.Apply(sTable); 3146 3147 SwRewriter aRewriter; 3148 aRewriter.AddRule(UNDO_ARG1, sTable); 3149 pActiveShell->StartUndo(UNDO_DELETE, &aRewriter); 3150 pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL); 3151 pActiveShell->DeleteRow(); 3152 pActiveShell->EndUndo(); 3153 pActiveShell->EndAction(); 3154 } 3155 else if(nMode == EDIT_MODE_RENAME) 3156 { 3157 uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); 3158 uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY); 3159 xNameAccess = xTables->getTextTables(); 3160 } 3161 else 3162 nSlot = FN_FORMAT_TABLE_DLG; 3163 break; 3164 3165 case CONTENT_TYPE_GRAPHIC : 3166 if(nMode == EDIT_MODE_DELETE) 3167 { 3168 pActiveShell->DelRight(); 3169 } 3170 else if(nMode == EDIT_MODE_RENAME) 3171 { 3172 uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); 3173 uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY); 3174 xNameAccess = xGraphics->getGraphicObjects(); 3175 uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); 3176 xSecond = xFrms->getTextFrames(); 3177 uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY); 3178 xThird = xObjs->getEmbeddedObjects(); 3179 } 3180 else 3181 nSlot = FN_FORMAT_GRAFIC_DLG; 3182 break; 3183 3184 case CONTENT_TYPE_FRAME : 3185 case CONTENT_TYPE_OLE : 3186 if(nMode == EDIT_MODE_DELETE) 3187 { 3188 pActiveShell->DelRight(); 3189 } 3190 else if(nMode == EDIT_MODE_RENAME) 3191 { 3192 uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); 3193 uno::Reference< text::XTextFramesSupplier > xFrms(xModel, uno::UNO_QUERY); 3194 uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY); 3195 if(CONTENT_TYPE_FRAME == nType) 3196 { 3197 xNameAccess = xFrms->getTextFrames(); 3198 xSecond = xObjs->getEmbeddedObjects(); 3199 } 3200 else 3201 { 3202 xNameAccess = xObjs->getEmbeddedObjects(); 3203 xSecond = xFrms->getTextFrames(); 3204 } 3205 uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY); 3206 xThird = xGraphics->getGraphicObjects(); 3207 } 3208 else 3209 nSlot = FN_FORMAT_FRAME_DLG; 3210 break; 3211 case CONTENT_TYPE_BOOKMARK : 3212 if(nMode == EDIT_MODE_DELETE) 3213 { 3214 IDocumentMarkAccess* const pMarkAccess = pActiveShell->getIDocumentMarkAccess(); 3215 pMarkAccess->deleteMark( pMarkAccess->findMark(pCnt->GetName()) ); 3216 } 3217 else if(nMode == EDIT_MODE_RENAME) 3218 { 3219 uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); 3220 uno::Reference< text::XBookmarksSupplier > xBkms(xModel, uno::UNO_QUERY); 3221 xNameAccess = xBkms->getBookmarks(); 3222 } 3223 else 3224 nSlot = FN_INSERT_BOOKMARK; 3225 break; 3226 3227 case CONTENT_TYPE_REGION : 3228 if(nMode == EDIT_MODE_RENAME) 3229 { 3230 uno::Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); 3231 uno::Reference< text::XTextSectionsSupplier > xSects(xModel, uno::UNO_QUERY); 3232 xNameAccess = xSects->getTextSections(); 3233 } 3234 else 3235 nSlot = FN_EDIT_REGION; 3236 break; 3237 3238 case CONTENT_TYPE_URLFIELD: 3239 nSlot = FN_EDIT_HYPERLINK; 3240 break; 3241 case CONTENT_TYPE_REFERENCE: 3242 nSlot = FN_EDIT_FIELD; 3243 break; 3244 3245 case CONTENT_TYPE_POSTIT: 3246 pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); 3247 if(nMode == EDIT_MODE_DELETE) 3248 { 3249 if (((SwPostItContent*)pCnt)->IsPostIt()) 3250 { 3251 pActiveShell->GetView().GetPostItMgr()->SetActiveSidebarWin(0); 3252 pActiveShell->DelRight(); 3253 } 3254 /* 3255 // this code can be used once we want redline comments in the margin 3256 else 3257 { 3258 SwMarginWin* pComment = pActiveShell->GetView().GetPostItMgr()->GetPostIt(((SwPostItContent*)pCnt)->GetRedline()); 3259 if (pComment) 3260 pComment->Delete(); 3261 } 3262 */ 3263 } 3264 else 3265 { 3266 if (((SwPostItContent*)pCnt)->IsPostIt()) 3267 nSlot = FN_POSTIT; 3268 else 3269 nSlot = FN_REDLINE_COMMENT; 3270 } 3271 break; 3272 case CONTENT_TYPE_INDEX: 3273 { 3274 const SwTOXBase* pBase = ((SwTOXBaseContent*)pCnt)->GetTOXBase(); 3275 switch(nMode) 3276 { 3277 case EDIT_MODE_EDIT: 3278 if(pBase) 3279 { 3280 SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, (void*)pBase); 3281 pActiveShell->GetView().GetViewFrame()-> 3282 GetDispatcher()->Execute(FN_INSERT_MULTI_TOX, 3283 SFX_CALLMODE_ASYNCHRON, &aPtrItem, 0L); 3284 3285 } 3286 break; 3287 case EDIT_MODE_RMV_IDX: 3288 case EDIT_MODE_DELETE: 3289 { 3290 if( pBase ) 3291 pActiveShell->DeleteTOX(*pBase, EDIT_MODE_DELETE == nMode); 3292 } 3293 break; 3294 case EDIT_MODE_UPD_IDX: 3295 case EDIT_MODE_RENAME: 3296 { 3297 Reference< frame::XModel > xModel = pActiveShell->GetView().GetDocShell()->GetBaseModel(); 3298 Reference< XDocumentIndexesSupplier > xIndexes(xModel, UNO_QUERY); 3299 Reference< XIndexAccess> xIdxAcc(xIndexes->getDocumentIndexes()); 3300 Reference< XNameAccess >xLocalNameAccess(xIdxAcc, UNO_QUERY); 3301 if(EDIT_MODE_RENAME == nMode) 3302 xNameAccess = xLocalNameAccess; 3303 else if(xLocalNameAccess.is() && xLocalNameAccess->hasByName(pBase->GetTOXName())) 3304 { 3305 Any aIdx = xLocalNameAccess->getByName(pBase->GetTOXName()); 3306 Reference< XDocumentIndex> xIdx; 3307 if(aIdx >>= xIdx) 3308 xIdx->update(); 3309 } 3310 } 3311 break; 3312 } 3313 } 3314 break; 3315 case CONTENT_TYPE_DRAWOBJECT : 3316 if(EDIT_MODE_DELETE == nMode) 3317 nSlot = SID_DELETE; 3318 break; 3319 } 3320 if(nSlot) 3321 pActiveShell->GetView().GetViewFrame()-> 3322 GetDispatcher()->Execute(nSlot, SFX_CALLMODE_ASYNCHRON); 3323 else if(xNameAccess.is()) 3324 { 3325 uno::Any aObj = xNameAccess->getByName(pCnt->GetName()); 3326 uno::Reference< uno::XInterface > xTmp; 3327 aObj >>= xTmp; 3328 uno::Reference< container::XNamed > xNamed(xTmp, uno::UNO_QUERY); 3329 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 3330 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 3331 3332 AbstractSwRenameXNamedDlg* pDlg = pFact->CreateSwRenameXNamedDlg( this, xNamed, xNameAccess, DLG_RENAME_XNAMED ); 3333 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 3334 if(xSecond.is()) 3335 pDlg->SetAlternativeAccess( xSecond, xThird); 3336 3337 String sForbiddenChars; 3338 if(CONTENT_TYPE_BOOKMARK == nType) 3339 { 3340 sForbiddenChars = C2S("/\\@:*?\";,.#"); 3341 } 3342 else if(CONTENT_TYPE_TABLE == nType) 3343 { 3344 sForbiddenChars = C2S(" .<>"); 3345 } 3346 pDlg->SetForbiddenChars(sForbiddenChars); 3347 pDlg->Execute(); 3348 delete pDlg; 3349 } 3350 } 3351 3352 /*-----------------14.01.97 16.53------------------- 3353 3354 --------------------------------------------------*/ 3355 3356 void SwContentTree::GotoContent(SwContent* pCnt) 3357 { 3358 pActiveShell->EnterStdMode(); 3359 3360 sal_Bool bSel = sal_False; 3361 sal_uInt16 nJumpType = pCnt->GetParent()->GetType(); 3362 switch(nJumpType) 3363 { 3364 case CONTENT_TYPE_OUTLINE : 3365 { 3366 pActiveShell->GotoOutline(((SwOutlineContent*)pCnt)->GetPos()); 3367 } 3368 break; 3369 case CONTENT_TYPE_TABLE : 3370 { 3371 pActiveShell->GotoTable(pCnt->GetName()); 3372 } 3373 break; 3374 case CONTENT_TYPE_FRAME : 3375 case CONTENT_TYPE_GRAPHIC : 3376 case CONTENT_TYPE_OLE : 3377 { 3378 if(pActiveShell->GotoFly(pCnt->GetName())) 3379 bSel = sal_True; 3380 } 3381 break; 3382 case CONTENT_TYPE_BOOKMARK: 3383 { 3384 pActiveShell->GotoMark(pCnt->GetName()); 3385 } 3386 break; 3387 case CONTENT_TYPE_REGION : 3388 { 3389 pActiveShell->GotoRegion(pCnt->GetName()); 3390 } 3391 break; 3392 case CONTENT_TYPE_URLFIELD: 3393 { 3394 if(pActiveShell->GotoINetAttr( 3395 *((SwURLFieldContent*)pCnt)->GetINetAttr() )) 3396 { 3397 pActiveShell->Right( CRSR_SKIP_CHARS, sal_True, 1, sal_False); 3398 pActiveShell->SwCrsrShell::SelectTxtAttr( RES_TXTATR_INETFMT, sal_True ); 3399 } 3400 3401 } 3402 break; 3403 case CONTENT_TYPE_REFERENCE: 3404 { 3405 pActiveShell->GotoRefMark(pCnt->GetName()); 3406 } 3407 break; 3408 case CONTENT_TYPE_INDEX: 3409 { 3410 if (!pActiveShell->GotoNextTOXBase(&pCnt->GetName())) 3411 pActiveShell->GotoPrevTOXBase(&pCnt->GetName()); 3412 } 3413 break; 3414 case CONTENT_TYPE_POSTIT: 3415 pActiveShell->GetView().GetPostItMgr()->AssureStdModeAtShell(); 3416 if (((SwPostItContent*)pCnt)->IsPostIt()) 3417 pActiveShell->GotoFld(*((SwPostItContent*)pCnt)->GetPostIt()); 3418 else 3419 pActiveShell->GetView().GetDocShell()->GetWrtShell()->GotoRedline( 3420 pActiveShell->GetView().GetDocShell()->GetWrtShell()->FindRedlineOfData(((SwPostItContent*)pCnt)->GetRedline()->GetRedlineData())); 3421 3422 break; 3423 case CONTENT_TYPE_DRAWOBJECT: 3424 { 3425 SdrView* pDrawView = pActiveShell->GetDrawView(); 3426 if (pDrawView) 3427 { 3428 pDrawView->SdrEndTextEdit(); 3429 pDrawView->UnmarkAll(); 3430 SdrModel* _pModel = pActiveShell->getIDocumentDrawModelAccess()->GetDrawModel(); 3431 SdrPage* pPage = _pModel->GetPage(0); 3432 sal_uInt32 nCount = pPage->GetObjCount(); 3433 for( sal_uInt32 i=0; i< nCount; i++ ) 3434 { 3435 SdrObject* pTemp = pPage->GetObj(i); 3436 // --> OD 2006-03-09 #i51726# - all drawing objects can be named now 3437 // if(pTemp->ISA(SdrObjGroup) && pTemp->GetName() == pCnt->GetName()) 3438 if ( pTemp->GetName() == pCnt->GetName() ) 3439 // <-- 3440 { 3441 SdrPageView* pPV = pDrawView->GetSdrPageView(); 3442 if( pPV ) 3443 { 3444 pDrawView->MarkObj( pTemp, pPV ); 3445 } 3446 } 3447 } 3448 } 3449 } 3450 break; 3451 } 3452 if(bSel) 3453 { 3454 pActiveShell->HideCrsr(); 3455 pActiveShell->EnterSelFrmMode(); 3456 } 3457 SwView& rView = pActiveShell->GetView(); 3458 rView.StopShellTimer(); 3459 rView.GetPostItMgr()->SetActiveSidebarWin(0); 3460 rView.GetEditWin().GrabFocus(); 3461 } 3462 /*-----------------06.02.97 19.14------------------- 3463 Jetzt nochtdie passende text::Bookmark 3464 --------------------------------------------------*/ 3465 3466 NaviContentBookmark::NaviContentBookmark() 3467 : 3468 nDocSh(0), 3469 nDefDrag( REGION_MODE_NONE ) 3470 { 3471 } 3472 3473 /*-----------------06.02.97 20.12------------------- 3474 3475 --------------------------------------------------*/ 3476 3477 NaviContentBookmark::NaviContentBookmark( const String &rUrl, 3478 const String& rDesc, 3479 sal_uInt16 nDragType, 3480 const SwDocShell* pDocSh ) : 3481 aUrl( rUrl ), 3482 aDescr(rDesc), 3483 nDocSh((long)pDocSh), 3484 nDefDrag( nDragType ) 3485 { 3486 } 3487 3488 void NaviContentBookmark::Copy( TransferDataContainer& rData ) const 3489 { 3490 rtl_TextEncoding eSysCSet = gsl_getSystemTextEncoding(); 3491 3492 ByteString sStr( aUrl, eSysCSet ); 3493 sStr += static_cast< char >(NAVI_BOOKMARK_DELIM); 3494 sStr += ByteString( aDescr, eSysCSet ); 3495 sStr += static_cast< char >(NAVI_BOOKMARK_DELIM); 3496 sStr += ByteString::CreateFromInt32( nDefDrag ); 3497 sStr += static_cast< char >(NAVI_BOOKMARK_DELIM); 3498 sStr += ByteString::CreateFromInt32( nDocSh ); 3499 rData.CopyByteString( SOT_FORMATSTR_ID_SONLK, sStr ); 3500 } 3501 3502 sal_Bool NaviContentBookmark::Paste( TransferableDataHelper& rData ) 3503 { 3504 String sStr; 3505 sal_Bool bRet = rData.GetString( SOT_FORMATSTR_ID_SONLK, sStr ); 3506 if( bRet ) 3507 { 3508 xub_StrLen nPos = 0; 3509 aUrl = sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ); 3510 aDescr = sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ); 3511 nDefDrag= (sal_uInt16)sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32(); 3512 nDocSh = sStr.GetToken(0, NAVI_BOOKMARK_DELIM, nPos ).ToInt32(); 3513 } 3514 return bRet; 3515 } 3516 3517 3518 /* -----------------------------09.12.99 13:50-------------------------------- 3519 3520 ---------------------------------------------------------------------------*/ 3521 class SwContentLBoxString : public SvLBoxString 3522 { 3523 public: 3524 SwContentLBoxString( SvLBoxEntry* pEntry, sal_uInt16 nFlags, 3525 const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {} 3526 3527 virtual void Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 3528 SvLBoxEntry* pEntry); 3529 }; 3530 3531 /* -----------------------------09.12.99 13:49-------------------------------- 3532 3533 ---------------------------------------------------------------------------*/ 3534 void SwContentTree::InitEntry(SvLBoxEntry* pEntry, 3535 const XubString& rStr ,const Image& rImg1,const Image& rImg2, 3536 SvLBoxButtonKind eButtonKind) 3537 { 3538 sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2" 3539 SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); 3540 SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite ); 3541 SwContentLBoxString* pStr = new SwContentLBoxString( pEntry, 0, pCol->GetText() ); 3542 pEntry->ReplaceItem( pStr, nColToHilite ); 3543 } 3544 /* -----------------------------09.12.99 13:49-------------------------------- 3545 3546 ---------------------------------------------------------------------------*/ 3547 void SwContentLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 3548 SvLBoxEntry* pEntry ) 3549 { 3550 if(lcl_IsContent(pEntry) && 3551 ((SwContent *)pEntry->GetUserData())->IsInvisible()) 3552 { 3553 //* pCont = (SwContent*)pEntry->GetUserData(); 3554 Font aOldFont( rDev.GetFont()); 3555 Font aFont(aOldFont); 3556 Color aCol( COL_LIGHTGRAY ); 3557 aFont.SetColor( aCol ); 3558 rDev.SetFont( aFont ); 3559 rDev.DrawText( rPos, GetText() ); 3560 rDev.SetFont( aOldFont ); 3561 } 3562 // IA2 CWS. MT: Removed for now (also in SvLBoxEntry) - only used in Sw/Sd/ScContentLBoxString, they should decide if they need this 3563 /* 3564 else if (pEntry->IsMarked()) 3565 { 3566 rDev.DrawText( rPos, GetText() ); 3567 XubString str; 3568 str = XubString::CreateFromAscii("*"); 3569 Point rPosStar(rPos.X()-6,rPos.Y()); 3570 Font aOldFont( rDev.GetFont()); 3571 Font aFont(aOldFont); 3572 Color aCol( aOldFont.GetColor() ); 3573 aCol.DecreaseLuminance( 200 ); 3574 aFont.SetColor( aCol ); 3575 rDev.SetFont( aFont ); 3576 rDev.DrawText( rPosStar, str); 3577 rDev.SetFont( aOldFont ); 3578 } 3579 */ 3580 else 3581 SvLBoxString::Paint( rPos, rDev, nFlags, pEntry); 3582 } 3583 /* -----------------------------06.05.2002 10:20------------------------------ 3584 3585 ---------------------------------------------------------------------------*/ 3586 void SwContentTree::DataChanged( const DataChangedEvent& rDCEvt ) 3587 { 3588 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 3589 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 3590 { 3591 sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; 3592 aEntryImages = ImageList(SW_RES(nResId)); 3593 FindActiveTypeAndRemoveUserData(); 3594 Display(sal_True); 3595 } 3596 SvTreeListBox::DataChanged( rDCEvt ); 3597 } 3598 3599 3600 sal_Int32 SwContentTree::GetEntryRealChildsNum( SvLBoxEntry* pParent ) const 3601 { 3602 // ist es ein Inhaltstyp? 3603 if(lcl_IsContentType(pParent)) 3604 { 3605 if(!pParent->HasChilds()) 3606 { 3607 SwContentType* pCntType = (SwContentType*)pParent->GetUserData(); 3608 return pCntType->GetMemberCount(); 3609 } 3610 } 3611 return 0; 3612 } 3613