LibreOffice Module sw (master)  1
glbltree.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <svl/stritem.hxx>
21 #include <sfx2/fcontnr.hxx>
22 #include <sfx2/linkmgr.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/viewfrm.hxx>
25 #include <svl/urihelper.hxx>
26 #include <sfx2/docfile.hxx>
27 #include <sfx2/docfilt.hxx>
28 #include <vcl/help.hxx>
29 #include <sot/filelist.hxx>
30 #include <svl/eitem.hxx>
31 #include <svl/urlbmk.hxx>
32 #include <svx/svxids.hrc>
33 #include <vcl/graphicfilter.hxx>
34 #include <vcl/settings.hxx>
35 
36 #include <vcl/treelistentry.hxx>
37 #include <sfx2/docinsert.hxx>
38 #include <sfx2/filedlghelper.hxx>
39 
40 #include <sfx2/app.hxx>
41 #include <swmodule.hxx>
42 #include <wrtsh.hxx>
43 #include <view.hxx>
44 #include <docsh.hxx>
45 #include <content.hxx>
46 #include <edglbldc.hxx>
47 #include <section.hxx>
48 #include <tox.hxx>
49 #include <cnttab.hxx>
50 #include <navipi.hxx>
51 #include <navicont.hxx>
52 #include <edtwin.hxx>
53 #include <uitool.hxx>
54 
55 #include <cmdid.h>
56 #include <helpids.h>
57 #include <strings.hrc>
58 #include <globals.hrc>
59 #include <bitmaps.hlst>
60 #include <swabstdlg.hxx>
61 #include <memory>
62 
63 using namespace ::com::sun::star::uno;
64 
65 // Context menu for GlobalTree
66 #define CTX_INSERT_ANY_INDEX 10
67 #define CTX_INSERT_FILE 11
68 #define CTX_INSERT_NEW_FILE 12
69 #define CTX_INSERT_TEXT 13
70 
71 #define CTX_UPDATE_SEL 20
72 #define CTX_UPDATE_INDEX 21
73 #define CTX_UPDATE_LINK 22
74 #define CTX_UPDATE_ALL 23
75 
76 #define CTX_UPDATE 1
77 #define CTX_INSERT 2
78 #define CTX_EDIT 3
79 #define CTX_DELETE 4
80 #define CTX_EDIT_LINK 5
81 
82 #define GLOBAL_UPDATE_TIMEOUT 2000
83 
84 // TabPos: push to left
85 #define GLBL_TABPOS_SUB 5
86 
88 static const char* aHelpForMenu[] =
89 {
90  nullptr,
91  HID_GLBLTREE_UPDATE, //CTX_UPDATE
92  HID_GLBLTREE_INSERT, //CTX_INSERT
93  HID_GLBLTREE_EDIT, //CTX_EDIT
94  HID_GLBLTREE_DEL, //CTX_DELETE
95  HID_GLBLTREE_EDIT_LINK, //CTX_EDIT_LINK
96  nullptr,
97  nullptr,
98  nullptr,
99  nullptr,
100  HID_GLBLTREE_INS_IDX, //CTX_INSERT_ANY_INDEX
101  HID_GLBLTREE_INS_FILE, //CTX_INSERT_FILE
102  HID_GLBLTREE_INS_NEW_FILE, //CTX_INSERT_NEW_FILE
103  HID_GLBLTREE_INS_TEXT, //CTX_INSERT_TEXT
104  nullptr,
105  nullptr,
106  nullptr,
107  nullptr,
108  nullptr,
109  nullptr,
110  HID_GLBLTREE_UPD_SEL, //CTX_UPDATE_SEL
111  HID_GLBLTREE_UPD_IDX, //CTX_UPDATE_INDEX
112  HID_GLBLTREE_UPD_LINK, //CTX_UPDATE_LINK
113  HID_GLBLTREEUPD_ALL //CTX_UPDATE_ALL
114 };
115 
117 {
118  bool bValid;
119 public:
121  : bValid(true)
122  {
123  StartListening(rFrame);
124  }
125 
126  virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ) override;
127 
128  bool IsValid() const {return bValid;}
129 };
130 
132 {
133  if( rHint.GetId() == SfxHintId::Dying)
134  bValid = false;
135 }
136 
138 {
153 };
154 
155 static const char* GLOBAL_CONTEXT_ARY[] =
156 {
157  STR_UPDATE,
158  STR_EDIT_CONTENT,
159  STR_EDIT_INSERT,
160  STR_INDEX,
161  STR_FILE,
162  STR_NEW_FILE,
163  STR_INSERT_TEXT,
164  STR_DELETE,
165  STR_UPDATE_SEL,
166  STR_UPDATE_INDEX,
167  STR_UPDATE_LINK,
168  STR_UPDATE_ALL,
169  STR_BROKEN_LINK,
170  STR_EDIT_LINK
171 };
172 
174  : SvTreeListBox(pParent)
175  , m_xDialog(pDialog)
176  , m_pActiveShell(nullptr)
177  , m_pEmphasisEntry(nullptr)
178  , m_pDDSource(nullptr)
179  , m_bIsInternalDrag(false)
180  , m_bLastEntryEmphasis(false)
181 {
182  SetDragDropMode(DragDropMode::APP_COPY |
183  DragDropMode::CTRL_MOVE |
184  DragDropMode::ENABLE_TOP );
185 
189  for (sal_uInt16 i = 0; i < GLOBAL_CONTEXT_COUNT; i++)
190  {
192  }
194  SelectHdl();
197 }
198 
200 {
201  disposeOnce();
202 }
203 
205 {
206  m_pSwGlblDocContents.reset();
207  m_pDocInserter.reset();
209  m_xDialog.clear();
211 }
212 
214 {
215  return LogicToPixel(Size(110, 112), MapMode(MapUnit::MapAppFont));
216 }
217 
219 {
220  sal_Int8 nRet = DND_ACTION_NONE;
221  SvTreeListEntry* pLast = LastVisible();
222  if(m_pEmphasisEntry)
223  {
225  m_pEmphasisEntry = nullptr;
226  }
227  else if(m_bLastEntryEmphasis && pLast)
228  {
229  ImplShowTargetEmphasis( pLast, false);
230  }
231 
232  SvTreeListEntry* pDropEntry = m_bLastEntryEmphasis ? nullptr : GetEntry(rEvt.maPosPixel);
233  if( m_bIsInternalDrag )
234  {
235  SvTreeListEntry* pDummy = nullptr;
236  sal_uLong nInsertionPos = TREELIST_APPEND;
237  NotifyMoving( pDropEntry, m_pDDSource, pDummy, nInsertionPos );
238  }
239  else
240  {
241  TransferableDataHelper aData( rEvt.maDropEvent.Transferable );
242 
243  OUString sFileName;
244  const SwGlblDocContent* pCnt = pDropEntry ?
245  static_cast<const SwGlblDocContent*>(pDropEntry->GetUserData()) :
246  nullptr;
247  if( aData.HasFormat( SotClipboardFormatId::FILE_LIST ))
248  {
249  nRet = rEvt.mnAction;
250  std::unique_ptr<SwGlblDocContents> pTempContents(new SwGlblDocContents);
251  int nAbsContPos = pDropEntry ?
252  static_cast<int>(GetModel()->GetAbsPos(pDropEntry)):
253  - 1;
254  sal_uLong nEntryCount = GetEntryCount();
255 
256  // Get data
257  FileList aFileList;
258  aData.GetFileList( SotClipboardFormatId::FILE_LIST, aFileList );
259  for ( size_t n = aFileList.Count(); n--; )
260  {
261  sFileName = aFileList.GetFile(n);
262  InsertRegion(pCnt, &sFileName);
263  // The list of contents must be newly fetched after inserting,
264  // to not work on an old content.
265  if(n)
266  {
267  m_pActiveShell->GetGlobalDocContent(*pTempContents);
268  // If the file was successfully inserted,
269  // then the next content must also be fetched.
270  if(nEntryCount < pTempContents->size())
271  {
272  nEntryCount++;
273  nAbsContPos++;
274  pCnt = (*pTempContents)[ nAbsContPos ].get();
275  }
276  }
277  }
278  }
279  else if( !(sFileName =
280  SwNavigationPI::CreateDropFileName( aData )).isEmpty())
281  {
282  INetURLObject aTemp(sFileName);
283  GraphicDescriptor aDesc(aTemp);
284  if( !aDesc.Detect() ) // accept no graphics
285  {
286  nRet = rEvt.mnAction;
287  InsertRegion(pCnt, &sFileName);
288  }
289  }
290  }
291  m_bLastEntryEmphasis = false;
292  return nRet;
293 
294 }
295 
297 {
298  sal_Int8 nRet = rEvt.mnAction;
299 
300  //initiate scrolling
301  GetDropTarget( rEvt.maPosPixel );
302  SvTreeListEntry* pLast = LastVisible();
303  if( rEvt.mbLeaving )
304  {
305  if( m_pEmphasisEntry )
306  {
308  m_pEmphasisEntry = nullptr;
309  }
310  else if(m_bLastEntryEmphasis && pLast)
311  {
312  ImplShowTargetEmphasis( pLast, false);
313  }
314  m_bLastEntryEmphasis = false;
315  }
316  else
317  {
318  SvTreeListEntry* pDropEntry = GetEntry( rEvt.maPosPixel );
320  {
321  if( m_pDDSource != pDropEntry )
322  nRet = rEvt.mnAction;
323  }
324  else if( IsDropFormatSupported( SotClipboardFormatId::SIMPLE_FILE ) ||
325  IsDropFormatSupported( SotClipboardFormatId::STRING ) ||
326  IsDropFormatSupported( SotClipboardFormatId::FILE_LIST ) ||
327  IsDropFormatSupported( SotClipboardFormatId::SOLK ) ||
328  IsDropFormatSupported( SotClipboardFormatId::NETSCAPE_BOOKMARK )||
329  IsDropFormatSupported( SotClipboardFormatId::FILECONTENT ) ||
330  IsDropFormatSupported( SotClipboardFormatId::FILEGRPDESCRIPTOR ) ||
331  IsDropFormatSupported( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) ||
332  IsDropFormatSupported( SotClipboardFormatId::FILENAME ))
333  nRet = DND_ACTION_LINK;
334 
335  if(m_pEmphasisEntry && m_pEmphasisEntry != pDropEntry)
337  else if(pLast && m_bLastEntryEmphasis && pDropEntry)
338  {
339  ImplShowTargetEmphasis( pLast, false);
340  m_bLastEntryEmphasis = false;
341  }
342 
343  if(pDropEntry)
344  ImplShowTargetEmphasis( Prev(pDropEntry), DND_ACTION_NONE != nRet );
345  else if(pLast)
346  {
347  ImplShowTargetEmphasis( pLast, DND_ACTION_NONE != nRet );
348  m_bLastEntryEmphasis = true;
349  }
350  m_pEmphasisEntry = pDropEntry;
351  }
352  return nRet;
353 }
354 
356 {
357  VclPtr<PopupMenu> pPop;
358  if(m_pActiveShell &&
360  {
361  const MenuEnableFlags nEnableFlags = GetEnableFlags();
362  pPop = VclPtr<PopupMenu>::Create();
363  VclPtrInstance<PopupMenu> pSubPop1;
364  VclPtrInstance<PopupMenu> pSubPop2;
365 
366  for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
367  {
369  pSubPop2->SetHelpId(i, aHelpForMenu[i]);
370  }
371  pSubPop2->EnableItem(CTX_UPDATE_SEL, bool(nEnableFlags & MenuEnableFlags::UpdateSel));
372 
381 
386  if(nEnableFlags&MenuEnableFlags::EditLink)
387  {
390  }
393  pPop->InsertSeparator() ;
396 
397  //disabling if applicable
398  pSubPop1->EnableItem(CTX_INSERT_ANY_INDEX, bool(nEnableFlags & MenuEnableFlags::InsertIdx ));
399  pSubPop1->EnableItem(CTX_INSERT_TEXT, bool(nEnableFlags & MenuEnableFlags::InsertText));
400  pSubPop1->EnableItem(CTX_INSERT_FILE, bool(nEnableFlags & MenuEnableFlags::InsertFile));
401  pSubPop1->EnableItem(CTX_INSERT_NEW_FILE, bool(nEnableFlags & MenuEnableFlags::InsertFile));
402 
403  pPop->EnableItem(CTX_UPDATE, bool(nEnableFlags & MenuEnableFlags::Update));
404  pPop->EnableItem(CTX_INSERT, bool(nEnableFlags & MenuEnableFlags::InsertIdx));
405  pPop->EnableItem(CTX_EDIT, bool(nEnableFlags & MenuEnableFlags::Edit));
406  pPop->EnableItem(CTX_DELETE, bool(nEnableFlags & MenuEnableFlags::Delete));
407 
408  pPop->SetPopupMenu( CTX_INSERT, pSubPop1 );
409  pPop->SetPopupMenu( CTX_UPDATE, pSubPop2 );
410  }
411  return pPop;
412 }
413 
414 void SwGlobalTree::TbxMenuHdl(sal_uInt16 nTbxId, ToolBox* pBox)
415 {
416  const MenuEnableFlags nEnableFlags = GetEnableFlags();
417  const OUString sCommand(pBox->GetItemCommand(nTbxId));
418  if (sCommand == "insert")
419  {
421  for (sal_uInt16 i = CTX_INSERT_ANY_INDEX; i <= CTX_INSERT_TEXT; ++i)
422  {
424  pMenu->SetHelpId(i, aHelpForMenu[i] );
425  }
426  pMenu->EnableItem(CTX_INSERT_ANY_INDEX, bool(nEnableFlags & MenuEnableFlags::InsertIdx ));
427  pMenu->EnableItem(CTX_INSERT_TEXT, bool(nEnableFlags & MenuEnableFlags::InsertText));
428  pMenu->EnableItem(CTX_INSERT_FILE, bool(nEnableFlags & MenuEnableFlags::InsertFile));
429  pMenu->EnableItem(CTX_INSERT_NEW_FILE, bool(nEnableFlags & MenuEnableFlags::InsertFile));
430  pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
431  pMenu->Execute(pBox, pBox->GetItemRect(nTbxId));
432  pMenu.disposeAndClear();
433  pBox->EndSelection();
434  pBox->Invalidate();
435  }
436  else if (sCommand == "update")
437  {
439  for (sal_uInt16 i = CTX_UPDATE_SEL; i <= CTX_UPDATE_ALL; i++)
440  {
442  pMenu->SetHelpId(i, aHelpForMenu[i] );
443  }
444  pMenu->EnableItem(CTX_UPDATE_SEL, bool(nEnableFlags & MenuEnableFlags::UpdateSel));
445  pMenu->SetSelectHdl(LINK(this, SwGlobalTree, PopupHdl));
446  pMenu->Execute(pBox, pBox->GetItemRect(nTbxId));
447  pMenu.disposeAndClear();
448  pBox->EndSelection();
449  pBox->Invalidate();
450  }
451 }
452 
454 {
455  SvTreeListEntry* pEntry = FirstSelected();
456  sal_uLong nSelCount = GetSelectionCount();
457  sal_uLong nEntryCount = GetEntryCount();
458  SvTreeListEntry* pPrevEntry = pEntry ? Prev(pEntry) : nullptr;
459 
461  if(nSelCount == 1 || !nEntryCount)
463  if(nSelCount == 1)
464  {
465  nRet |= MenuEnableFlags::Edit;
466  if (pEntry && static_cast<SwGlblDocContent*>(pEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN &&
467  (!pPrevEntry || static_cast<SwGlblDocContent*>(pPrevEntry->GetUserData())->GetType() != GLBLDOC_UNKNOWN))
469  if (pEntry && GLBLDOC_SECTION == static_cast<SwGlblDocContent*>(pEntry->GetUserData())->GetType())
471  }
472  else if(!nEntryCount)
473  {
475  }
476  if(nEntryCount)
478  if(nSelCount)
480  return nRet;
481 }
482 
484 {
485  bool bParent = true;
486  Update(true);
487  Display(true);
488  if( rHEvt.GetMode() & HelpEventMode::QUICK )
489  {
490  Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
491  SvTreeListEntry* pEntry = GetEntry( aPos );
492  const SwGlblDocContent* pCont = pEntry ?
493  static_cast<const SwGlblDocContent*>(pEntry->GetUserData()) : nullptr;
494  if( pCont && GLBLDOC_SECTION == pCont->GetType())
495  {
496  bParent = false;
497  SvLBoxTab* pTab;
498  SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
499  if (pItem && SvLBoxItemType::String == pItem->GetType())
500  {
501  const SwSection* pSect = pCont->GetSection();
502  OUString sEntry = pSect->GetLinkFileName().getToken(0, sfx2::cTokenSeparator);
503  if(!pSect->IsConnectFlag())
504  sEntry = m_aContextStrings[IDX_STR_BROKEN_LINK] + sEntry;
505  Point aEntryPos = GetEntryPosition( pEntry );
506 
507  aEntryPos.setX( GetTabPos( pEntry, pTab ) );
508  Size aSize( pItem->GetSize( this, pEntry ) );
509 
510  if((aEntryPos.X() + aSize.Width()) > GetSizePixel().Width())
511  aSize.setWidth( GetSizePixel().Width() - aEntryPos.X() );
512 
513  aEntryPos = OutputToScreenPixel(aEntryPos);
514  tools::Rectangle aItemRect( aEntryPos, aSize );
516  {
517  aEntryPos.AdjustX(aSize.Width() );
518  Help::ShowBalloon( this, aEntryPos, aItemRect, sEntry );
519  }
520  else
521  Help::ShowQuickHelp( this, aItemRect, sEntry,
522  QuickHelpFlags::Left|QuickHelpFlags::VCenter );
523  }
524  }
525  }
526 
527  if(bParent)
529 }
530 
532 {
533 
534  sal_uLong nSelCount = GetSelectionCount();
535  SvTreeListEntry* pSel = FirstSelected();
536  sal_uLong nAbsPos = pSel ? GetModel()->GetAbsPos(pSel) : 0;
537  SwNavigationPI* pNavi = GetParentWindow();
538  bool bReadonly = !m_pActiveShell ||
540  pNavi->m_aGlobalToolBox->EnableItem(pNavi->m_aGlobalToolBox->GetItemId("edit"), nSelCount == 1 && !bReadonly);
541  pNavi->m_aGlobalToolBox->EnableItem(pNavi->m_aGlobalToolBox->GetItemId("insert"), nSelCount <= 1 && !bReadonly);
542  pNavi->m_aGlobalToolBox->EnableItem(pNavi->m_aGlobalToolBox->GetItemId("update"), GetEntryCount() > 0 && !bReadonly);
544  nSelCount == 1 && nAbsPos && !bReadonly);
545  pNavi->m_aGlobalToolBox->EnableItem(pNavi->m_aGlobalToolBox->GetItemId("down"),
546  nSelCount == 1 && nAbsPos < GetEntryCount() - 1 && !bReadonly);
547 
548 }
549 
551 {
552  SelectHdl();
553 }
554 
556  SvTreeListEntry* pEntry )
557 {
558  m_bIsInternalDrag = true;
559  m_pDDSource = pEntry;
560  return DragDropMode::CTRL_MOVE;
561 }
562 
564 {
565  return pTab->GetPos() - GLBL_TABPOS_SUB;
566 }
567 
569  SvTreeListEntry* pSource,
570  SvTreeListEntry*&,
571  sal_uLong&
572  )
573 {
574  SvTreeList* _pModel = GetModel();
575  sal_uLong nSource = _pModel->GetAbsPos(pSource);
576  sal_uLong nDest = pTarget ? _pModel->GetAbsPos(pTarget) : m_pSwGlblDocContents->size();
577 
579  *m_pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
580  Update( false ))
581  Display();
582 
583  return TRISTATE_FALSE;
584 }
585 
587  SvTreeListEntry* /*pEntry*/,
588  SvTreeListEntry*& /*rpNewParent*/,
589  sal_uLong& /*rNewChildPos*/
590  )
591 {
592  return TRISTATE_FALSE;
593 }
594 
596 {
597  return pEntry != nullptr;
598 }
599 
600 void SwGlobalTree::StartDrag( sal_Int8 nAction, const Point& rPt )
601 {
602  if( 1 == GetSelectionCount() )
603  SvTreeListBox::StartDrag( nAction, rPt );
604 }
605 
607 {
608  SvTreeListBox::DragFinished( nAction );
609  m_bIsInternalDrag = false;
610 }
611 
612 // If a Ctrl+DoubleClick is executed in an empty area,
613 // then the base function of the control should be called.
614 
616 {
617  Point aPos( rMEvt.GetPosPixel());
618  SvTreeListEntry* pEntry = GetEntry( aPos, true );
619  if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
620  Control::MouseButtonDown( rMEvt );
621  else
623 }
624 
626 {
627  if(Update( false ))
628  Display();
630 }
631 
633 {
634  const vcl::KeyCode aCode = rKEvt.GetKeyCode();
635  if(aCode.GetCode() == KEY_RETURN)
636  {
637  switch(aCode.GetModifier())
638  {
639  case KEY_MOD2:
640  // Switch boxes
642  break;
643  }
644  }
645  else
647 }
648 
650 {
651  m_pEmphasisEntry = nullptr;
653 }
654 
655 void SwGlobalTree::Display(bool bOnlyUpdateUserData)
656 {
657  size_t nCount = m_pSwGlblDocContents->size();
658  if(bOnlyUpdateUserData && GetEntryCount() == m_pSwGlblDocContents->size())
659  {
660  SvTreeListEntry* pEntry = First();
661  for (size_t i = 0; i < nCount && pEntry; i++)
662  {
663  SwGlblDocContent* pCont = (*m_pSwGlblDocContents)[i].get();
664  pEntry->SetUserData(pCont);
665  pEntry = Next(pEntry);
666  assert(pEntry || i == nCount - 1);
667  }
668  }
669  else
670  {
671  SetUpdateMode( false );
672  SvTreeListEntry* pOldSelEntry = FirstSelected();
673  OUString sEntryName; // Name of the entry
675  if(pOldSelEntry)
676  {
677  sEntryName = GetEntryText(pOldSelEntry);
678  nSelPos = GetModel()->GetAbsPos(pOldSelEntry);
679  }
680  Clear();
682  Update( false );
683 
684  SvTreeListEntry* pSelEntry = nullptr;
685  for( size_t i = 0; i < nCount; i++)
686  {
687  SwGlblDocContent* pCont = (*m_pSwGlblDocContents)[i].get();
688  OUString sEntry;
689  Image aImage;
690  switch( pCont->GetType() )
691  {
692  case GLBLDOC_UNKNOWN:
693  {
695  }
696  break;
697  case GLBLDOC_TOXBASE:
698  {
699  const SwTOXBase* pBase = pCont->GetTOX();
700  sEntry = pBase->GetTitle();
701  aImage = Image(StockImage::Yes, RID_BMP_NAVI_INDEX);
702  }
703  break;
704  case GLBLDOC_SECTION:
705  {
706  const SwSection* pSect = pCont->GetSection();
707  sEntry = pSect->GetSectionName();
708  aImage = Image(StockImage::Yes, RID_BMP_DROP_REGION);
709  }
710  break;
711  }
712  SvTreeListEntry* pEntry = InsertEntry(sEntry, aImage, aImage,
713  nullptr, false, TREELIST_APPEND, pCont);
714  if(sEntry == sEntryName)
715  {
716  pSelEntry = pEntry;
717  }
718  }
719  if(pSelEntry)
720  {
721  Select(pSelEntry);
722  }
723  else if(nSelPos != TREELIST_ENTRY_NOTFOUND && nSelPos < nCount)
724  {
725  Select(GetEntry(nSelPos));
726  }
727  else if(nCount)
728  Select(First());
729  else
730  SelectHdl();
731  SetUpdateMode( true );
732  }
733 }
734 
735 void SwGlobalTree::InsertRegion( const SwGlblDocContent* pCont, const OUString* pFileName )
736 {
737  Sequence< OUString > aFileNames;
738  if ( !pFileName )
739  {
740  m_pDocInserter.reset(new ::sfx2::DocumentInserter(GetFrameWeld(), "swriter", sfx2::DocumentInserter::Mode::InsertMulti));
741  m_pDocInserter->StartExecuteModal( LINK( this, SwGlobalTree, DialogClosedHdl ) );
742  }
743  else if ( !pFileName->isEmpty() )
744  {
745  aFileNames.realloc(1);
746  INetURLObject aFileName;
747  aFileName.SetSmartURL( *pFileName );
748  aFileNames.getArray()[0] = aFileName.GetMainURL( INetURLObject::DecodeMechanism::NONE );
749  InsertRegion( pCont, aFileNames );
750  }
751 }
752 
754 {
755  sal_uInt16 nSlot = 0;
756  switch( pCont->GetType() )
757  {
758  case GLBLDOC_UNKNOWN:
760  break;
761  case GLBLDOC_TOXBASE:
762  {
763  const SwTOXBase* pBase = pCont->GetTOX();
764  if(pBase)
765  nSlot = FN_INSERT_MULTI_TOX;
766  }
767  break;
768  case GLBLDOC_SECTION:
769  {
770  OpenDoc(pCont);
771 
772  nSlot = 0;
773  pCont = nullptr;
774  }
775  break;
776  }
777  if(pCont)
778  GotoContent(pCont);
779  if(nSlot)
780  {
782  if(Update( false ))
783  Display();
784  }
785 }
786 
787 IMPL_LINK( SwGlobalTree, PopupHdl, Menu* , pMenu, bool)
788 {
789  ExecuteContextMenuAction( pMenu->GetCurItemId());
790  return true;
791 }
792 
793 void SwGlobalTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
794 {
795  SvTreeListEntry* pEntry = FirstSelected();
796  SwGlblDocContent* pCont = pEntry ? static_cast<SwGlblDocContent*>(pEntry->GetUserData()) : nullptr;
797  // If a RequestHelp is called during the dialogue,
798  // then the content gets lost. Because of that a copy
799  // is created in which only the DocPos is set correctly.
800  std::unique_ptr<SwGlblDocContent> pContCopy;
801  if(pCont)
802  pContCopy.reset(new SwGlblDocContent(pCont->GetDocPos()));
804  sal_uInt16 nSlot = 0;
805  switch( nSelectedPopupEntry )
806  {
807  case CTX_UPDATE_SEL:
808  {
809  // Two passes: first update the areas, then the directories.
810  SvTreeListEntry* pSelEntry = FirstSelected();
811  while( pSelEntry )
812  {
813  SwGlblDocContent* pContent = static_cast<SwGlblDocContent*>(pSelEntry->GetUserData());
814  if(GLBLDOC_SECTION == pContent->GetType() &&
815  pContent->GetSection()->IsConnected())
816  {
817  const_cast<SwSection*>(pContent->GetSection())->UpdateNow();
818  }
819 
820  pSelEntry = NextSelected(pSelEntry);
821  }
822  pSelEntry = FirstSelected();
823  while( pSelEntry )
824  {
825  SwGlblDocContent* pContent = static_cast<SwGlblDocContent*>(pSelEntry->GetUserData());
826  if(GLBLDOC_TOXBASE == pContent->GetType())
827  m_pActiveShell->UpdateTableOf(*pContent->GetTOX());
828  pSelEntry = NextSelected(pSelEntry);
829  }
830 
831  }
832  break;
833  case CTX_UPDATE_INDEX:
834  {
835  nSlot = FN_UPDATE_TOX;
836  }
837  break;
838  case CTX_UPDATE_LINK:
839  case CTX_UPDATE_ALL:
840  {
841  m_pActiveShell->GetLinkManager().UpdateAllLinks(true, false, nullptr);
842  if(CTX_UPDATE_ALL == nSelectedPopupEntry)
843  nSlot = FN_UPDATE_TOX;
844  pCont = nullptr;
845  }
846  break;
847  case CTX_EDIT:
848  {
849  OSL_ENSURE(pCont, "edit without entry ? " );
850  if (pCont)
851  {
852  EditContent(pCont);
853  }
854  }
855  break;
856  case CTX_EDIT_LINK:
857  {
858  OSL_ENSURE(pCont, "edit without entry ? " );
859  if (pCont)
860  {
862  pCont->GetSection()->GetSectionName());
863  rDispatch.ExecuteList(FN_EDIT_REGION, SfxCallMode::ASYNCHRON,
864  { &aName });
865  }
866  }
867  break;
868  case CTX_DELETE:
869  {
870  // If several entries selected, then after each delete the array
871  // must be refilled. So you do not have to remember anything,
872  // deleting begins at the end.
873  SvTreeListEntry* pSelEntry = LastSelected();
874  std::unique_ptr<SwGlblDocContents> pTempContents;
876  while(pSelEntry)
877  {
879  pTempContents ? *pTempContents : *m_pSwGlblDocContents,
880  GetModel()->GetAbsPos(pSelEntry));
881  pSelEntry = PrevSelected(pSelEntry);
882  if(pSelEntry)
883  {
884  pTempContents.reset(new SwGlblDocContents);
885  m_pActiveShell->GetGlobalDocContent(*pTempContents);
886  }
887  }
888  pTempContents.reset();
890  pCont = nullptr;
891  }
892  break;
894  {
895  if(pContCopy)
896  {
897  SfxItemSet aSet(
899  svl::Items<
903  RES_COL, RES_COL,
904  SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
905  FN_PARAM_TOX_TYPE, FN_PARAM_TOX_TYPE>{});
906 
908  ScopedVclPtr<AbstractMultiTOXTabDialog> pDlg(pFact->CreateMultiTOXTabDialog(
909  this, aSet,
911  nullptr,
912  true));
913  if(RET_OK == pDlg->Execute())
914  {
915  SwTOXDescription& rDesc = pDlg->GetTOXDescription(
916  pDlg->GetCurrentTOXType());
917  SwTOXMgr aMgr(m_pActiveShell);
918  SwTOXBase* pToInsert = nullptr;
919  if(aMgr.UpdateOrInsertTOX(rDesc, &pToInsert, pDlg->GetOutputItemSet()))
920  m_pActiveShell->InsertGlobalDocContent( *pContCopy, *pToInsert );
921  }
922  pCont = nullptr;
923  }
924  }
925  break;
926  case CTX_INSERT_FILE:
927  {
928  m_pDocContent = std::move(pContCopy);
929  InsertRegion( m_pDocContent.get() );
930  pCont = nullptr;
931  }
932  break;
933  case CTX_INSERT_NEW_FILE:
934  {
935  SfxViewFrame* pGlobFrame = m_pActiveShell->GetView().GetViewFrame();
936  SwGlobalFrameListener_Impl aFrameListener(*pGlobFrame);
937 
938  sal_uLong nEntryPos = pEntry ? GetModel()->GetAbsPos(pEntry) : sal_uLong(-1);
939  // Creating a new doc
940  SfxStringItem aFactory(SID_NEWDOCDIRECT,
941  SwDocShell::Factory().GetFilterContainer()->GetName());
942 
943  const SfxFrameItem* pItem = static_cast<const SfxFrameItem*>(
944  rDispatch.ExecuteList(SID_NEWDOCDIRECT,
945  SfxCallMode::SYNCHRON, { &aFactory }));
946 
947  // save at
948  SfxFrame* pFrame = pItem ? pItem->GetFrame() : nullptr;
949  SfxViewFrame* pViewFrame = pFrame ? pFrame->GetCurrentViewFrame() : nullptr;
950  if (pViewFrame)
951  {
952  const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(
953  pViewFrame->GetDispatcher()->Execute(
954  SID_SAVEASDOC, SfxCallMode::SYNCHRON ));
955  SfxObjectShell& rObj = *pViewFrame->GetObjectShell();
956  const SfxMedium* pMedium = rObj.GetMedium();
957  OUString sNewFile(pMedium->GetURLObject().GetMainURL(INetURLObject::DecodeMechanism::ToIUri));
958  // Insert the area with the Doc-Name
959  // Bring the own Doc in the foreground
960  if(aFrameListener.IsValid() && !sNewFile.isEmpty())
961  {
962  pGlobFrame->ToTop();
963  // Due to the update the entries are invalid
964  if(nEntryPos != sal_uLong(-1))
965  {
966  Update( false );
967  Display();
968  Select(GetModel()->GetEntryAtAbsPos(nEntryPos));
969  pEntry = FirstSelected();
970  pCont = pEntry ? static_cast<SwGlblDocContent*>(pEntry->GetUserData()) : nullptr;
971  }
972  else
973  {
974  pEntry = nullptr;
975  pCont = nullptr;
976  }
977  if(pBool->GetValue())
978  {
979  InsertRegion(pCont, &sNewFile);
980  pViewFrame->ToTop();
981  }
982  else
983  pViewFrame->GetDispatcher()->Execute(SID_CLOSEWIN,
984  SfxCallMode::SYNCHRON);
985  }
986  else
987  {
988  pViewFrame->ToTop();
989  return;
990  }
991  }
992  }
993  break;
994  case CTX_INSERT_TEXT:
995  {
996  if(pCont)
998  else
999  {
1000  m_pActiveShell->SplitNode(); // Empty document
1001  m_pActiveShell->Up( false );
1002  }
1004  }
1005  break;
1006  case CTX_UPDATE:
1007  pCont = nullptr;
1008  break;
1009  default:;
1010  // here nothing happens
1011  }
1012  if(pCont)
1013  GotoContent(pCont);
1014  if(nSlot)
1015  rDispatch.Execute(nSlot);
1016  if(Update( false ))
1017  Display();
1018 }
1019 
1021 {
1022  if(!IsDisposed() && !HasFocus() && Update( false ))
1023  Display();
1024 }
1025 
1027 {
1029 
1030  switch( pCont->GetType() )
1031  {
1032  case GLBLDOC_UNKNOWN:
1034  break;
1035  case GLBLDOC_TOXBASE:
1036  {
1037  const OUString sName = pCont->GetTOX()->GetTOXName();
1038  if (!m_pActiveShell->GotoNextTOXBase(&sName))
1040  }
1041  break;
1042  case GLBLDOC_SECTION:
1043  break;
1044  }
1045 
1046 }
1047 
1049 {
1052 }
1053 
1055 {
1056  m_aUpdateTimer.Stop();
1058 }
1059 
1060 void SwGlobalTree::ExecCommand(const OUString &rCmd)
1061 {
1062  SvTreeListEntry* pEntry = FirstSelected();
1063  OSL_ENSURE(pEntry, "It explodes in the next moment");
1064  if (rCmd == "edit")
1065  {
1066  const SwGlblDocContent* pCont = static_cast<const SwGlblDocContent*>(
1067  pEntry->GetUserData());
1068  EditContent(pCont);
1069  }
1070  else
1071  {
1072  if(GetSelectionCount() == 1)
1073  {
1074  bool bMove = false;
1075  sal_uLong nSource = GetModel()->GetAbsPos(pEntry);
1076  sal_uLong nDest = nSource;
1077  if (rCmd == "down")
1078  {
1079  sal_uLong nEntryCount = GetEntryCount();
1080  bMove = nEntryCount > nSource + 1;
1081  nDest+= 2;
1082  }
1083  else if (rCmd == "up")
1084  {
1085  bMove = 0 != nSource;
1086  nDest--;
1087  }
1088  if( bMove && m_pActiveShell->MoveGlobalDocContent(
1089  *m_pSwGlblDocContents, nSource, nSource + 1, nDest ) &&
1090  Update( false ))
1091  Display();
1092  }
1093  }
1094 }
1095 
1096 bool SwGlobalTree::Update(bool bHard)
1097 {
1098  SwView* pActView = GetParentWindow()->GetCreateView();
1099  bool bRet = false;
1100  if(pActView && pActView->GetWrtShellPtr())
1101  {
1102  const SwWrtShell* pOldShell = m_pActiveShell;
1103  m_pActiveShell = pActView->GetWrtShellPtr();
1104  if(m_pActiveShell != pOldShell)
1105  {
1106  m_pSwGlblDocContents.reset();
1107  }
1109  {
1111  bRet = true;
1113  }
1114  else
1115  {
1116  bool bCopy = false;
1117  std::unique_ptr<SwGlblDocContents> pTempContents(new SwGlblDocContents);
1118  m_pActiveShell->GetGlobalDocContent(*pTempContents);
1119  if(pTempContents->size() != m_pSwGlblDocContents->size() ||
1120  pTempContents->size() != GetEntryCount())
1121  {
1122  bRet = true;
1123  bCopy = true;
1124  }
1125  else
1126  {
1127  for(size_t i = 0; i < pTempContents->size() && !bCopy; i++)
1128  {
1129  SwGlblDocContent* pLeft = (*pTempContents)[i].get();
1130  SwGlblDocContent* pRight = (*m_pSwGlblDocContents)[i].get();
1131  GlobalDocContentType eType = pLeft->GetType();
1132  SvTreeListEntry* pEntry = GetEntry(i);
1133  OUString sTemp = GetEntryText(pEntry);
1134  if (
1135  eType != pRight->GetType() ||
1136  (
1137  eType == GLBLDOC_SECTION &&
1138  pLeft->GetSection()->GetSectionName() != sTemp
1139  ) ||
1140  (
1141  eType == GLBLDOC_TOXBASE &&
1142  pLeft->GetTOX()->GetTitle() != sTemp
1143  )
1144  )
1145  {
1146  bCopy = bRet = true;
1147  }
1148  }
1149  }
1150  if(bCopy || bHard)
1151  {
1152  *m_pSwGlblDocContents = std::move( *pTempContents );
1153  }
1154  }
1155 
1156  }
1157  else
1158  {
1159  Clear();
1161  m_pSwGlblDocContents->clear();
1162  }
1163  // FIXME: Implement a test for changes!
1164  return bRet;
1165 }
1166 
1168 {
1169  const OUString sFileName(pCont->GetSection()->GetLinkFileName().getToken(0,
1171  bool bFound = false;
1172  const SfxObjectShell* pCurr = SfxObjectShell::GetFirst();
1173  while( !bFound && pCurr )
1174  {
1175  if(pCurr->GetMedium() &&
1177  {
1178  bFound = true;
1180  Application::PostUserEvent( LINK( this, SwGlobalTree, ShowFrameHdl ), nullptr, true );
1181  pCurr = nullptr;
1182  }
1183  else
1184  pCurr = SfxObjectShell::GetNext(*pCurr);
1185  }
1186  if(!bFound)
1187  {
1188  SfxStringItem aURL(SID_FILE_NAME, sFileName);
1189  SfxBoolItem aReadOnly(SID_DOC_READONLY, false);
1190  SfxStringItem aTargetFrameName( SID_TARGETNAME, "_blank" );
1191  SfxStringItem aReferer(SID_REFERER, m_pActiveShell->GetView().GetDocShell()->GetTitle());
1193  ExecuteList(SID_OPENDOC, SfxCallMode::ASYNCHRON,
1194  { &aURL, &aReadOnly, &aReferer, &aTargetFrameName });
1195  }
1196 }
1197 
1198 IMPL_LINK_NOARG( SwGlobalTree, DoubleClickHdl, SvTreeListBox*, bool)
1199 {
1200  SvTreeListEntry* pEntry = GetCurEntry();
1201  SwGlblDocContent* pCont = static_cast<SwGlblDocContent*>(pEntry->GetUserData());
1202  if(pCont->GetType() == GLBLDOC_SECTION)
1203  OpenDoc(pCont);
1204  else
1205  {
1206  GotoContent(pCont);
1207  m_pActiveShell->GetView().GetEditWin().GrabFocus();
1208  }
1209  return false;
1210 }
1211 
1213 {
1214  return m_xDialog;
1215 }
1216 
1217 IMPL_STATIC_LINK_NOARG(SwGlobalTree, ShowFrameHdl, void*, void)
1218 {
1219  SfxViewFrame* pFirst = pShowShell ? SfxViewFrame::GetFirst(pShowShell) : nullptr;
1220  if (pFirst)
1221  pFirst->ToTop();
1222  SwGlobalTree::SetShowShell(nullptr);
1223 }
1224 
1226  const OUString& rStr ,const Image& rImg1,const Image& rImg2,
1227  SvLBoxButtonKind eButtonKind)
1228 {
1229  const size_t nColToHilite = 1; //0==Bitmap;1=="Column1";2=="Column2"
1230  SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
1231  SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nColToHilite ));
1232  pEntry->ReplaceItem(std::make_unique<SwLBoxString>(rCol.GetText()), nColToHilite);
1233 }
1234 
1235 void SwLBoxString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
1236  const SvViewDataEntry* pView, const SvTreeListEntry& rEntry)
1237 {
1238  SwGlblDocContent* pCont = static_cast<SwGlblDocContent*>(rEntry.GetUserData());
1239  if (pCont->GetType() == GLBLDOC_SECTION &&
1240  !pCont->GetSection()->IsConnectFlag())
1241  {
1242  rRenderContext.Push(PushFlags::FONT);
1243  vcl::Font aOldFont(rRenderContext.GetFont());
1244  vcl::Font aFont(rRenderContext.GetFont());
1245  aFont.SetColor(COL_LIGHTRED);
1246  rRenderContext.SetFont(aFont);
1247  rRenderContext.DrawText(rPos, GetText());
1248  rRenderContext.Pop();
1249  }
1250  else
1251  SvLBoxString::Paint(rPos, rDev, rRenderContext, pView, rEntry);
1252 }
1253 
1255 {
1256  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1257  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
1258  {
1259  Update(true);
1260  }
1261  SvTreeListBox::DataChanged( rDCEvt );
1262 }
1263 
1264 void SwGlobalTree::InsertRegion( const SwGlblDocContent* _pContent, const Sequence< OUString >& _rFiles )
1265 {
1266  sal_Int32 nFiles = _rFiles.getLength();
1267  if ( !nFiles )
1268  return;
1269 
1270  bool bMove = false;
1271  if ( !_pContent )
1272  {
1273  SvTreeListEntry* pLast = LastVisible();
1274  _pContent = static_cast<SwGlblDocContent*>(pLast->GetUserData());
1275  bMove = true;
1276  }
1277  sal_uLong nEntryCount = GetEntryCount();
1278  const OUString* pFileNames = _rFiles.getConstArray();
1280  rSh.StartAction();
1281  // after insertion of the first new content the 'pCont' parameter becomes invalid
1282  // find the index of the 'anchor' content to always use a current anchor content
1283  size_t nAnchorContent = m_pSwGlblDocContents->size() - 1;
1284  if ( !bMove )
1285  {
1286  for (size_t nContent = 0; nContent < m_pSwGlblDocContents->size();
1287  ++nContent)
1288  {
1289  if( *_pContent == *(*m_pSwGlblDocContents)[ nContent ] )
1290  {
1291  nAnchorContent = nContent;
1292  break;
1293  }
1294  }
1295  }
1296  SwGlblDocContents aTempContents;
1297  for ( sal_Int32 nFile = 0; nFile < nFiles; ++nFile )
1298  {
1299  //update the global document content after each inserted document
1300  rSh.GetGlobalDocContent(aTempContents);
1301  SwGlblDocContent* pAnchorContent = nullptr;
1302  OSL_ENSURE(aTempContents.size() > (nAnchorContent + nFile), "invalid anchor content -> last insertion failed");
1303  if ( aTempContents.size() > (nAnchorContent + nFile) )
1304  pAnchorContent = aTempContents[nAnchorContent + nFile].get();
1305  else
1306  pAnchorContent = aTempContents.back().get();
1307  OUString sFileName(pFileNames[nFile]);
1308  INetURLObject aFileUrl;
1309  aFileUrl.SetSmartURL( sFileName );
1310  OUString sSectionName(aFileUrl.GetLastName(
1312  sal_uInt16 nSectCount = rSh.GetSectionFormatCount();
1313  OUString sTempSectionName(sSectionName);
1314  sal_uInt16 nAddNumber = 0;
1315  sal_uInt16 nCount = 0;
1316  // if applicable: add index if the range name is already in use.
1317  while ( nCount < nSectCount )
1318  {
1319  const SwSectionFormat& rFormat = rSh.GetSectionFormat(nCount);
1320  if ((rFormat.GetSection()->GetSectionName() == sTempSectionName)
1321  && rFormat.IsInNodesArr())
1322  {
1323  nCount = 0;
1324  nAddNumber++;
1325  sTempSectionName = sSectionName + ":" + OUString::number( nAddNumber );
1326  }
1327  else
1328  nCount++;
1329  }
1330 
1331  if ( nAddNumber )
1332  sSectionName = sTempSectionName;
1333 
1334  SwSectionData aSectionData(CONTENT_SECTION, sSectionName);
1335  aSectionData.SetProtectFlag(true);
1336  aSectionData.SetHidden(false);
1337 
1338  aSectionData.SetLinkFileName(sFileName);
1339  aSectionData.SetType(FILE_LINK_SECTION);
1340  aSectionData.SetLinkFilePassword( OUString() );
1341 
1342  rSh.InsertGlobalDocContent( *pAnchorContent, aSectionData );
1343  }
1344  if ( bMove )
1345  {
1346  Update( false );
1348  *m_pSwGlblDocContents, nEntryCount, nEntryCount + nFiles, nEntryCount - nFiles );
1349  }
1350  rSh.EndAction();
1351  Update( false );
1352  Display();
1353 
1354 }
1355 
1356 IMPL_LINK( SwGlobalTree, DialogClosedHdl, sfx2::FileDialogHelper*, _pFileDlg, void )
1357 {
1358  if ( ERRCODE_NONE != _pFileDlg->GetError() )
1359  return;
1360 
1361  SfxMediumList aMedList(m_pDocInserter->CreateMediumList());
1362  if ( !aMedList.empty() )
1363  {
1364  Sequence< OUString >aFileNames( aMedList.size() );
1365  OUString* pFileNames = aFileNames.getArray();
1366  sal_Int32 nPos = 0;
1367  for (std::unique_ptr<SfxMedium>& pMed : aMedList)
1368  {
1369  OUString sFileName = pMed->GetURLObject().GetMainURL( INetURLObject::DecodeMechanism::NONE )
1370  + OUStringLiteral1(sfx2::cTokenSeparator)
1371  + pMed->GetFilter()->GetFilterName()
1372  + OUStringLiteral1(sfx2::cTokenSeparator);
1373  pFileNames[nPos++] = sFileName;
1374  }
1375  InsertRegion( m_pDocContent.get(), aFileNames );
1376  m_pDocContent.reset();
1377  }
1378 }
1379 
1380 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
bool GetValue() const
long Width() const
MenuEnableFlags GetEnableFlags() const
Definition: glbltree.cxx:453
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
virtual Size GetOptimalSize() const override
Definition: glbltree.cxx:213
const OUString GetItemCommand(sal_uInt16 nItemId) const
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
#define FN_UPDATE_TOX
Definition: cmdid.h:483
#define RES_FRM_SIZE
Definition: hintids.hxx:194
#define RES_COL
Definition: hintids.hxx:214
const Value & back() const
SvTreeListEntry * NextSelected(SvTreeListEntry *pEntry) const
void EditContent(const SwGlblDocContent *pCont)
Definition: glbltree.cxx:753
const css::datatransfer::dnd::DropTargetDropEvent maDropEvent
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: glbltree.cxx:483
void SplitNode(bool bAutoFormat=false)
Definition: wrtsh1.cxx:966
#define CTX_DELETE
Definition: glbltree.cxx:79
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: glbltree.cxx:615
virtual VclPtr< PopupMenu > CreateContextMenu() override
Definition: glbltree.cxx:355
#define FN_EDIT_REGION
Definition: cmdid.h:107
#define CTX_EDIT_LINK
Definition: glbltree.cxx:80
SwNavigationPI * GetParentWindow()
Definition: glbltree.cxx:1212
virtual DragDropMode NotifyStartDrag(TransferDataContainer &rData, SvTreeListEntry *) override
Definition: glbltree.cxx:555
bool MoveGlobalDocContent(const SwGlblDocContents &rArr, size_t nFromPos, size_t nToPos, size_t nNewPos)
Definition: edglbldc.cxx:298
virtual void DragFinished(sal_Int8 nDropAction)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
long AdjustX(long nHorzMove)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
sfx2::LinkManager & GetLinkManager()
Definition: editsh.cxx:598
SfxFrame * GetFrame() const
virtual void DragFinished(sal_Int8) override
Definition: glbltree.cxx:606
virtual SvTreeListEntry * InsertEntry(const OUString &rText, SvTreeListEntry *pParent=nullptr, bool bChildrenOnDemand=false, sal_uLong nPos=TREELIST_APPEND, void *pUserData=nullptr, SvLBoxButtonKind eButtonKind=SvLBoxButtonKind::EnabledCheckbox)
void SetHelpId(sal_uInt16 nItemId, const OString &rHelpId)
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
Definition: glbltree.cxx:600
signed char sal_Int8
SvTreeList * GetModel() const
bool m_bLastEntryEmphasis
Definition: conttree.hxx:274
virtual void Paint(const Point &rPos, SvTreeListBox &rOutDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry) override
SfxDispatcher * GetDispatcher()
const Size & GetSize(const SvTreeListBox *pView, const SvTreeListEntry *pEntry) const
void SetDoubleClickHdl(const Link< SvTreeListBox *, bool > &rNewHdl)
sal_uIntPtr sal_uLong
std::unique_ptr< SwGlblDocContents > m_pSwGlblDocContents
Definition: conttree.hxx:268
void disposeAndClear()
sal_uLong GetEntryCount() const
SvLBoxItem * GetItem(SvTreeListEntry *, long nX, SvLBoxTab **ppTab)
#define GLOBAL_CONTEXT_COUNT
Definition: swcont.hxx:48
const sal_Unicode cTokenSeparator
static const SfxObjectShell * pShowShell
Definition: conttree.hxx:276
bool IsDropFormatSupported(SotClipboardFormatId nFormat)
virtual Size GetSizePixel() const
bool IsConnected() const
Definition: section.hxx:225
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
sal_uInt16 GetCode() const
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
virtual TriState NotifyMoving(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uLong &rNewChildPos) override
Definition: glbltree.cxx:568
DataChangedEventType GetType() const
void EnterStdMode()
Definition: select.cxx:552
SwEditWin & GetEditWin()
Definition: view.hxx:403
sal_uInt16 Execute(vcl::Window *pWindow, const Point &rPopupPos)
constexpr::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
OUString GetLastName(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
const OUString & GetText() const
long GetPos() const
virtual void RequestHelp(const HelpEvent &rHEvt) override
void SetHelpId(const OString &)
virtual bool DoubleClickHdl()
OUString const & GetLinkFileName() const
Definition: section.cxx:548
static const char * aHelpForMenu[]
Definition: glbltree.cxx:88
virtual SfxObjectShell * GetObjectShell() override
#define HID_GLBLTREE_INSERT
Definition: helpids.h:43
virtual bool NotifyAcceptDrop(SvTreeListEntry *) override
Definition: glbltree.cxx:595
bool HasFormat(SotClipboardFormatId nFormat) const
SvTreeListEntry * LastSelected() const
#define CTX_EDIT
Definition: glbltree.cxx:78
HelpEventMode GetMode() const
SfxHintId GetId() const
SwGlobalTree(vcl::Window *pParent, SwNavigationPI *pDialog)
Definition: glbltree.cxx:173
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint) override
Definition: glbltree.cxx:131
virtual sal_IntPtr GetTabPos(SvTreeListEntry *, SvLBoxTab *) override
Definition: glbltree.cxx:563
void EnableContextMenuHandling()
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: glbltree.cxx:1254
void SetUpdateMode(bool)
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
sal_uLong GetAbsPos(SvTreeListEntry const *pEntry) const
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
IMPL_STATIC_LINK_NOARG(SwGlobalTree, ShowFrameHdl, void *, void)
Definition: glbltree.cxx:1217
weld::Window * GetFrameWeld() const
sal_uInt16 GetClicks() const
#define GLOBAL_UPDATE_TIMEOUT
Definition: glbltree.cxx:82
const SwView & GetView() const
Definition: wrtsh.hxx:424
bool GotoNextTOXBase(const OUString *pName=nullptr)
Definition: move.cxx:642
virtual void GetFocus() override
DragDropMode
#define KEY_MOD2
void setX(long nX)
SvTreeListEntry * FirstSelected() const
const vcl::Font & GetFont() const
virtual TriState NotifyCopying(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uLong &rNewChildPos) override
Definition: glbltree.cxx:586
void SetDragDropMode(DragDropMode)
#define HID_GLBLTREE_UPD_LINK
Definition: helpids.h:52
virtual void KeyInput(const KeyEvent &rKEvt) override
bool GotoPrevTOXBase(const OUString *=nullptr)
jump to previous index
Definition: crstrvl.cxx:314
#define DND_ACTION_NONE
AllSettingsFlags GetFlags() const
static OUString CreateDropFileName(TransferableDataHelper &rData)
Definition: navipi.cxx:1039
void ToggleTree()
Definition: navipi.cxx:1149
#define HID_GLBLTREE_INS_NEW_FILE
Definition: helpids.h:48
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: glbltree.cxx:296
SfxViewFrame * GetCurrentViewFrame() const
virtual void InitEntry(SvTreeListEntry *, const OUString &, const Image &, const Image &, SvLBoxButtonKind)
sal_uInt16 GetModifier() const
void InsertSeparator(const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
size_type size() const
void UpdateTableOf(const SwTOXBase &rTOX, const SfxItemSet *pSet=nullptr)
Definition: wrtsh2.cxx:323
const SwSectionFormat & GetSectionFormat(size_t nFormat) const
Definition: edsect.cxx:142
void GotoContent(const SwGlblDocContent *)
Definition: glbltree.cxx:1026
#define CTX_INSERT_NEW_FILE
Definition: glbltree.cxx:68
MenuEnableFlags
Definition: conttree.hxx:55
SfxItemPool & GetPool() const
void Update()
tools::Rectangle GetItemRect(sal_uInt16 nItemId)
void SetPopupMenu(sal_uInt16 nItemId, PopupMenu *pMenu)
const Point & GetMousePosPixel() const
SvLBoxButtonKind
#define RES_BACKGROUND
Definition: hintids.hxx:210
std::unique_ptr< sfx2::DocumentInserter > m_pDocInserter
Definition: conttree.hxx:271
#define HID_GLBLTREE_DEL
Definition: helpids.h:45
#define HID_GLBLTREE_EDIT_LINK
Definition: helpids.h:55
#define CTX_UPDATE_INDEX
Definition: glbltree.cxx:72
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
void clear()
bool Up(bool bSelect, sal_uInt16 nCount=1, bool bBasicCall=false)
Definition: move.cxx:137
#define CTX_INSERT_FILE
Definition: glbltree.cxx:67
void SetSelectHdl(const Link< Menu *, bool > &rLink)
#define HID_GLBLTREE_INS_IDX
Definition: helpids.h:46
void EndSelection()
VclPtr< ToolBox > m_aGlobalToolBox
Definition: navipi.hxx:72
sal_uLong GetAbsPos(const SvTreeListEntry *pEntry) const
SvTreeListEntry * m_pDDSource
Definition: conttree.hxx:267
#define HID_GLBLTREE_UPDATE
Definition: helpids.h:42
#define HID_GLBLTREE_UPD_IDX
Definition: helpids.h:51
const OUString & GetSectionName() const
Definition: section.hxx:169
void Clear()
Definition: glbltree.cxx:649
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:229
void DeleteGlobalDocContent(const SwGlblDocContents &rArr, size_t nPos)
Definition: edglbldc.cxx:234
static void SetShowShell(const SfxObjectShell *pSet)
Definition: conttree.hxx:332
virtual void dispose() override
Definition: glbltree.cxx:204
OUString sName
int i
#define CTX_UPDATE_SEL
Definition: glbltree.cxx:71
TRISTATE_FALSE
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
css::uno::Reference< css::datatransfer::dnd::XDropTarget > GetDropTarget()
void * GetUserData() const
IMPL_LINK(SwGlobalTree, PopupHdl, Menu *, pMenu, bool)
Definition: glbltree.cxx:787
virtual void Start() override
OUString GetFile(size_t nIndex) const
size
#define CTX_UPDATE
Definition: glbltree.cxx:76
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
Display
GUIDCNamePair const aData
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
#define DND_ACTION_LINK
virtual OUString GetEntryText(SvTreeListEntry *pEntry) const
const SvLBoxItem & GetItem(size_t nPos) const
size_t Count() const
DocumentType const eType
void SetTimeout(sal_uInt64 nTimeoutMs)
Point ScreenToOutputPixel(const Point &rPos) const
void GrabFocus()
GlobalDocContentType
Definition: edglbldc.hxx:28
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
const OUString & GetTitle() const
Definition: tox.hxx:674
long X() const
void GetGlobalDocContent(SwGlblDocContents &rArr) const
Definition: edglbldc.cxx:55
void GotoGlobalDocContent(const SwGlblDocContent &rPos)
Definition: edglbldc.cxx:335
static bool IsBalloonHelpEnabled()
SwDocShell * GetDocShell()
Definition: view.cxx:1115
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
bool IsReadOnly() const
void InsertRegion(const SwGlblDocContent *_pContent, const css::uno::Sequence< OUString > &_rFiles)
Point GetEntryPosition(SvTreeListEntry *) const
void SetColor(const Color &)
#define HID_GLBLTREE_UPD_SEL
Definition: helpids.h:50
virtual SvLBoxItemType GetType() const =0
#define RES_LR_SPACE
Definition: hintids.hxx:196
Point LogicToPixel(const Point &rLogicPt) const
void StartAction()
Definition: crsrsh.cxx:212
SvTreeListEntry * Next(SvTreeListEntry *pEntry) const
void HideTree()
Definition: glbltree.cxx:1054
SwView * GetCreateView() const
Definition: navipi.cxx:1211
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
#define KEY_RETURN
SvTreeListEntry * LastVisible() const
SvTreeListEntry * First() const
const SwTOXBase * GetTOX() const
Definition: edglbldc.hxx:52
size_t GetSectionFormatCount() const
Definition: edsect.cxx:114
AutoTimer m_aUpdateTimer
Definition: conttree.hxx:262
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
const vcl::KeyCode & GetKeyCode() const
SwWrtShell * m_pActiveShell
Definition: conttree.hxx:265
void InsertGlobalDocContent(const SwGlblDocContent &rPos, SwSectionData &rNew)
Definition: edglbldc.cxx:132
SvTreeListEntry * m_pEmphasisEntry
Definition: conttree.hxx:266
IMPL_LINK_NOARG(SwGlobalTree, Timeout, Timer *, void)
Definition: glbltree.cxx:1020
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:401
virtual void Paint(const Point &rPos, SvTreeListBox &rDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry) override
Definition: glbltree.cxx:1235
#define HID_GLBLTREE_INS_FILE
Definition: helpids.h:47
void Stop()
VclPtr< SwNavigationPI > m_xDialog
Definition: conttree.hxx:261
virtual void InitEntry(SvTreeListEntry *, const OUString &, const Image &, const Image &, SvLBoxButtonKind) override
Definition: glbltree.cxx:1225
#define HID_NAVIGATOR_GLOB_TREELIST
Definition: helpids.h:41
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: glbltree.cxx:218
#define ERRCODE_NONE
static SfxObjectShell * GetFirst(const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
void UpdateAllLinks(bool bAskUpdate, bool bUpdateGrfLinks, weld::Window *pParentWin)
bool m_bIsInternalDrag
Definition: conttree.hxx:273
GlobalDocContentType GetType() const
Query contents.
Definition: edglbldc.hxx:49
void SetFont(const vcl::Font &rNewFont)
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: glbltree.cxx:632
void ReplaceItem(std::unique_ptr< SvLBoxItem > pNewItem, size_t nPos)
bool IsLeft() const
void OpenDoc(const SwGlblDocContent *)
Definition: glbltree.cxx:1167
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uLong nPos) const
RET_OK
#define HID_GLBLTREE_EDIT
Definition: helpids.h:44
bool IsConnectFlag() const
Definition: section.hxx:239
static VclPtr< reference_type > Create(Arg &&...arg)
const SwSection * GetSection() const
Definition: edglbldc.hxx:50
bool GetFileList(SotClipboardFormatId nFormat, FileList &rFileList)
const INetURLObject & GetURLObject() const
#define HID_GLBLTREE_INS_TEXT
Definition: helpids.h:49
#define CTX_UPDATE_ALL
Definition: glbltree.cxx:74
void Display(bool bOnlyUpdateUserData=false)
Definition: glbltree.cxx:655
SwGlobalFrameListener_Impl(SfxViewFrame &rFrame)
Definition: glbltree.cxx:120
#define CTX_INSERT_ANY_INDEX
Definition: glbltree.cxx:66
void SetInvokeHandler(const Link< Timer *, void > &rLink)
const Point & GetPosPixel() const
virtual void ExecuteContextMenuAction(sal_uInt16 nSelectedPopupEntry) override
Definition: glbltree.cxx:793
#define GLBL_TABPOS_SUB
Definition: glbltree.cxx:85
virtual void SelectHdl() override
Definition: glbltree.cxx:531
SvTreeListEntry * PrevSelected(SvTreeListEntry *pEntry) const
virtual void dispose() override
SvTreeListEntry * GetEntryAtAbsPos(sal_uLong nAbsPos) const
#define CTX_UPDATE_LINK
Definition: glbltree.cxx:73
OString const aName
WindowType GetType() const
sal_uInt16 GetItemId(ImplToolItems::size_type nPos) const
#define CTX_INSERT
Definition: glbltree.cxx:77
void ExecCommand(const OUString &rCmd)
Definition: glbltree.cxx:1060
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual void GetFocus() override
Definition: glbltree.cxx:625
static SfxObjectShell * GetNext(const SfxObjectShell &rPrev, const std::function< bool(const SfxObjectShell *)> &isObjectShell=nullptr, bool bOnlyVisible=true)
#define FN_PARAM_TOX_TYPE
Definition: cmdid.h:778
void ImplShowTargetEmphasis(SvTreeListEntry *pEntry, bool bShow)
#define CTX_INSERT_TEXT
Definition: glbltree.cxx:69
Point OutputToScreenPixel(const Point &rPos) const
virtual bool Select(SvTreeListEntry *pEntry, bool bSelect=true)
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
OUString m_aContextStrings[GLOBAL_CONTEXT_COUNT]
Definition: conttree.hxx:263
static const char * GLOBAL_CONTEXT_ARY[]
Definition: glbltree.cxx:155
virtual ~SwGlobalTree() override
Definition: glbltree.cxx:199
void TbxMenuHdl(sal_uInt16 nTbxId, ToolBox *pBox)
Definition: glbltree.cxx:414
std::unique_ptr< SwGlblDocContent > m_pDocContent
Definition: conttree.hxx:270
#define TREELIST_ENTRY_NOTFOUND
SwSection * GetSection() const
Definition: section.cxx:675
bool Detect(bool bExtendedInfo=false)
sal_Int8 mnAction
TriState
#define FN_INSERT_MULTI_TOX
Definition: cmdid.h:272
sal_uLong GetSelectionCount() const
void Push(PushFlags nFlags=PushFlags::ALL)
sal_Int32 nPos
void setWidth(long nWidth)
GLOBAL_CONTEXT_IDX
Definition: glbltree.cxx:137
void ShowTree()
Definition: glbltree.cxx:1048
#define HID_GLBLTREEUPD_ALL
Definition: helpids.h:53
SvTreeListEntry * Prev(SvTreeListEntry *pEntry) const
sal_uLong GetDocPos() const
Definition: edglbldc.hxx:54
Definition: view.hxx:146
virtual void DeselectHdl() override
Definition: glbltree.cxx:550
bool UpdateOrInsertTOX(const SwTOXDescription &rDesc, SwTOXBase **ppBase, const SfxItemSet *pSet)
Definition: toxmgr.cxx:268
bool SetSmartURL(OUString const &rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
const OUString & GetTOXName() const
Definition: tox.hxx:441
static void ShowBalloon(vcl::Window *pParent, const Point &rScreenPos, const tools::Rectangle &, const OUString &rHelpText)
#define TREELIST_APPEND
::std::vector< std::unique_ptr< SfxMedium > > SfxMediumList
bool IsMod1() const
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
bool IsInNodesArr() const
Definition: section.cxx:919
SfxMedium * GetMedium() const