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