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