1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 // MARKER(update_precomp.py): autogen include statement, do not remove 25 #include "precompiled_sw.hxx" 26 27 #ifndef _SVSTDARR_HXX 28 #define _SVSTDARR_STRINGSDTOR 29 #include <svl/svstdarr.hxx> 30 #endif 31 #include <vcl/msgbox.hxx> 32 #include <svl/stritem.hxx> 33 #include <sfx2/fcontnr.hxx> 34 #include <sfx2/linkmgr.hxx> 35 #include <sfx2/dispatch.hxx> 36 #include <svl/urihelper.hxx> 37 #include <sfx2/docfile.hxx> 38 #include <vcl/help.hxx> 39 #include <sot/filelist.hxx> 40 #include <svl/eitem.hxx> 41 #include <svl/urlbmk.hxx> 42 #include <svtools/filter.hxx> 43 #include <sfx2/docinsert.hxx> 44 #include <sfx2/filedlghelper.hxx> 45 46 #include <sfx2/app.hxx> 47 #include <swmodule.hxx> 48 #include <wrtsh.hxx> 49 #include <view.hxx> 50 #include <errhdl.hxx> 51 #include <docsh.hxx> 52 #include <content.hxx> 53 #include <edglbldc.hxx> 54 #include <section.hxx> 55 #include <tox.hxx> 56 #include <cnttab.hxx> 57 #define NAVIPI_CXX 58 #include <navipi.hxx> 59 #include <navicont.hxx> 60 #include <edtwin.hxx> 61 #include <uitool.hxx> 62 63 #include <cmdid.h> 64 #include <helpid.h> 65 #ifndef _NAVIPI_HRC 66 #include <navipi.hrc> 67 #endif 68 #ifndef _UTLUI_HRC 69 #include <utlui.hrc> 70 #endif 71 #ifndef _COMCORE_HRC 72 #include <comcore.hrc> 73 #endif 74 #include <globals.hrc> 75 #include "swabstdlg.hxx" 76 77 using namespace ::com::sun::star::uno; 78 using ::rtl::OUString; 79 80 81 // Kontextmenue fuer GlobalTree 82 #define CTX_INSERT_ANY_INDEX 10 83 //#define CTX_INSERT_CNTIDX 11 84 //#define CTX_INSERT_USRIDX 12 85 #define CTX_INSERT_FILE 11 86 #define CTX_INSERT_NEW_FILE 12 87 #define CTX_INSERT_TEXT 13 88 89 #define CTX_UPDATE_SEL 20 90 #define CTX_UPDATE_INDEX 21 91 #define CTX_UPDATE_LINK 22 92 #define CTX_UPDATE_ALL 23 93 94 #define CTX_UPDATE 1 95 #define CTX_INSERT 2 96 #define CTX_EDIT 3 97 #define CTX_DELETE 4 98 #define CTX_EDIT_LINK 5 99 100 #define GLOBAL_UPDATE_TIMEOUT 2000 101 102 // Flags fuer PopupMenu-enable/disable 103 #define ENABLE_INSERT_IDX 0x0001 104 #define ENABLE_INSERT_FILE 0x0002 105 #define ENABLE_INSERT_TEXT 0x0004 106 #define ENABLE_EDIT 0x0008 107 #define ENABLE_DELETE 0x0010 108 #define ENABLE_UPDATE 0x0020 109 #define ENABLE_UPDATE_SEL 0x0040 110 #define ENABLE_EDIT_LINK 0x0080 111 112 // TabPos nach links schieben 113 #define GLBL_TABPOS_SUB 5 114 115 const SfxObjectShell* SwGlobalTree::pShowShell = 0; 116 static const char* __FAR_DATA aHelpForMenu[] = 117 { 118 0, // 119 HID_GLBLTREE_UPDATE, //CTX_UPDATE 120 HID_GLBLTREE_INSERT, //CTX_INSERT 121 HID_GLBLTREE_EDIT, //CTX_EDIT 122 HID_GLBLTREE_DEL, //CTX_DELETE 123 HID_GLBLTREE_EDIT_LINK, //CTX_EDIT_LINK 124 0, // 125 0, // 126 0, // 127 0, // 128 HID_GLBLTREE_INS_IDX, //CTX_INSERT_ANY_INDEX 129 HID_GLBLTREE_INS_FILE, //CTX_INSERT_FILE 130 HID_GLBLTREE_INS_NEW_FILE, //CTX_INSERT_NEW_FILE 131 HID_GLBLTREE_INS_TEXT, //CTX_INSERT_TEXT 132 0, // 133 0, // 134 0, // 135 0, // 136 0, // 137 0, // 138 HID_GLBLTREE_UPD_SEL, //CTX_UPDATE_SEL 139 HID_GLBLTREE_UPD_IDX, //CTX_UPDATE_INDEX 140 HID_GLBLTREE_UPD_LINK, //CTX_UPDATE_LINK 141 HID_GLBLTREEUPD_ALL //CTX_UPDATE_ALL 142 }; 143 144 /************************************************************************/ 145 /* */ 146 /************************************************************************/ 147 /* -----------------------------24.08.00 12:04-------------------------------- 148 149 ---------------------------------------------------------------------------*/ 150 class SwGlobalFrameListener_Impl : public SfxListener 151 { 152 sal_Bool bValid; 153 public: 154 SwGlobalFrameListener_Impl(SfxViewFrame& rFrame) : 155 bValid(sal_True) 156 { 157 StartListening(rFrame); 158 } 159 160 virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 161 162 sal_Bool IsValid() const {return bValid;} 163 }; 164 /* -----------------------------24.08.00 12:05-------------------------------- 165 166 ---------------------------------------------------------------------------*/ 167 void SwGlobalFrameListener_Impl::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) 168 { 169 if( rHint.ISA(SfxSimpleHint) && 170 (((SfxSimpleHint&) rHint).GetId() == SFX_HINT_DYING)) 171 bValid = sal_False; 172 } 173 174 /*-----------------12.06.97 09:38------------------- 175 176 --------------------------------------------------*/ 177 SwGlobalTree::SwGlobalTree(Window* pParent, const ResId& rResId) : 178 179 SvTreeListBox(pParent, rResId), 180 181 pActiveShell ( NULL ), 182 pEmphasisEntry ( NULL ), 183 pDDSource ( NULL ), 184 pSwGlblDocContents ( NULL ), 185 pDefParentWin ( NULL ), 186 pDocContent ( NULL ), 187 pDocInserter ( NULL ), 188 189 bIsInternalDrag ( sal_False ), 190 bLastEntryEmphasis ( sal_False ), 191 bIsImageListInitialized ( sal_False ) 192 193 { 194 SetDragDropMode(SV_DRAGDROP_APP_COPY | 195 SV_DRAGDROP_CTRL_MOVE | 196 SV_DRAGDROP_ENABLE_TOP ); 197 198 aUpdateTimer.SetTimeout(GLOBAL_UPDATE_TIMEOUT); 199 aUpdateTimer.SetTimeoutHdl(LINK(this, SwGlobalTree, Timeout)); 200 aUpdateTimer.Start(); 201 for(sal_uInt16 i = 0; i < GLOBAL_CONTEXT_COUNT; i++) 202 { 203 aContextStrings[i] = SW_RESSTR(i+ ST_GLOBAL_CONTEXT_FIRST); 204 } 205 SetHelpId(HID_NAVIGATOR_GLOB_TREELIST); 206 SelectHdl(); 207 SetDoubleClickHdl(LINK(this, SwGlobalTree, DoubleClickHdl)); 208 EnableContextMenuHandling(); 209 } 210 211 /*-----------------12.06.97 09:38------------------- 212 213 --------------------------------------------------*/ 214 SwGlobalTree::~SwGlobalTree() 215 { 216 delete pSwGlblDocContents; 217 delete pDocInserter; 218 } 219 220 /*-----------------12.06.97 09:38------------------- 221 222 --------------------------------------------------*/ 223 sal_Int8 SwGlobalTree::ExecuteDrop( const ExecuteDropEvent& rEvt ) 224 { 225 sal_Int8 nRet = DND_ACTION_NONE; 226 SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible(); 227 if(pEmphasisEntry) 228 { 229 ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False ); 230 pEmphasisEntry = 0; 231 } 232 else if(bLastEntryEmphasis && pLast) 233 { 234 ImplShowTargetEmphasis( pLast, sal_False); 235 } 236 237 SvLBoxEntry* pDropEntry = bLastEntryEmphasis ? 0 : GetEntry(rEvt.maPosPixel); 238 if( bIsInternalDrag ) 239 { 240 SvLBoxEntry* pDummy = 0; 241 sal_uLong nInsertionPos = LIST_APPEND; 242 NotifyMoving( pDropEntry, pDDSource, pDummy, nInsertionPos ); 243 } 244 else 245 { 246 TransferableDataHelper aData( rEvt.maDropEvent.Transferable ); 247 248 String sFileName; 249 const SwGlblDocContent* pCnt = pDropEntry ? 250 (const SwGlblDocContent*)pDropEntry->GetUserData() : 251 0; 252 if( aData.HasFormat( FORMAT_FILE_LIST )) 253 { 254 nRet = rEvt.mnAction; 255 SwGlblDocContents* pTempContents = new SwGlblDocContents; 256 int nAbsContPos = pDropEntry ? 257 (int) GetModel()->GetAbsPos(pDropEntry): 258 - 1; 259 sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); 260 261 // Daten holen 262 FileList aFileList; 263 aData.GetFileList( FORMAT_FILE_LIST, aFileList ); 264 for ( sal_uInt16 n = (sal_uInt16)aFileList.Count(); n--; ) 265 { 266 sFileName = aFileList.GetFile(n); 267 InsertRegion(pCnt, &sFileName); 268 // nach dem Einfuegen muss die Liste der Contents neu 269 // geholt werden, um nicht auf einem alten Content zu 270 // arbeiten 271 if(n) 272 { 273 pActiveShell->GetGlobalDocContent(*pTempContents); 274 // wenn das file erfolgreich eingefuegt wurde, 275 // dann muss auch der naechste Content geholt werden 276 if(nEntryCount < pTempContents->Count()) 277 { 278 nEntryCount++; 279 nAbsContPos++; 280 pCnt = pTempContents->GetObject( static_cast< sal_uInt16 >(nAbsContPos) ); 281 } 282 } 283 } 284 delete pTempContents; 285 } 286 else if( 0 != (sFileName = 287 SwNavigationPI::CreateDropFileName( aData )).Len()) 288 { 289 INetURLObject aTemp(sFileName); 290 GraphicDescriptor aDesc(aTemp); 291 if( !aDesc.Detect() ) // keine Grafiken annehmen 292 { 293 nRet = rEvt.mnAction; 294 InsertRegion(pCnt, &sFileName); 295 } 296 } 297 } 298 bLastEntryEmphasis = sal_False; 299 return nRet; 300 301 } 302 /*-----------------12.06.97 09:38------------------- 303 304 --------------------------------------------------*/ 305 sal_Int8 SwGlobalTree::AcceptDrop( const AcceptDropEvent& rEvt ) 306 { 307 sal_Int8 nRet = rEvt.mnAction; 308 309 //initiate scrolling 310 GetDropTarget( rEvt.maPosPixel ); 311 SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible(); 312 if( rEvt.mbLeaving ) 313 { 314 if( pEmphasisEntry ) 315 { 316 ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False ); 317 pEmphasisEntry = 0; 318 } 319 else if(bLastEntryEmphasis && pLast) 320 { 321 ImplShowTargetEmphasis( pLast, sal_False); 322 } 323 bLastEntryEmphasis = sal_False; 324 } 325 else 326 { 327 SvLBoxEntry* pDropEntry = GetEntry( rEvt.maPosPixel ); 328 if(bIsInternalDrag) 329 { 330 if( pDDSource != pDropEntry ) 331 nRet = rEvt.mnAction; 332 } 333 else if( IsDropFormatSupported( FORMAT_FILE ) || 334 IsDropFormatSupported( FORMAT_STRING ) || 335 IsDropFormatSupported( FORMAT_FILE_LIST ) || 336 IsDropFormatSupported( SOT_FORMATSTR_ID_SOLK ) || 337 IsDropFormatSupported( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK )|| 338 IsDropFormatSupported( SOT_FORMATSTR_ID_FILECONTENT ) || 339 IsDropFormatSupported( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) || 340 IsDropFormatSupported( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) || 341 IsDropFormatSupported( SOT_FORMATSTR_ID_FILENAME )) 342 nRet = DND_ACTION_LINK; 343 344 if(pEmphasisEntry && pEmphasisEntry != pDropEntry) 345 ImplShowTargetEmphasis( Prev(pEmphasisEntry), sal_False ); 346 else if(pLast && bLastEntryEmphasis && pDropEntry) 347 { 348 ImplShowTargetEmphasis( pLast, sal_False); 349 bLastEntryEmphasis = sal_False; 350 } 351 352 if(pDropEntry) 353 ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet ); 354 else if(pLast) 355 { 356 ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet ); 357 bLastEntryEmphasis = sal_True; 358 } 359 pEmphasisEntry = pDropEntry; 360 } 361 return nRet; 362 } 363 /*-----------------12.06.97 09:38------------------- 364 365 --------------------------------------------------*/ 366 PopupMenu* SwGlobalTree::CreateContextMenu() 367 { 368 PopupMenu* pPop = 0; 369 if(pActiveShell && 370 !pActiveShell->GetView().GetDocShell()->IsReadOnly()) 371 { 372 sal_uInt16 nEnableFlags = GetEnableFlags(); 373 pPop = new PopupMenu; 374 PopupMenu* pSubPop1 = new PopupMenu; 375 PopupMenu* pSubPop2 = new PopupMenu; 376 377 for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++) 378 { 379 pSubPop2->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] ); 380 pSubPop2->SetHelpId(i, aHelpForMenu[i]); 381 } 382 pSubPop2->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL)); 383 384 pSubPop1->InsertItem(CTX_INSERT_ANY_INDEX, aContextStrings[ST_INDEX - ST_GLOBAL_CONTEXT_FIRST]); 385 pSubPop1->SetHelpId(CTX_INSERT_ANY_INDEX, aHelpForMenu[CTX_INSERT_ANY_INDEX]); 386 pSubPop1->InsertItem(CTX_INSERT_FILE, aContextStrings[ST_FILE - ST_GLOBAL_CONTEXT_FIRST]); 387 pSubPop1->SetHelpId(CTX_INSERT_FILE, aHelpForMenu[CTX_INSERT_FILE]); 388 pSubPop1->InsertItem(CTX_INSERT_NEW_FILE, aContextStrings[ST_NEW_FILE - ST_GLOBAL_CONTEXT_FIRST]); 389 pSubPop1->SetHelpId(CTX_INSERT_NEW_FILE, aHelpForMenu[CTX_INSERT_NEW_FILE]); 390 pSubPop1->InsertItem(CTX_INSERT_TEXT, aContextStrings[ST_TEXT - ST_GLOBAL_CONTEXT_FIRST]); 391 pSubPop1->SetHelpId(CTX_INSERT_TEXT, aHelpForMenu[CTX_INSERT_TEXT]); 392 393 394 pPop->InsertItem(CTX_UPDATE, aContextStrings[ST_UPDATE - ST_GLOBAL_CONTEXT_FIRST]); 395 pPop->SetHelpId(CTX_UPDATE, aHelpForMenu[CTX_UPDATE]); 396 pPop->InsertItem(CTX_EDIT, aContextStrings[ST_EDIT_CONTENT - ST_GLOBAL_CONTEXT_FIRST]); 397 pPop->SetHelpId(CTX_EDIT, aHelpForMenu[CTX_EDIT]); 398 if(nEnableFlags&ENABLE_EDIT_LINK) 399 { 400 pPop->InsertItem(CTX_EDIT_LINK, aContextStrings[ST_EDIT_LINK - ST_GLOBAL_CONTEXT_FIRST]); 401 pPop->SetHelpId(CTX_EDIT_LINK, aHelpForMenu[CTX_EDIT_LINK]); 402 } 403 pPop->InsertItem(CTX_INSERT, aContextStrings[ST_INSERT - ST_GLOBAL_CONTEXT_FIRST]); 404 pPop->SetHelpId(CTX_INSERT, aHelpForMenu[CTX_INSERT]); 405 pPop->InsertSeparator() ; 406 pPop->InsertItem(CTX_DELETE, aContextStrings[ST_DELETE - ST_GLOBAL_CONTEXT_FIRST]); 407 pPop->SetHelpId(CTX_DELETE, aHelpForMenu[CTX_DELETE]); 408 409 //evtl. disablen 410 pSubPop1->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); 411 pSubPop1->EnableItem(CTX_INSERT_TEXT, 0 != (nEnableFlags & ENABLE_INSERT_TEXT)); 412 pSubPop1->EnableItem(CTX_INSERT_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); 413 pSubPop1->EnableItem(CTX_INSERT_NEW_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); 414 415 pPop->EnableItem(CTX_UPDATE, 0 != (nEnableFlags & ENABLE_UPDATE)); 416 pPop->EnableItem(CTX_INSERT, 0 != (nEnableFlags & ENABLE_INSERT_IDX)); 417 pPop->EnableItem(CTX_EDIT, 0 != (nEnableFlags & ENABLE_EDIT)); 418 pPop->EnableItem(CTX_DELETE, 0 != (nEnableFlags & ENABLE_DELETE)); 419 420 421 pPop->SetPopupMenu( CTX_INSERT, pSubPop1 ); 422 pPop->SetPopupMenu( CTX_UPDATE, pSubPop2 ); 423 } 424 return pPop; 425 } 426 /*-----------------16.06.97 10:41------------------- 427 428 --------------------------------------------------*/ 429 void SwGlobalTree::TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox) 430 { 431 sal_uInt16 nEnableFlags = GetEnableFlags(); 432 if(FN_GLOBAL_OPEN == nTbxId) 433 { 434 PopupMenu *pMenu = new PopupMenu; 435 for (sal_uInt16 i = CTX_INSERT_ANY_INDEX; i <= CTX_INSERT_TEXT; i++) 436 { 437 pMenu->InsertItem( i, aContextStrings[ST_INDEX - ST_GLOBAL_CONTEXT_FIRST - CTX_INSERT_ANY_INDEX + i] ); 438 pMenu->SetHelpId(i, aHelpForMenu[i] ); 439 } 440 pMenu->EnableItem(CTX_INSERT_ANY_INDEX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); 441 // pMenu->EnableItem(CTX_INSERT_CNTIDX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); 442 // pMenu->EnableItem(CTX_INSERT_USRIDX, 0 != (nEnableFlags & ENABLE_INSERT_IDX )); 443 pMenu->EnableItem(CTX_INSERT_TEXT, 0 != (nEnableFlags & ENABLE_INSERT_TEXT)); 444 pMenu->EnableItem(CTX_INSERT_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); 445 pMenu->EnableItem(CTX_INSERT_NEW_FILE, 0 != (nEnableFlags & ENABLE_INSERT_FILE)); 446 pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl)); 447 pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft()); 448 delete pMenu; 449 pBox->EndSelection(); 450 pBox->Invalidate(); 451 } 452 else if(FN_GLOBAL_UPDATE == nTbxId) 453 { 454 PopupMenu *pMenu = new PopupMenu; 455 for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++) 456 { 457 pMenu->InsertItem( i, aContextStrings[ST_UPDATE_SEL - ST_GLOBAL_CONTEXT_FIRST - CTX_UPDATE_SEL+ i] ); 458 pMenu->SetHelpId(i, aHelpForMenu[i] ); 459 } 460 pMenu->EnableItem(CTX_UPDATE_SEL, 0 != (nEnableFlags & ENABLE_UPDATE_SEL)); 461 pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl)); 462 pMenu->Execute( pBox, pBox->GetItemRect(nTbxId).BottomLeft()); 463 delete pMenu; 464 pBox->EndSelection(); 465 pBox->Invalidate(); 466 } 467 } 468 /*-----------------16.06.97 11:02------------------- 469 470 --------------------------------------------------*/ 471 sal_uInt16 SwGlobalTree::GetEnableFlags() const 472 { 473 SvLBoxEntry* pEntry = FirstSelected(); 474 sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount(); 475 sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); 476 SvLBoxEntry* pPrevEntry = pEntry ? Prev(pEntry) : 0; 477 478 sal_uInt16 nRet = 0; 479 if(nSelCount == 1 || !nEntryCount) 480 nRet |= ENABLE_INSERT_IDX|ENABLE_INSERT_FILE; 481 if(nSelCount == 1) 482 { 483 nRet |= ENABLE_EDIT; 484 if( ((SwGlblDocContent*)pEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN && 485 (!pPrevEntry || ((SwGlblDocContent*)pPrevEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN)) 486 nRet |= ENABLE_INSERT_TEXT; 487 if( GLBLDOC_SECTION == ((SwGlblDocContent*)pEntry->GetUserData())->GetType() ) 488 nRet |= ENABLE_EDIT_LINK; 489 } 490 else if(!nEntryCount) 491 { 492 nRet |= ENABLE_INSERT_TEXT; 493 } 494 if(nEntryCount) 495 nRet |= ENABLE_UPDATE|ENABLE_DELETE; 496 if(nSelCount) 497 nRet |= ENABLE_UPDATE_SEL; 498 return nRet; 499 } 500 501 /*-----------------12.06.97 09:38------------------- 502 503 --------------------------------------------------*/ 504 void SwGlobalTree::RequestHelp( const HelpEvent& rHEvt ) 505 { 506 sal_Bool bParent = sal_True; 507 Update(sal_True); 508 Display(sal_True); 509 if( rHEvt.GetMode() & HELPMODE_QUICK ) 510 { 511 Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() )); 512 SvLBoxEntry* pEntry = GetEntry( aPos ); 513 const SwGlblDocContent* pCont = pEntry ? 514 (const SwGlblDocContent*)pEntry->GetUserData() : 0; 515 if( pCont && GLBLDOC_SECTION == pCont->GetType()) 516 { 517 bParent = sal_False; 518 SvLBoxTab* pTab; 519 SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab ); 520 if(pItem && SV_ITEM_ID_LBOXSTRING == pItem->IsA()) 521 { 522 const SwSection* pSect = pCont->GetSection(); 523 String sEntry = pSect->GetLinkFileName().GetToken(0, sfx2::cTokenSeperator); 524 if(!pSect->IsConnectFlag()) 525 sEntry.Insert(aContextStrings[ST_BROKEN_LINK - ST_GLOBAL_CONTEXT_FIRST], 0 ); 526 Point aEntryPos = GetEntryPosition( pEntry ); 527 528 aEntryPos.X() = GetTabPos( pEntry, pTab ); 529 Size aSize( pItem->GetSize( this, pEntry ) ); 530 531 if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width()) 532 aSize.Width() = GetSizePixel().Width() - aEntryPos.X(); 533 534 aEntryPos = OutputToScreenPixel(aEntryPos); 535 Rectangle aItemRect( aEntryPos, aSize ); 536 if(Help::IsBalloonHelpEnabled()) 537 { 538 aEntryPos.X() += aSize.Width(); 539 Help::ShowBalloon( this, aEntryPos, aItemRect, sEntry ); 540 } 541 else 542 Help::ShowQuickHelp( this, aItemRect, sEntry, 543 QUICKHELP_LEFT|QUICKHELP_VCENTER ); 544 } 545 } 546 } 547 548 if(bParent) 549 SvTreeListBox::RequestHelp(rHEvt); 550 } 551 /*-----------------16.06.97 16:15------------------- 552 553 --------------------------------------------------*/ 554 void SwGlobalTree::SelectHdl() 555 { 556 557 sal_uInt16 nSelCount = (sal_uInt16)GetSelectionCount(); 558 SvLBoxEntry* pSel = FirstSelected(); 559 sal_uInt16 nAbsPos = pSel ? (sal_uInt16)GetModel()->GetAbsPos(pSel) : 0; 560 SwNavigationPI* pNavi = GetParentWindow(); 561 sal_Bool bReadonly = !pActiveShell || 562 pActiveShell->GetView().GetDocShell()->IsReadOnly(); 563 pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_EDIT, nSelCount == 1 && !bReadonly); 564 pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_OPEN, nSelCount <= 1 && !bReadonly); 565 pNavi->aGlobalToolBox.EnableItem(FN_GLOBAL_UPDATE, GetEntryCount() > 0 && !bReadonly); 566 pNavi->aGlobalToolBox.EnableItem(FN_ITEM_UP, 567 nSelCount == 1 && nAbsPos && !bReadonly); 568 pNavi->aGlobalToolBox.EnableItem(FN_ITEM_DOWN, 569 nSelCount == 1 && nAbsPos < ((sal_uInt16)GetEntryCount()) - 1 && !bReadonly); 570 571 } 572 /*-----------------16.06.97 16:15------------------- 573 574 --------------------------------------------------*/ 575 void SwGlobalTree::DeselectHdl() 576 { 577 SelectHdl(); 578 } 579 580 /*-----------------17.06.97 13:11------------------- 581 582 --------------------------------------------------*/ 583 DragDropMode SwGlobalTree::NotifyStartDrag( TransferDataContainer& , 584 SvLBoxEntry* pEntry ) 585 { 586 bIsInternalDrag = sal_True; 587 pDDSource = pEntry; 588 return SV_DRAGDROP_CTRL_MOVE; 589 } 590 591 /*-----------------21.06.97 12:44------------------- 592 593 --------------------------------------------------*/ 594 long SwGlobalTree::GetTabPos( SvLBoxEntry*, SvLBoxTab* pTab) 595 { 596 return pTab->GetPos() - GLBL_TABPOS_SUB; 597 } 598 599 /*-----------------12.06.97 09:38------------------- 600 601 --------------------------------------------------*/ 602 sal_Bool SwGlobalTree::NotifyMoving( SvLBoxEntry* pTarget, 603 SvLBoxEntry* pSource, 604 SvLBoxEntry*&, 605 sal_uLong& 606 ) 607 { 608 SvTreeList* _pModel = GetModel(); 609 sal_uInt16 nSource = (sal_uInt16) _pModel->GetAbsPos(pSource); 610 sal_uInt16 nDest = pTarget ? (sal_uInt16) _pModel->GetAbsPos(pTarget) : pSwGlblDocContents->Count(); 611 612 if( pActiveShell->MoveGlobalDocContent( 613 *pSwGlblDocContents, nSource, nSource + 1, nDest ) && 614 Update( sal_False )) 615 Display(); 616 return sal_False; 617 } 618 /*-----------------12.06.97 09:39------------------- 619 620 --------------------------------------------------*/ 621 sal_Bool SwGlobalTree::NotifyCopying( SvLBoxEntry* /*pTarget*/, 622 SvLBoxEntry* /*pEntry*/, 623 SvLBoxEntry*& /*rpNewParent*/, 624 sal_uLong& /*rNewChildPos*/ 625 ) 626 { 627 return sal_False; 628 } 629 /*-----------------12.06.97 09:39------------------- 630 631 --------------------------------------------------*/ 632 sal_Bool SwGlobalTree::NotifyAcceptDrop( SvLBoxEntry* pEntry) 633 { 634 return pEntry != 0; 635 } 636 /*-----------------12.06.97 09:39------------------- 637 638 --------------------------------------------------*/ 639 void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt ) 640 { 641 if( 1 == GetSelectionCount() ) 642 SvTreeListBox::StartDrag( nAction, rPt ); 643 } 644 /*-----------------12.06.97 09:39------------------- 645 646 --------------------------------------------------*/ 647 void SwGlobalTree::DragFinished( sal_Int8 nAction ) 648 { 649 SvTreeListBox::DragFinished( nAction ); 650 bIsInternalDrag = sal_False; 651 } 652 653 /*************************************************************************** 654 Beschreibung: Wird ein Ctrl+DoubleClick in einen freien Bereich ausgefuehrt, 655 * dann soll die Basisfunktion des Controls gerufen werden 656 ***************************************************************************/ 657 void SwGlobalTree::MouseButtonDown( const MouseEvent& rMEvt ) 658 { 659 Point aPos( rMEvt.GetPosPixel()); 660 SvLBoxEntry* pEntry = GetEntry( aPos, sal_True ); 661 if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0) 662 Control::MouseButtonDown( rMEvt ); 663 else 664 SvTreeListBox::MouseButtonDown( rMEvt ); 665 } 666 667 /*-----------------12.06.97 13:08------------------- 668 669 --------------------------------------------------*/ 670 void SwGlobalTree::GetFocus() 671 { 672 if(Update( sal_False )) 673 Display(); 674 SvTreeListBox::GetFocus(); 675 } 676 677 /*-----------------12.06.97 12:34------------------- 678 679 --------------------------------------------------*/ 680 void SwGlobalTree::KeyInput(const KeyEvent& rKEvt) 681 { 682 const KeyCode aCode = rKEvt.GetKeyCode(); 683 if(aCode.GetCode() == KEY_RETURN) 684 { 685 switch(aCode.GetModifier()) 686 { 687 case KEY_MOD2: 688 // Boxen umschalten 689 GetParentWindow()->ToggleTree(); 690 break; 691 } 692 } 693 else 694 SvTreeListBox::KeyInput(rKEvt); 695 } 696 697 /*-----------------17.06.97 11:59------------------- 698 699 --------------------------------------------------*/ 700 void SwGlobalTree::Clear() 701 { 702 pEmphasisEntry = 0; 703 SvTreeListBox::Clear(); 704 } 705 /*-----------------12.06.97 12:38------------------- 706 707 --------------------------------------------------*/ 708 void SwGlobalTree::Display(sal_Bool bOnlyUpdateUserData) 709 { 710 if(!bIsImageListInitialized) 711 { 712 sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; 713 aEntryImages = ImageList(SW_RES(nResId)); 714 bIsImageListInitialized = sal_True; 715 } 716 sal_uInt16 nCount = pSwGlblDocContents->Count(); 717 if(bOnlyUpdateUserData && GetEntryCount() == pSwGlblDocContents->Count()) 718 { 719 SvLBoxEntry* pEntry = First(); 720 for( sal_uInt16 i = 0; i < nCount; i++) 721 { 722 SwGlblDocContentPtr pCont = pSwGlblDocContents->GetObject(i); 723 pEntry->SetUserData(pCont); 724 pEntry = Next(pEntry); 725 } 726 } 727 else 728 { 729 SetUpdateMode( sal_False ); 730 SvLBoxEntry* pOldSelEntry = FirstSelected(); 731 String sEntryName; // Name des Eintrags 732 sal_uInt16 nSelPos = USHRT_MAX; 733 if(pOldSelEntry) 734 { 735 sEntryName = GetEntryText(pOldSelEntry); 736 nSelPos = (sal_uInt16)GetModel()->GetAbsPos(pOldSelEntry); 737 } 738 Clear(); 739 if(!pSwGlblDocContents) 740 Update( sal_False ); 741 742 SvLBoxEntry* pSelEntry = 0; 743 for( sal_uInt16 i = 0; i < nCount; i++) 744 { 745 SwGlblDocContentPtr pCont = pSwGlblDocContents->GetObject(i); 746 String sEntry; 747 Image aImage; 748 switch( pCont->GetType() ) 749 { 750 case GLBLDOC_UNKNOWN: 751 { 752 sEntry = aContextStrings[ST_TEXT - ST_GLOBAL_CONTEXT_FIRST]; 753 aImage = aEntryImages.GetImage(SID_SW_START + GLOBAL_CONTENT_TEXT); 754 } 755 break; 756 case GLBLDOC_TOXBASE: 757 { 758 const SwTOXBase* pBase = pCont->GetTOX(); 759 sEntry = pBase->GetTitle(); 760 aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_INDEX); 761 } 762 break; 763 case GLBLDOC_SECTION: 764 { 765 const SwSection* pSect = pCont->GetSection(); 766 sEntry = pSect->GetSectionName(); 767 aImage = aEntryImages.GetImage(SID_SW_START + CONTENT_TYPE_REGION); 768 } 769 break; 770 } 771 SvLBoxEntry* pEntry = InsertEntry(sEntry, aImage, aImage, 772 0, sal_False, LIST_APPEND, pCont); 773 if(sEntry == sEntryName) 774 { 775 pSelEntry = pEntry; 776 } 777 } 778 if(pSelEntry) 779 { 780 Select(pSelEntry); 781 } 782 else if(nSelPos != USHRT_MAX && nSelPos < nCount) 783 { 784 Select(GetEntry(nSelPos)); 785 } 786 else if(nCount) 787 Select(First()); 788 else 789 SelectHdl(); 790 SetUpdateMode( sal_True ); 791 } 792 } 793 794 /*-----------------13.06.97 10:32------------------- 795 796 --------------------------------------------------*/ 797 void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const String* pFileName ) 798 { 799 Sequence< OUString > aFileNames; 800 if ( !pFileName ) 801 { 802 pDefParentWin = Application::GetDefDialogParent(); 803 Application::SetDefDialogParent( this ); 804 if ( pDocInserter ) 805 delete pDocInserter; 806 pDocInserter = new ::sfx2::DocumentInserter( 0, String::CreateFromAscii("swriter"), true ); 807 pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) ); 808 } 809 else if ( pFileName->Len() ) 810 { 811 aFileNames.realloc(1); 812 INetURLObject aFileName; 813 aFileName.SetSmartURL( *pFileName ); 814 aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::NO_DECODE ); 815 InsertRegion( pCont, aFileNames ); 816 } 817 } 818 819 /*-----------------18.06.97 12:42------------------- 820 821 --------------------------------------------------*/ 822 void SwGlobalTree::EditContent(const SwGlblDocContent* pCont ) 823 { 824 sal_uInt16 nSlot = 0; 825 switch( pCont->GetType() ) 826 { 827 case GLBLDOC_UNKNOWN: 828 pActiveShell->GetView().GetEditWin().GrabFocus(); 829 break; 830 case GLBLDOC_TOXBASE: 831 { 832 const SwTOXBase* pBase = pCont->GetTOX(); 833 if(pBase) 834 nSlot = FN_INSERT_MULTI_TOX; 835 } 836 break; 837 case GLBLDOC_SECTION: 838 { 839 OpenDoc(pCont); 840 841 nSlot = 0; 842 pCont = 0; 843 } 844 break; 845 } 846 if(pCont) 847 GotoContent(pCont); 848 if(nSlot) 849 { 850 pActiveShell->GetView().GetViewFrame()->GetDispatcher()->Execute(nSlot); 851 if(Update( sal_False )) 852 Display(); 853 } 854 } 855 856 /*-----------------13.06.97 14:22------------------- 857 858 --------------------------------------------------*/ 859 IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu) 860 { 861 ExcecuteContextMenuAction( pMenu->GetCurItemId()); 862 return sal_True; 863 } 864 /* -----------------26.08.2003 11:57----------------- 865 866 --------------------------------------------------*/ 867 void SwGlobalTree::ExcecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry ) 868 //IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu) 869 { 870 // sal_uInt16 nId = pMenu->GetCurItemId(); 871 SvLBoxEntry* pEntry = FirstSelected(); 872 SwGlblDocContent* pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0; 873 // wird waehrend des Dialogs ein RequestHelp gerufen, 874 // dann geht der Content verloren. Deshalb wird hier eine 875 // Kopie angelegt, in der nur die DocPos richtig gesetzt ist. 876 SwGlblDocContent* pContCopy = 0; 877 if(pCont) 878 pContCopy = new SwGlblDocContent(pCont->GetDocPos()); 879 SfxDispatcher& rDispatch = *pActiveShell->GetView().GetViewFrame()->GetDispatcher(); 880 sal_uInt16 nSlot = 0; 881 bool bDeleteContentCopy = true; 882 switch( nSelectedPopupEntry ) 883 { 884 case CTX_UPDATE_SEL: 885 { 886 // zwei Durchlaeufe: zuerst die Bereiche, dann die Verzeichnisse 887 // aktualisieren 888 SvLBoxEntry* pSelEntry = FirstSelected(); 889 while( pSelEntry ) 890 { 891 SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData(); 892 if(GLBLDOC_SECTION == pContent->GetType() && 893 pContent->GetSection()->IsConnected()) 894 { 895 ((SwSection*)pContent->GetSection())->UpdateNow(); 896 } 897 898 pSelEntry = NextSelected(pSelEntry); 899 } 900 pSelEntry = FirstSelected(); 901 while( pSelEntry ) 902 { 903 SwGlblDocContent* pContent = (SwGlblDocContent*)pSelEntry->GetUserData(); 904 if(GLBLDOC_TOXBASE == pContent->GetType()) 905 pActiveShell->UpdateTableOf(*pContent->GetTOX()); 906 pSelEntry = NextSelected(pSelEntry); 907 } 908 909 } 910 break; 911 case CTX_UPDATE_INDEX: 912 { 913 nSlot = FN_UPDATE_TOX; 914 } 915 break; 916 case CTX_UPDATE_LINK: 917 case CTX_UPDATE_ALL: 918 { 919 pActiveShell->GetLinkManager().UpdateAllLinks(sal_True); 920 if(CTX_UPDATE_ALL == nSelectedPopupEntry) 921 nSlot = FN_UPDATE_TOX; 922 pCont = 0; 923 } 924 break; 925 case CTX_EDIT: 926 { 927 DBG_ASSERT(pCont, "Edit ohne Entry ? " ); 928 EditContent(pCont); 929 } 930 break; 931 case CTX_EDIT_LINK: 932 { 933 DBG_ASSERT(pCont, "Edit ohne Entry ? " ); 934 SfxStringItem aName(FN_EDIT_REGION, 935 pCont->GetSection()->GetSectionName()); 936 rDispatch.Execute(FN_EDIT_REGION, SFX_CALLMODE_ASYNCHRON, &aName, 0L); 937 } 938 break; 939 case CTX_DELETE: 940 { 941 // sind mehrere Eintraege selektiert, dann muss nach jedem delete 942 // das Array neu gefuellt werden. Damit man sich nichts merken muss, 943 // beginnt das Loeschen am Ende 944 SvLBoxEntry* pSelEntry = LastSelected(); 945 SwGlblDocContents* pTempContents = 0; 946 pActiveShell->StartAction(); 947 while(pSelEntry) 948 { 949 pActiveShell->DeleteGlobalDocContent( 950 pTempContents ? *pTempContents : *pSwGlblDocContents, 951 (sal_uInt16)GetModel()->GetAbsPos(pSelEntry)); 952 pSelEntry = PrevSelected(pSelEntry); 953 if(pSelEntry) 954 { 955 pTempContents = new SwGlblDocContents; 956 pActiveShell->GetGlobalDocContent(*pTempContents); 957 } 958 } 959 delete pTempContents; 960 pActiveShell->EndAction(); 961 pCont = 0; 962 } 963 break; 964 case CTX_INSERT_ANY_INDEX: 965 // case CTX_INSERT_CNTIDX: 966 // case CTX_INSERT_USRIDX: 967 { 968 if(pContCopy) 969 { 970 SfxItemSet aSet(pActiveShell->GetView().GetPool(), 971 RES_COL, RES_COL, 972 RES_BACKGROUND, RES_BACKGROUND, 973 RES_FRM_SIZE, RES_FRM_SIZE, 974 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 975 RES_LR_SPACE, RES_LR_SPACE, 976 FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE, 977 0); 978 979 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 980 DBG_ASSERT(pFact, "Dialogdiet fail!"); 981 AbstractMultiTOXTabDialog* pDlg = pFact->CreateMultiTOXTabDialog( DLG_MULTI_TOX, 982 this, aSet, 983 *pActiveShell, 984 0, 985 USHRT_MAX, 986 sal_True); 987 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 988 if(RET_OK == pDlg->Execute()) 989 { 990 SwTOXDescription& rDesc = pDlg->GetTOXDescription( 991 pDlg->GetCurrentTOXType()); 992 SwTOXMgr aMgr(pActiveShell); 993 SwTOXBase* pToInsert = 0; 994 if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet())) 995 pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert ); 996 } 997 pCont = 0; 998 delete pDlg; 999 } 1000 } 1001 break; 1002 case CTX_INSERT_FILE: 1003 { 1004 bDeleteContentCopy = false; 1005 pDocContent = pContCopy; 1006 InsertRegion( pContCopy ); 1007 pCont = NULL; 1008 } 1009 break; 1010 case CTX_INSERT_NEW_FILE: 1011 { 1012 SfxViewFrame* pGlobFrm = pActiveShell->GetView().GetViewFrame(); 1013 SwGlobalFrameListener_Impl aFrmListener(*pGlobFrm); 1014 1015 sal_uLong nEntryPos = pEntry ? GetModel()->GetAbsPos(pEntry) : (sal_uLong)-1; 1016 // neues Dok anlegen 1017 SfxStringItem aFactory(SID_NEWDOCDIRECT, 1018 SwDocShell::Factory().GetFilterContainer()->GetName()); 1019 1020 const SfxFrameItem* pItem = (SfxFrameItem*) 1021 rDispatch.Execute(SID_NEWDOCDIRECT, 1022 SFX_CALLMODE_SYNCHRON, &aFactory, 0L); 1023 1024 // sichern unter 1025 SfxFrame* pFrm = pItem ? pItem->GetFrame() : 0; 1026 SfxViewFrame* pFrame = pFrm ? pFrm->GetCurrentViewFrame() : 0; 1027 if( pFrame ) 1028 { 1029 const SfxBoolItem* pBool = (const SfxBoolItem*) 1030 pFrame->GetDispatcher()->Execute( 1031 SID_SAVEASDOC, SFX_CALLMODE_SYNCHRON ); 1032 SfxObjectShell& rObj = *pFrame->GetObjectShell(); 1033 const SfxMedium* pMedium = rObj.GetMedium(); 1034 String sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)); 1035 // Bereich mit dem Dok-Namen einfuegen 1036 // eigenes Dok in den Vordergrund 1037 1038 if(aFrmListener.IsValid() && sNewFile.Len()) 1039 { 1040 pGlobFrm->ToTop(); 1041 // durch das Update sind die Eintraege invalid 1042 if(nEntryPos != (sal_uLong)-1) 1043 { 1044 Update( sal_False ); 1045 Display(); 1046 Select(GetModel()->GetEntryAtAbsPos(nEntryPos)); 1047 pEntry = FirstSelected(); 1048 pCont = pEntry ? (SwGlblDocContent*)pEntry->GetUserData() : 0; 1049 } 1050 else 1051 { 1052 pEntry = 0; 1053 pCont = 0; 1054 } 1055 if(pBool->GetValue()) 1056 { 1057 InsertRegion(pCont, &sNewFile); 1058 pFrame->ToTop(); 1059 } 1060 else 1061 pFrame->GetDispatcher()->Execute(SID_CLOSEWIN, 1062 SFX_CALLMODE_SYNCHRON); 1063 } 1064 else 1065 { 1066 pFrame->ToTop(); 1067 return; 1068 } 1069 } 1070 } 1071 break; 1072 case CTX_INSERT_TEXT: 1073 { 1074 if(pCont) 1075 pActiveShell->InsertGlobalDocContent(*pCont); 1076 else 1077 { 1078 pActiveShell->SplitNode(); // leeres Dokument 1079 pActiveShell->Up( sal_False, 1 ); 1080 } 1081 pActiveShell->GetView().GetEditWin().GrabFocus(); 1082 } 1083 break; 1084 case CTX_UPDATE: 1085 pCont = 0; 1086 break; 1087 default:; 1088 // hier passiert nichts 1089 } 1090 if(pCont) 1091 GotoContent(pCont); 1092 if(nSlot) 1093 rDispatch.Execute(nSlot); 1094 if(Update( sal_False )) 1095 Display(); 1096 if ( bDeleteContentCopy ) 1097 delete pContCopy; 1098 else 1099 bDeleteContentCopy = true; 1100 // return sal_True; 1101 } 1102 1103 /*-----------------16.06.97 07:57------------------- 1104 1105 --------------------------------------------------*/ 1106 IMPL_LINK( SwGlobalTree, Timeout, Timer*, EMPTYARG ) 1107 { 1108 if(!HasFocus() && Update( sal_False )) 1109 Display(); 1110 return 0; 1111 } 1112 1113 /*-----------------13.06.97 16:56------------------- 1114 1115 --------------------------------------------------*/ 1116 void SwGlobalTree::GotoContent(const SwGlblDocContent* pCont) 1117 { 1118 pActiveShell->EnterStdMode(); 1119 1120 switch( pCont->GetType() ) 1121 { 1122 case GLBLDOC_UNKNOWN: 1123 pActiveShell->GotoGlobalDocContent(*pCont); 1124 break; 1125 case GLBLDOC_TOXBASE: 1126 { 1127 String sName = pCont->GetTOX()->GetTOXName(); 1128 if (!pActiveShell->GotoNextTOXBase(&sName)) 1129 pActiveShell->GotoPrevTOXBase(&sName); 1130 } 1131 break; 1132 case GLBLDOC_SECTION: 1133 break; 1134 } 1135 1136 } 1137 /*-----------------16.06.97 07:42------------------- 1138 1139 --------------------------------------------------*/ 1140 void SwGlobalTree::ShowTree() 1141 { 1142 aUpdateTimer.Start(); 1143 SvTreeListBox::Show(); 1144 } 1145 /*-----------------16.06.97 07:42------------------- 1146 1147 --------------------------------------------------*/ 1148 void SwGlobalTree::HideTree() 1149 { 1150 aUpdateTimer.Stop(); 1151 SvTreeListBox::Hide(); 1152 } 1153 /*-----------------18.06.97 10:02------------------- 1154 1155 --------------------------------------------------*/ 1156 void SwGlobalTree::ExecCommand(sal_uInt16 nCmd) 1157 { 1158 SvLBoxEntry* pEntry = FirstSelected(); 1159 DBG_ASSERT(pEntry, "gleich knallt's"); 1160 if(FN_GLOBAL_EDIT == nCmd) 1161 { 1162 const SwGlblDocContent* pCont = (const SwGlblDocContent*) 1163 pEntry->GetUserData(); 1164 EditContent(pCont); 1165 } 1166 else 1167 { 1168 if(GetSelectionCount() == 1) 1169 { 1170 sal_Bool bMove = sal_False; 1171 sal_uInt16 nSource = (sal_uInt16)GetModel()->GetAbsPos(pEntry); 1172 sal_uInt16 nDest = nSource; 1173 switch(nCmd) 1174 { 1175 case FN_ITEM_DOWN: 1176 { 1177 sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); 1178 bMove = nEntryCount > nSource + 1; 1179 nDest+= 2; 1180 } 1181 break; 1182 case FN_ITEM_UP: 1183 { 1184 if(nSource) 1185 bMove = 0 != nSource; 1186 nDest--; 1187 } 1188 break; 1189 } 1190 if( bMove && pActiveShell->MoveGlobalDocContent( 1191 *pSwGlblDocContents, nSource, nSource + 1, nDest ) && 1192 Update( sal_False )) 1193 Display(); 1194 } 1195 } 1196 } 1197 1198 /*-----------------16.06.97 07:43------------------- 1199 1200 --------------------------------------------------*/ 1201 sal_Bool SwGlobalTree::Update(sal_Bool bHard) 1202 { 1203 SwView* pActView = GetParentWindow()->GetCreateView(); 1204 sal_Bool bRet = sal_False; 1205 if(pActView && pActView->GetWrtShellPtr()) 1206 { 1207 const SwWrtShell* pOldShell = pActiveShell; 1208 pActiveShell = pActView->GetWrtShellPtr(); 1209 if(pActiveShell != pOldShell) 1210 { 1211 delete pSwGlblDocContents; 1212 pSwGlblDocContents = 0; 1213 } 1214 if(!pSwGlblDocContents) 1215 { 1216 pSwGlblDocContents = new SwGlblDocContents; 1217 bRet = sal_True; 1218 pActiveShell->GetGlobalDocContent(*pSwGlblDocContents); 1219 } 1220 else 1221 { 1222 sal_Bool bCopy = sal_False; 1223 SwGlblDocContents* pTempContents = new SwGlblDocContents; 1224 pActiveShell->GetGlobalDocContent(*pTempContents); 1225 if(pTempContents->Count() != pSwGlblDocContents->Count() || 1226 pTempContents->Count() != GetEntryCount()) 1227 { 1228 bRet = sal_True; 1229 bCopy = sal_True; 1230 } 1231 else 1232 { 1233 for(sal_uInt16 i = 0; i < pTempContents->Count() && !bCopy; i++) 1234 { 1235 SwGlblDocContent* pLeft = pTempContents->GetObject(i); 1236 SwGlblDocContent* pRight = pSwGlblDocContents->GetObject(i); 1237 GlobalDocContentType eType = pLeft->GetType(); 1238 SvLBoxEntry* pEntry = GetEntry(i); 1239 String sTemp = GetEntryText(pEntry); 1240 if ( 1241 eType != pRight->GetType() || 1242 ( 1243 eType == GLBLDOC_SECTION && 1244 pLeft->GetSection()->GetSectionName() != sTemp 1245 ) || 1246 ( 1247 eType == GLBLDOC_TOXBASE && 1248 pLeft->GetTOX()->GetTitle() != sTemp 1249 ) 1250 ) 1251 { 1252 bCopy = bRet = sal_True; 1253 } 1254 } 1255 } 1256 if(bCopy || bHard) 1257 { 1258 sal_uInt16 i; 1259 1260 pSwGlblDocContents->DeleteAndDestroy(0, pSwGlblDocContents->Count()); 1261 for( i = 0; i < pTempContents->Count(); i++) 1262 { 1263 pSwGlblDocContents->Insert(pTempContents->GetObject(i)); 1264 } 1265 for( i = pTempContents->Count(); i; i--) 1266 pTempContents->Remove(i - 1); 1267 1268 } 1269 delete pTempContents; 1270 } 1271 1272 } 1273 else 1274 { 1275 Clear(); 1276 if(pSwGlblDocContents) 1277 pSwGlblDocContents->DeleteAndDestroy(0, pSwGlblDocContents->Count()); 1278 } 1279 // hier muss noch eine Veraenderungspruefung rein! 1280 return bRet; 1281 } 1282 1283 /*-----------------25.06.97 16:20------------------- 1284 1285 --------------------------------------------------*/ 1286 void SwGlobalTree::OpenDoc(const SwGlblDocContent* pCont) 1287 { 1288 String sFileName(pCont->GetSection()->GetLinkFileName().GetToken(0, 1289 sfx2::cTokenSeperator)); 1290 sal_Bool bFound = sal_False; 1291 const SfxObjectShell* pCurr = SfxObjectShell::GetFirst(); 1292 while( !bFound && pCurr ) 1293 { 1294 if(pCurr->GetMedium() && 1295 String(pCurr->GetMedium()->GetURLObject().GetMainURL(INetURLObject::DECODE_TO_IURI)) == sFileName) 1296 { 1297 bFound = sal_True; 1298 SwGlobalTree::SetShowShell(pCurr); 1299 Application::PostUserEvent( STATIC_LINK( 1300 this, SwGlobalTree, ShowFrameHdl ) ); 1301 pCurr = 0; 1302 } 1303 else 1304 pCurr = SfxObjectShell::GetNext(*pCurr); 1305 } 1306 if(!bFound) 1307 { 1308 SfxStringItem aURL(SID_FILE_NAME, 1309 sFileName); 1310 SfxBoolItem aReadOnly(SID_DOC_READONLY, sal_False); 1311 SfxStringItem aTargetFrameName( SID_TARGETNAME, String::CreateFromAscii("_blank") ); 1312 SfxStringItem aReferer(SID_REFERER, pActiveShell->GetView().GetDocShell()->GetTitle()); 1313 pActiveShell->GetView().GetViewFrame()->GetDispatcher()-> 1314 Execute(SID_OPENDOC, SFX_CALLMODE_ASYNCHRON, 1315 &aURL, &aReadOnly, &aReferer, &aTargetFrameName, 0L); 1316 } 1317 } 1318 1319 /*-----------------25.06.97 16:08------------------- 1320 1321 --------------------------------------------------*/ 1322 IMPL_LINK( SwGlobalTree, DoubleClickHdl, SwGlobalTree *, EMPTYARG ) 1323 { 1324 SvLBoxEntry* pEntry = GetCurEntry(); 1325 SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData(); 1326 if(pCont->GetType() == GLBLDOC_SECTION) 1327 OpenDoc(pCont); 1328 else 1329 { 1330 GotoContent(pCont); 1331 pActiveShell->GetView().GetEditWin().GrabFocus(); 1332 } 1333 return 0; 1334 } 1335 1336 /*-----------------07.10.97 08:09------------------- 1337 1338 --------------------------------------------------*/ 1339 IMPL_STATIC_LINK_NOINSTANCE(SwGlobalTree, ShowFrameHdl, SwGlobalTree*, EMPTYARG) 1340 { 1341 if(SwGlobalTree::GetShowShell()) 1342 SfxViewFrame::GetFirst(SwGlobalTree::GetShowShell())->ToTop(); 1343 SwGlobalTree::SetShowShell(0); 1344 return 0; 1345 } 1346 /* -----------------04.11.98 10:43------------------- 1347 * 1348 * --------------------------------------------------*/ 1349 void SwGlobalTree::InitEntry(SvLBoxEntry* pEntry, 1350 const XubString& rStr ,const Image& rImg1,const Image& rImg2, 1351 SvLBoxButtonKind eButtonKind) 1352 { 1353 sal_uInt16 nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2" 1354 SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind ); 1355 SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite ); 1356 SwLBoxString* pStr = new SwLBoxString( pEntry, 0, pCol->GetText() ); 1357 pEntry->ReplaceItem( pStr, nColToHilite ); 1358 } 1359 /* -----------------04.11.98 10:39------------------- 1360 * 1361 * --------------------------------------------------*/ 1362 1363 void SwLBoxString::Paint( const Point& rPos, SvLBox& rDev, sal_uInt16 nFlags, 1364 SvLBoxEntry* pEntry ) 1365 { 1366 SwGlblDocContent* pCont = (SwGlblDocContent*)pEntry->GetUserData(); 1367 const SwSection* pSect; 1368 if(pCont->GetType() == GLBLDOC_SECTION && 1369 !(pSect = pCont->GetSection())->IsConnectFlag() ) 1370 { 1371 Font aOldFont( rDev.GetFont()); 1372 Font aFont(aOldFont); 1373 Color aCol( COL_LIGHTRED ); 1374 aFont.SetColor( aCol ); 1375 rDev.SetFont( aFont ); 1376 rDev.DrawText( rPos, GetText() ); 1377 rDev.SetFont( aOldFont ); 1378 } 1379 else 1380 SvLBoxString::Paint( rPos, rDev, nFlags, pEntry); 1381 } 1382 /* -----------------------------06.05.2002 10:20------------------------------ 1383 1384 ---------------------------------------------------------------------------*/ 1385 void SwGlobalTree::DataChanged( const DataChangedEvent& rDCEvt ) 1386 { 1387 if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && 1388 (rDCEvt.GetFlags() & SETTINGS_STYLE) ) 1389 { 1390 sal_uInt16 nResId = GetSettings().GetStyleSettings().GetHighContrastMode() ? IMG_NAVI_ENTRYBMPH : IMG_NAVI_ENTRYBMP; 1391 aEntryImages = ImageList(SW_RES(nResId)); 1392 Update(sal_True); 1393 } 1394 SvTreeListBox::DataChanged( rDCEvt ); 1395 } 1396 1397 void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles ) 1398 { 1399 sal_Int32 nFiles = _rFiles.getLength(); 1400 if ( nFiles ) 1401 { 1402 sal_Bool bMove = sal_False; 1403 if ( !_pContent ) 1404 { 1405 SvLBoxEntry* pLast = (SvLBoxEntry*)LastVisible(); 1406 _pContent = (SwGlblDocContent*)pLast->GetUserData(); 1407 bMove = sal_True; 1408 } 1409 String sFilePassword; 1410 sal_uInt16 nEntryCount = (sal_uInt16)GetEntryCount(); 1411 const OUString* pFileNames = _rFiles.getConstArray(); 1412 SwWrtShell& rSh = GetParentWindow()->GetCreateView()->GetWrtShell(); 1413 rSh.StartAction(); 1414 // after insertion of the first new content the 'pCont' parameter becomes invalid 1415 // find the index of the 'anchor' content to always use a current anchor content 1416 sal_uInt16 nAnchorContent = pSwGlblDocContents->Count() - 1; 1417 if ( !bMove ) 1418 { 1419 for( sal_uInt16 nContent = 0; nContent < pSwGlblDocContents->Count(); ++nContent ) 1420 { 1421 if( *_pContent == *pSwGlblDocContents->GetObject( nContent ) ) 1422 { 1423 nAnchorContent = nContent; 1424 break; 1425 } 1426 } 1427 } 1428 SwGlblDocContents aTempContents; 1429 for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile ) 1430 { 1431 //update the global document content after each inserted document 1432 rSh.GetGlobalDocContent(aTempContents); 1433 SwGlblDocContent* pAnchorContent = 0; 1434 DBG_ASSERT(aTempContents.Count() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed"); 1435 if ( aTempContents.Count() > (nAnchorContent + nFile) ) 1436 pAnchorContent = aTempContents.GetObject(nAnchorContent + (sal_uInt16)nFile); 1437 else 1438 pAnchorContent = aTempContents.GetObject(aTempContents.Count() - 1); 1439 String sFileName(pFileNames[nFile]); 1440 INetURLObject aFileUrl; 1441 aFileUrl.SetSmartURL( sFileName ); 1442 String sSectionName(String(aFileUrl.GetLastName( 1443 INetURLObject::DECODE_UNAMBIGUOUS)).GetToken(0, 1444 sfx2::cTokenSeperator)); 1445 sal_uInt16 nSectCount = rSh.GetSectionFmtCount(); 1446 String sTempSectionName(sSectionName); 1447 sal_uInt16 nAddNumber = 0; 1448 sal_uInt16 nCount = 0; 1449 // evtl : und Index anhaengen, wenn der Bereichsname schon vergeben ist 1450 while ( nCount < nSectCount ) 1451 { 1452 const SwSectionFmt& rFmt = rSh.GetSectionFmt(nCount); 1453 if ((rFmt.GetSection()->GetSectionName() == sTempSectionName) 1454 && rFmt.IsInNodesArr()) 1455 { 1456 nCount = 0; 1457 nAddNumber++; 1458 sTempSectionName = sSectionName; 1459 sTempSectionName += ':'; 1460 sTempSectionName += String::CreateFromInt32( nAddNumber ); 1461 } 1462 else 1463 nCount++; 1464 } 1465 1466 if ( nAddNumber ) 1467 sSectionName = sTempSectionName; 1468 1469 SwSectionData aSectionData(CONTENT_SECTION, sSectionName); 1470 aSectionData.SetProtectFlag(true); 1471 aSectionData.SetHidden(false); 1472 1473 aSectionData.SetLinkFileName(sFileName); 1474 aSectionData.SetType(FILE_LINK_SECTION); 1475 aSectionData.SetLinkFilePassword( sFilePassword ); 1476 1477 rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData ); 1478 } 1479 if ( bMove ) 1480 { 1481 Update( sal_False ); 1482 rSh.MoveGlobalDocContent( 1483 *pSwGlblDocContents, nEntryCount, nEntryCount + (sal_uInt16)nFiles, nEntryCount - (sal_uInt16)nFiles ); 1484 } 1485 rSh.EndAction(); 1486 Update( sal_False ); 1487 Display(); 1488 } 1489 } 1490 1491 IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg ) 1492 { 1493 Application::SetDefDialogParent( pDefParentWin ); 1494 if ( ERRCODE_NONE == _pFileDlg->GetError() ) 1495 { 1496 SfxMediumList* pMedList = pDocInserter->CreateMediumList(); 1497 if ( pMedList ) 1498 { 1499 Sequence< OUString >aFileNames( pMedList->Count() ); 1500 OUString* pFileNames = aFileNames.getArray(); 1501 SfxMedium* pMed = pMedList->First(); 1502 sal_Int32 nPos = 0; 1503 while ( pMed ) 1504 { 1505 String sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::NO_DECODE ); 1506 sFileName += sfx2::cTokenSeperator; 1507 sFileName += pMed->GetFilter()->GetFilterName(); 1508 sFileName += sfx2::cTokenSeperator; 1509 pFileNames[nPos++] = sFileName; 1510 pMed = pMedList->Next(); 1511 } 1512 delete pMedList; 1513 InsertRegion( pDocContent, aFileNames ); 1514 DELETEZ( pDocContent ); 1515 } 1516 } 1517 return 0; 1518 } 1519 1520