LibreOffice Module sw (master)  1
content.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 <comphelper/string.hxx>
21 #include <svl/urlbmk.hxx>
22 #include <osl/thread.h>
23 #include <sal/log.hxx>
24 #include <tools/urlobj.hxx>
25 #include <sfx2/docfile.hxx>
26 #include <sfx2/dispatch.hxx>
27 #include <sfx2/event.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <o3tl/enumrange.hxx>
30 #include <o3tl/sorted_vector.hxx>
31 #include <vcl/help.hxx>
32 #include <vcl/settings.hxx>
33 #include <sot/formats.hxx>
34 #include <uiitems.hxx>
35 #include <fmtinfmt.hxx>
36 #include <txtinet.hxx>
37 #include <fmtfld.hxx>
38 #include <swmodule.hxx>
39 #include <wrtsh.hxx>
40 #include <view.hxx>
41 #include <docsh.hxx>
42 #include <drawdoc.hxx>
43 #include <content.hxx>
44 #include <frmfmt.hxx>
45 #include <fldbas.hxx>
46 #include <txtatr.hxx>
47 #include <IMark.hxx>
48 #include <section.hxx>
49 #include <tox.hxx>
50 #include <navipi.hxx>
51 #include <navicont.hxx>
52 #include <navicfg.hxx>
53 #include <edtwin.hxx>
54 #include <doc.hxx>
57 #include <unotools.hxx>
58 #include <unotxvw.hxx>
59 #include <cmdid.h>
60 #include <helpids.h>
61 #include <strings.hrc>
62 #include <com/sun/star/text/XTextSectionsSupplier.hpp>
63 #include <com/sun/star/text/XTextGraphicObjectsSupplier.hpp>
64 #include <com/sun/star/text/XTextTablesSupplier.hpp>
65 #include <com/sun/star/text/XDocumentIndexesSupplier.hpp>
66 #include <com/sun/star/text/XDocumentIndex.hpp>
67 #include <com/sun/star/text/XBookmarksSupplier.hpp>
68 #include <com/sun/star/text/XTextEmbeddedObjectsSupplier.hpp>
69 #include <com/sun/star/text/XTextFramesSupplier.hpp>
70 #include <dcontact.hxx>
71 #include <svx/svdogrp.hxx>
72 #include <svx/svdmodel.hxx>
73 #include <svx/svdpage.hxx>
74 #include <svx/svdview.hxx>
75 #include <vcl/scrbar.hxx>
76 #include <SwRewriter.hxx>
77 #include <hints.hxx>
78 #include <numrule.hxx>
79 #include <swundo.hxx>
80 #include <ndtxt.hxx>
81 #include <fmtcntnt.hxx>
82 #include <PostItMgr.hxx>
83 #include <postithelper.hxx>
84 #include <redline.hxx>
85 #include <docary.hxx>
86 #include <vcl/treelistentry.hxx>
87 
88 #include <swabstdlg.hxx>
89 #include <globals.hrc>
90 #include <bitmaps.hlst>
91 #include <unomid.h>
92 
93 #include <navmgr.hxx>
94 #include <AnnotationWin.hxx>
95 #include <memory>
96 
97 #define CTYPE_CNT 0
98 #define CTYPE_CTT 1
99 
100 using namespace ::std;
101 using namespace ::com::sun::star;
102 using namespace ::com::sun::star::text;
103 using namespace ::com::sun::star::uno;
104 using namespace ::com::sun::star::container;
105 
106 #define NAVI_BOOKMARK_DELIM u'\x0001'
107 
109  : public o3tl::sorted_vector<std::unique_ptr<SwContent>, o3tl::less_uniqueptr_to<SwContent>,
110  o3tl::find_partialorder_ptrequals>
111 {
112 };
113 
114 bool SwContentTree::bIsInDrag = false;
115 
116 namespace
117 {
118  bool lcl_IsContent(const SvTreeListEntry* pEntry)
119  {
120  return static_cast<const SwTypeNumber*>(pEntry->GetUserData())->GetTypeId() == CTYPE_CNT;
121  }
122 
123  bool lcl_IsContentType(const SvTreeListEntry* pEntry)
124  {
125  return static_cast<const SwTypeNumber*>(pEntry->GetUserData())->GetTypeId() == CTYPE_CTT;
126  }
127 
128  bool lcl_FindShell(SwWrtShell const * pShell)
129  {
130  bool bFound = false;
131  SwView *pView = SwModule::GetFirstView();
132  while (pView)
133  {
134  if(pShell == &pView->GetWrtShell())
135  {
136  bFound = true;
137  break;
138  }
139  pView = SwModule::GetNextView(pView);
140  }
141  return bFound;
142  }
143 
144  bool lcl_IsUiVisibleBookmark(const IDocumentMarkAccess::pMark_t& rpMark)
145  {
147  }
148 
149  size_t lcl_InsertURLFieldContent(
150  SwContentArr *pMember,
151  SwWrtShell* pWrtShell,
152  const SwContentType *pCntType)
153  {
155  pWrtShell->GetINetAttrs( aArr );
156  const SwGetINetAttrs::size_type nCount {aArr.size()};
157  for( SwGetINetAttrs::size_type n = 0; n < nCount; ++n )
158  {
159  SwGetINetAttr* p = &aArr[ n ];
160  std::unique_ptr<SwURLFieldContent> pCnt(new SwURLFieldContent(
161  pCntType,
162  p->sText,
166  &p->rINetAttr,
167  n ));
168  pMember->insert( std::move(pCnt) );
169  }
170  return nCount;
171  }
172 }
173 
174 // Content, contains names and reference at the content type.
175 
176 SwContent::SwContent(const SwContentType* pCnt, const OUString& rName, long nYPos) :
178  pParent(pCnt),
179  sContentName(rName),
180  nYPosition(nYPos),
181  bInvisible(false)
182 {
183 }
184 
185 
187 {
188 }
189 
191 {
192  return false;
193 }
194 
196 {
197  return pField->IsProtect();
198 }
199 
201 {
202  return pINetAttr->IsProtect();
203 }
204 
206 {
207 }
208 
210 {
211 }
212 
213 static const char* STR_CONTENT_TYPE_ARY[] =
214 {
215  STR_CONTENT_TYPE_OUTLINE,
216  STR_CONTENT_TYPE_TABLE,
217  STR_CONTENT_TYPE_FRAME,
218  STR_CONTENT_TYPE_GRAPHIC,
219  STR_CONTENT_TYPE_OLE,
220  STR_CONTENT_TYPE_BOOKMARK,
221  STR_CONTENT_TYPE_REGION,
222  STR_CONTENT_TYPE_URLFIELD,
223  STR_CONTENT_TYPE_REFERENCE,
224  STR_CONTENT_TYPE_INDEX,
225  STR_CONTENT_TYPE_POSTIT,
226  STR_CONTENT_TYPE_DRAWOBJECT
227 };
228 
229 static const char* STR_CONTENT_TYPE_SINGLE_ARY[] =
230 {
231  STR_CONTENT_TYPE_SINGLE_OUTLINE,
232  STR_CONTENT_TYPE_SINGLE_TABLE,
233  STR_CONTENT_TYPE_SINGLE_FRAME,
234  STR_CONTENT_TYPE_SINGLE_GRAPHIC,
235  STR_CONTENT_TYPE_SINGLE_OLE,
236  STR_CONTENT_TYPE_SINGLE_BOOKMARK,
237  STR_CONTENT_TYPE_SINGLE_REGION,
238  STR_CONTENT_TYPE_SINGLE_URLFIELD,
239  STR_CONTENT_TYPE_SINGLE_REFERENCE,
240  STR_CONTENT_TYPE_SINGLE_INDEX,
241  STR_CONTENT_TYPE_SINGLE_POSTIT,
242  STR_CONTENT_TYPE_SINGLE_DRAWOBJECT
243 };
244 
245 namespace
246 {
247  bool checkVisibilityChanged(
248  const SwContentArr& rSwContentArrA,
249  const SwContentArr& rSwContentArrB)
250  {
251  if(rSwContentArrA.size() != rSwContentArrB.size())
252  {
253  return true;
254  }
255 
256  for(size_t a(0); a < rSwContentArrA.size(); a++)
257  {
258  if(rSwContentArrA[a]->IsInvisible() != rSwContentArrB[a]->IsInvisible())
259  {
260  return true;
261  }
262  }
263 
264  return false;
265  }
266 } // end of anonymous namespace
267 
270  m_pWrtShell(pShell),
271  m_sContentTypeName(SwResId(STR_CONTENT_TYPE_ARY[static_cast<int>(nType)])),
272  m_sSingleContentTypeName(SwResId(STR_CONTENT_TYPE_SINGLE_ARY[static_cast<int>(nType)])),
273  m_nMemberCount(0),
274  m_nContentType(nType),
275  m_nOutlineLevel(nLevel),
276  m_bDataValid(false),
277  m_bEdit(false),
278  m_bDelete(true)
279 {
280  Init();
281 }
282 
283 void SwContentType::Init(bool* pbInvalidateWindow)
284 {
285  // if the MemberCount is changing ...
286  size_t nOldMemberCount = m_nMemberCount;
287  m_nMemberCount = 0;
288  switch(m_nContentType)
289  {
291  {
292  m_sTypeToken = "outline";
294  if (m_nMemberCount < MAXLEVEL)
295  {
296  const size_t nOutlineCount = m_nMemberCount;
297  for(size_t j = 0; j < nOutlineCount; ++j)
298  {
301  {
302  m_nMemberCount --;
303  }
304  }
305  }
306  m_bDelete = false;
307  }
308  break;
309 
310  case ContentTypeId::TABLE :
311  m_sTypeToken = "table";
313  m_bEdit = true;
314  break;
315 
316  case ContentTypeId::FRAME :
318  case ContentTypeId::OLE :
319  {
321  m_sTypeToken = "frame";
323  {
324  eType = FLYCNTTYPE_OLE;
325  m_sTypeToken = "ole";
326  }
328  {
329  eType = FLYCNTTYPE_GRF;
330  m_sTypeToken = "graphic";
331  }
332  m_nMemberCount = m_pWrtShell->GetFlyCount(eType, /*bIgnoreTextBoxes=*/true);
333  m_bEdit = true;
334  }
335  break;
337  {
339  m_nMemberCount = count_if(
340  pMarkAccess->getBookmarksBegin(),
341  pMarkAccess->getBookmarksEnd(),
342  &lcl_IsUiVisibleBookmark);
343  m_sTypeToken.clear();
344  m_bEdit = true;
345  }
346  break;
347  case ContentTypeId::REGION :
348  {
349  std::unique_ptr<SwContentArr> pOldMember;
350  if(!m_pMember)
351  m_pMember.reset( new SwContentArr );
352  else if(!m_pMember->empty())
353  {
354  pOldMember = std::move(m_pMember);
355  m_pMember.reset( new SwContentArr );
356  }
357  const Point aNullPt;
359  for(size_t i = 0; i < m_nMemberCount; ++i)
360  {
361  const SwSectionFormat* pFormat;
362  SectionType eTmpType;
363  if( (pFormat = &m_pWrtShell->GetSectionFormat(i))->IsInNodesArr() &&
364  (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
365  && TOX_HEADER_SECTION != eTmpType )
366  {
367  const OUString& rSectionName =
368  pFormat->GetSection()->GetSectionName();
369  sal_uInt8 nLevel = 0;
370  SwSectionFormat* pParentFormat = pFormat->GetParent();
371  while(pParentFormat)
372  {
373  nLevel++;
374  pParentFormat = pParentFormat->GetParent();
375  }
376 
377  std::unique_ptr<SwContent> pCnt(new SwRegionContent(this, rSectionName,
378  nLevel,
379  pFormat->FindLayoutRect( false, &aNullPt ).Top()));
380 
381  SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, nullptr );
382  if( !pFormat->GetInfo( aAskItem ) &&
383  !aAskItem.pObject ) // not visible
384  pCnt->SetInvisible();
385  m_pMember->insert(std::move(pCnt));
386  }
387  }
388  m_nMemberCount = m_pMember->size();
389  m_sTypeToken = "region";
390  m_bEdit = true;
391  m_bDelete = false;
392  if(pOldMember)
393  {
394  if(nullptr != pbInvalidateWindow)
395  {
396  // need to check visibility (and equal entry number) after
397  // creation due to a sorted list being used here (before,
398  // entries with same index were compared already at creation
399  // time what worked before a sorted list was used)
400  *pbInvalidateWindow = checkVisibilityChanged(
401  *pOldMember,
402  *m_pMember);
403  }
404  }
405  }
406  break;
408  {
410  m_bEdit = true;
411  m_bDelete = false;
412  }
413  break;
415  {
417  m_bDelete = false;
418  }
419  break;
421  {
422  m_nMemberCount = 0;
423  if(!m_pMember)
424  m_pMember.reset( new SwContentArr );
425  else
426  m_pMember->clear();
427 
428  m_nMemberCount = lcl_InsertURLFieldContent(m_pMember.get(), m_pWrtShell, this);
429 
430  m_bEdit = true;
431  nOldMemberCount = m_nMemberCount;
432  m_bDelete = false;
433  }
434  break;
436  {
437  m_nMemberCount = 0;
438  if(!m_pMember)
439  m_pMember.reset( new SwContentArr );
440  else
441  m_pMember->clear();
442 
444  if (aMgr)
445  {
446  for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
447  {
448  if (const SwFormatField* pFormatField = dynamic_cast<const SwFormatField *>((*i)->GetBroadcaster())) // SwPostit
449  {
450  if (pFormatField->GetTextField() && pFormatField->IsFieldInDoc() &&
451  (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
452  {
453  OUString sEntry = pFormatField->GetField()->GetPar2();
454  sEntry = RemoveNewline(sEntry);
455  std::unique_ptr<SwPostItContent> pCnt(new SwPostItContent(
456  this,
457  sEntry,
458  pFormatField,
459  m_nMemberCount));
460  m_pMember->insert(std::move(pCnt));
461  m_nMemberCount++;
462  }
463  }
464  }
465  }
466  m_sTypeToken.clear();
467  m_bEdit = true;
468  nOldMemberCount = m_nMemberCount;
469  }
470  break;
472  {
473  m_sTypeToken.clear();
474  m_nMemberCount = 0;
476  if(pModel)
477  {
478  SdrPage* pPage = pModel->GetPage(0);
479  const size_t nCount = pPage->GetObjCount();
480  for( size_t i=0; i<nCount; ++i )
481  {
482  SdrObject* pTemp = pPage->GetObj(i);
483  // #i51726# - all drawing objects can be named now
484  if (!pTemp->GetName().isEmpty())
485  m_nMemberCount++;
486  }
487  }
488  }
489  break;
490  default: break;
491  }
492  // ... then, the data can also no longer be valid,
493  // apart from those which have already been corrected,
494  // then nOldMemberCount is nevertheless not so old.
495  if( nOldMemberCount != m_nMemberCount )
496  m_bDataValid = false;
497 }
498 
500 {
501 }
502 
503 const SwContent* SwContentType::GetMember(size_t nIndex)
504 {
505  if(!m_bDataValid || !m_pMember)
506  {
507  FillMemberList();
508  }
509  if(nIndex < m_pMember->size())
510  return (*m_pMember)[nIndex].get();
511 
512  return nullptr;
513 }
514 
516 {
517  m_bDataValid = false;
518 }
519 
520 void SwContentType::FillMemberList(bool* pbLevelOrVisibilityChanged)
521 {
522  std::unique_ptr<SwContentArr> pOldMember;
523  size_t nOldMemberCount = 0;
524  SwPtrMsgPoolItem aAskItem( RES_CONTENT_VISIBLE, nullptr );
525  if(m_pMember && pbLevelOrVisibilityChanged)
526  {
527  pOldMember = std::move(m_pMember);
528  nOldMemberCount = pOldMember->size();
529  m_pMember.reset( new SwContentArr );
530  *pbLevelOrVisibilityChanged = false;
531  }
532  else if(!m_pMember)
533  m_pMember.reset( new SwContentArr );
534  else
535  m_pMember->clear();
536  switch(m_nContentType)
537  {
539  {
540  const size_t nOutlineCount = m_nMemberCount =
542 
543  size_t nPos = 0;
544  for (size_t i = 0; i < nOutlineCount; ++i)
545  {
547  if(nLevel >= m_nOutlineLevel )
548  m_nMemberCount--;
549  else
550  {
552  {
553  --m_nMemberCount;
554  continue; // don't hide it, just skip it
555  }
556  OUString aEntry(comphelper::string::stripStart(
558  aEntry = SwNavigationPI::CleanEntry(aEntry);
559  std::unique_ptr<SwOutlineContent> pCnt(new SwOutlineContent(this, aEntry, i, nLevel,
560  m_pWrtShell->IsOutlineMovable( i ), nPos ));
561  m_pMember->insert(std::move(pCnt));
562  // with the same number and existing "pOldMember" the
563  // old one is compared with the new OutlinePos.
564  if (nOldMemberCount > nPos && static_cast<SwOutlineContent*>((*pOldMember)[nPos].get())->GetOutlineLevel() != nLevel)
565  *pbLevelOrVisibilityChanged = true;
566 
567  nPos++;
568  }
569  }
570 
571  }
572  break;
573 
574  case ContentTypeId::TABLE :
575  {
576  const size_t nCount = m_pWrtShell->GetTableFrameFormatCount(true);
577  OSL_ENSURE(m_nMemberCount == nCount, "MemberCount differs");
578  Point aNullPt;
579  m_nMemberCount = nCount;
580  for(size_t i = 0; i < m_nMemberCount; ++i)
581  {
582  const SwFrameFormat& rTableFormat = m_pWrtShell->GetTableFrameFormat(i, true);
583  const OUString& sTableName( rTableFormat.GetName() );
584 
585  SwContent* pCnt = new SwContent(this, sTableName,
586  rTableFormat.FindLayoutRect(false, &aNullPt).Top() );
587  if( !rTableFormat.GetInfo( aAskItem ) &&
588  !aAskItem.pObject ) // not visible
589  pCnt->SetInvisible();
590 
591  m_pMember->insert(std::unique_ptr<SwContent>(pCnt));
592 
593  if(nOldMemberCount > i &&
594  (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible())
595  *pbLevelOrVisibilityChanged = true;
596  }
597  }
598  break;
599  case ContentTypeId::OLE :
600  case ContentTypeId::FRAME :
602  {
605  eType = FLYCNTTYPE_OLE;
607  eType = FLYCNTTYPE_GRF;
608  Point aNullPt;
609  m_nMemberCount = m_pWrtShell->GetFlyCount(eType, /*bIgnoreTextBoxes=*/true);
610  std::vector<SwFrameFormat const*> formats(m_pWrtShell->GetFlyFrameFormats(eType, /*bIgnoreTextBoxes=*/true));
611  SAL_WARN_IF(m_nMemberCount != formats.size(), "sw.ui", "MemberCount differs");
612  m_nMemberCount = formats.size();
613  for (size_t i = 0; i < m_nMemberCount; ++i)
614  {
615  SwFrameFormat const*const pFrameFormat = formats[i];
616  const OUString sFrameName = pFrameFormat->GetName();
617 
618  SwContent* pCnt;
620  {
621  OUString sLink;
622  m_pWrtShell->GetGrfNms( &sLink, nullptr, static_cast<const SwFlyFrameFormat*>( pFrameFormat));
623  pCnt = new SwGraphicContent(this, sFrameName,
624  INetURLObject::decode( sLink,
626  pFrameFormat->FindLayoutRect(false, &aNullPt).Top());
627  }
628  else
629  {
630  pCnt = new SwContent(this, sFrameName,
631  pFrameFormat->FindLayoutRect(false, &aNullPt).Top() );
632  }
633  if( !pFrameFormat->GetInfo( aAskItem ) &&
634  !aAskItem.pObject ) // not visible
635  pCnt->SetInvisible();
636  m_pMember->insert(std::unique_ptr<SwContent>(pCnt));
637  if (nOldMemberCount > i &&
638  (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible())
639  *pbLevelOrVisibilityChanged = true;
640  }
641  }
642  break;
644  {
646  for(IDocumentMarkAccess::const_iterator_t ppBookmark = pMarkAccess->getBookmarksBegin();
647  ppBookmark != pMarkAccess->getBookmarksEnd();
648  ++ppBookmark)
649  {
650  if(lcl_IsUiVisibleBookmark(*ppBookmark))
651  {
652  const OUString& rBkmName = ppBookmark->get()->GetName();
653  //nYPos from 0 -> text::Bookmarks will be sorted alphabetically
654  std::unique_ptr<SwContent> pCnt(new SwContent(this, rBkmName, 0));
655  m_pMember->insert(std::move(pCnt));
656  }
657  }
658  }
659  break;
660  case ContentTypeId::REGION :
661  {
662  const Point aNullPt;
664  for(size_t i = 0; i < m_nMemberCount; ++i)
665  {
666  const SwSectionFormat* pFormat;
667  SectionType eTmpType;
668  if( (pFormat = &m_pWrtShell->GetSectionFormat(i))->IsInNodesArr() &&
669  (eTmpType = pFormat->GetSection()->GetType()) != TOX_CONTENT_SECTION
670  && TOX_HEADER_SECTION != eTmpType )
671  {
672  OUString sSectionName = pFormat->GetSection()->GetSectionName();
673 
674  sal_uInt8 nLevel = 0;
675  SwSectionFormat* pParentFormat = pFormat->GetParent();
676  while(pParentFormat)
677  {
678  nLevel++;
679  pParentFormat = pParentFormat->GetParent();
680  }
681 
682  std::unique_ptr<SwContent> pCnt(new SwRegionContent(this, sSectionName,
683  nLevel,
684  pFormat->FindLayoutRect( false, &aNullPt ).Top()));
685  if( !pFormat->GetInfo( aAskItem ) &&
686  !aAskItem.pObject ) // not visible
687  pCnt->SetInvisible();
688  m_pMember->insert(std::move(pCnt));
689  }
690 
691  if(nullptr != pbLevelOrVisibilityChanged)
692  {
693  assert(pOldMember);
694  // need to check visibility (and equal entry number) after
695  // creation due to a sorted list being used here (before,
696  // entries with same index were compared already at creation
697  // time what worked before a sorted list was used)
698  *pbLevelOrVisibilityChanged = checkVisibilityChanged(
699  *pOldMember,
700  *m_pMember);
701  }
702  }
703  m_nMemberCount = m_pMember->size();
704  }
705  break;
707  {
708  std::vector<OUString> aRefMarks;
709  m_nMemberCount = m_pWrtShell->GetRefMarks( &aRefMarks );
710 
711  for (const auto& rRefMark : aRefMarks)
712  {
713  // References sorted alphabetically
714  m_pMember->insert(std::make_unique<SwContent>(this, rRefMark, 0));
715  }
716  }
717  break;
719  m_nMemberCount = lcl_InsertURLFieldContent(m_pMember.get(), m_pWrtShell, this);
720  break;
722  {
723 
724  const sal_uInt16 nCount = m_pWrtShell->GetTOXCount();
725  m_nMemberCount = nCount;
726  for ( sal_uInt16 nTox = 0; nTox < nCount; nTox++ )
727  {
728  const SwTOXBase* pBase = m_pWrtShell->GetTOX( nTox );
729  OUString sTOXNm( pBase->GetTOXName() );
730 
731  SwContent* pCnt = new SwTOXBaseContent(
732  this, sTOXNm, nTox, *pBase);
733 
734  if( !pBase->GetInfo( aAskItem ) &&
735  !aAskItem.pObject ) // not visible
736  pCnt->SetInvisible();
737 
738  m_pMember->insert( std::unique_ptr<SwContent>(pCnt) );
739  const size_t nPos = m_pMember->size() - 1;
740  if(nOldMemberCount > nPos &&
741  (*pOldMember)[nPos]->IsInvisible()
742  != pCnt->IsInvisible())
743  *pbLevelOrVisibilityChanged = true;
744  }
745  }
746  break;
748  {
749  m_nMemberCount = 0;
750  m_pMember->clear();
752  if (aMgr)
753  {
754  for(SwPostItMgr::const_iterator i = aMgr->begin(); i != aMgr->end(); ++i)
755  {
756  if (const SwFormatField* pFormatField = dynamic_cast<const SwFormatField *>((*i)->GetBroadcaster())) // SwPostit
757  {
758  if (pFormatField->GetTextField() && pFormatField->IsFieldInDoc() &&
759  (*i)->mLayoutStatus!=SwPostItHelper::INVISIBLE )
760  {
761  OUString sEntry = pFormatField->GetField()->GetPar2();
762  sEntry = RemoveNewline(sEntry);
763  std::unique_ptr<SwPostItContent> pCnt(new SwPostItContent(
764  this,
765  sEntry,
766  pFormatField,
767  m_nMemberCount));
768  m_pMember->insert(std::move(pCnt));
769  m_nMemberCount++;
770  }
771  }
772  }
773  }
774  }
775  break;
777  {
778  m_nMemberCount = 0;
779  m_pMember->clear();
780 
782  SwDrawModel* pModel = rIDDMA.GetDrawModel();
783  if(pModel)
784  {
785  SdrPage* pPage = pModel->GetPage(0);
786  const size_t nCount = pPage->GetObjCount();
787  for( size_t i=0; i<nCount; ++i )
788  {
789  SdrObject* pTemp = pPage->GetObj(i);
790  // #i51726# - all drawing objects can be named now
791  if (!pTemp->GetName().isEmpty())
792  {
793  SwContact* pContact = static_cast<SwContact*>(pTemp->GetUserCall());
794  long nYPos = 0;
795  const Point aNullPt;
796  if(pContact && pContact->GetFormat())
797  nYPos = pContact->GetFormat()->FindLayoutRect(false, &aNullPt).Top();
798  SwContent* pCnt = new SwContent(
799  this,
800  pTemp->GetName(),
801  nYPos);
802  if(!rIDDMA.IsVisibleLayerId(pTemp->GetLayer()))
803  pCnt->SetInvisible();
804  m_pMember->insert(std::unique_ptr<SwContent>(pCnt));
805  m_nMemberCount++;
806  if (nOldMemberCount > i &&
807  (*pOldMember)[i]->IsInvisible() != pCnt->IsInvisible() )
808  *pbLevelOrVisibilityChanged = true;
809  }
810  }
811  }
812  }
813  break;
814  default: break;
815  }
816  m_bDataValid = true;
817 }
818 
820 {
834 };
835 
836 static const char* STR_CONTEXT_ARY[] =
837 {
838  STR_OUTLINE_LEVEL,
839  STR_DRAGMODE,
840  STR_HYPERLINK,
841  STR_LINK_REGION,
842  STR_COPY_REGION,
843  STR_DISPLAY,
844  STR_ACTIVE_VIEW,
845  STR_HIDDEN,
846  STR_ACTIVE,
847  STR_INACTIVE,
848  STR_EDIT_ENTRY,
849  STR_DELETE_ENTRY,
850  STR_SEND_OUTLINE_TO_CLIPBOARD_ENTRY
851 };
852 
854  : SvTreeListBox(pParent)
855  , m_xDialog(pDialog)
856  , m_sSpace(OUString(" "))
857  , m_sRemoveIdx(SwResId(STR_REMOVE_INDEX))
858  , m_sUpdateIdx(SwResId(STR_UPDATE))
859  , m_sUnprotTable(SwResId(STR_REMOVE_TBL_PROTECTION))
860  , m_sRename(SwResId(STR_RENAME))
861  , m_sReadonlyIdx(SwResId(STR_READONLY_IDX))
862  , m_sInvisible(SwResId(STR_INVISIBLE))
863  , m_sPostItShow(SwResId(STR_POSTIT_SHOW))
864  , m_sPostItHide(SwResId(STR_POSTIT_HIDE))
865  , m_sPostItDelete(SwResId(STR_POSTIT_DELETE))
866  , m_pHiddenShell(nullptr)
867  , m_pActiveShell(nullptr)
868  , m_pConfig(SW_MOD()->GetNavigationConfig())
869  , m_nActiveBlock(0)
870  , m_nHiddenBlock(0)
871  , m_nRootType(ContentTypeId::UNKNOWN)
872  , m_nLastSelType(ContentTypeId::UNKNOWN)
873  , m_nOutlineLevel(MAXLEVEL)
874  , m_eState(State::ACTIVE)
875  , m_bDocChgdInDragging(false)
876  , m_bIsInternalDrag(false)
877  , m_bIsRoot(false)
878  , m_bIsIdleClear(false)
879  , m_bIsLastReadOnly(false)
880  , m_bIsOutlineMoveable(true)
881  , m_bViewHasChanged(false)
882  , m_bIsKeySpace(false)
883 {
885 
887  SetDoubleClickHdl(LINK(this, SwContentTree, ContentDoubleClickHdl));
888  SetDragDropMode(DragDropMode::APP_COPY);
890  {
891  m_aActiveContentArr[i] = nullptr;
892  m_aHiddenContentArr[i] = nullptr;
893  }
894  for (int i = 0; i < CONTEXT_COUNT; ++i)
895  {
896  m_aContextStrings[i] = SwResId(STR_CONTEXT_ARY[i]);
897  }
899  m_aUpdTimer.SetInvokeHandler(LINK(this, SwContentTree, TimerUpdate));
900  m_aUpdTimer.SetTimeout(1000);
901  Clear();
903  SetQuickSearch(true);
904 }
905 
907 {
908  disposeOnce();
909 }
910 
912 {
913  Clear(); // If applicable erase content types previously.
914  bIsInDrag = false;
915  m_aUpdTimer.Stop();
916  SetActiveShell(nullptr);
917  m_xDialog.clear();
919 }
920 
922 {
923  return LogicToPixel(Size(110, 112), MapMode(MapUnit::MapAppFont));
924 }
925 
927 {
928  if (pEntry == nullptr || !lcl_IsContent(pEntry))
929  return OUString();
930 
931  assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
932  SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
933  if( pCnt == nullptr || pCnt->GetParent() == nullptr)
934  return OUString();
935 
936  ContentTypeId nJumpType = pCnt->GetParent()->GetType();
937  SdrObject* pTemp;
938 
939  switch(nJumpType)
940  {
942  {
943  SdrView* pDrawView = m_pActiveShell->GetDrawView();
944  if (pDrawView)
945  {
947  SdrPage* pPage = pDrawModel->GetPage(0);
948  const size_t nCount = pPage->GetObjCount();
949  for( size_t i=0; i<nCount; ++i )
950  {
951  pTemp = pPage->GetObj(i);
952  sal_uInt16 nCmpId;
953  switch( pTemp->GetObjIdentifier() )
954  {
955  case OBJ_GRUP:
956  case OBJ_TEXT:
957  case OBJ_LINE:
958  case OBJ_RECT:
959  case OBJ_CUSTOMSHAPE:
960  case OBJ_CIRC:
961  case OBJ_SECT:
962  case OBJ_CARC:
963  case OBJ_CCUT:
964  case OBJ_POLY:
965  case OBJ_PLIN:
966  case OBJ_PATHLINE:
967  case OBJ_PATHFILL:
968  case OBJ_FREELINE:
969  case OBJ_FREEFILL:
970  case OBJ_PATHPOLY:
971  case OBJ_PATHPLIN:
972  case OBJ_CAPTION:
973  nCmpId = OBJ_GRUP;
974  break;
975  default:
976  nCmpId = pTemp->GetObjIdentifier();
977  }
978  if(nCmpId == OBJ_GRUP && pTemp->GetName() == pCnt->GetName())
979  {
980  return pTemp->GetTitle();
981  }
982  }
983  }
984  }
985  break;
987  {
989  {
990  const SwFlyFrameFormat* pFrameFormat = m_pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName());
991  if( pFrameFormat )
992  return pFrameFormat->GetObjTitle();
993  }
994  }
995  break;
996  case ContentTypeId::OLE :
997  case ContentTypeId::FRAME :
998  {
999  //Can't find the GetAlternateText function. Need to verify again.
1000  const SwFlyFrameFormat* pFlyFormat = m_pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName());
1001  if( pFlyFormat )
1002  return pFlyFormat->/*GetAlternateText*/GetName();
1003  }
1004  break;
1005  default: break;
1006  }
1007  return OUString();
1008 }
1009 
1011 {
1012  if( pEntry == nullptr)
1013  return OUString();
1014 
1015  assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1016  SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
1017  if( pCnt == nullptr || pCnt->GetParent() == nullptr)
1018  return OUString();
1019 
1020  SdrObject* pTemp;
1021 
1022  switch(pCnt->GetParent()->GetType())
1023  {
1025  {
1026  SdrView* pDrawView = m_pActiveShell->GetDrawView();
1027  if (pDrawView)
1028  {
1030  SdrPage* pPage = pDrawModel->GetPage(0);
1031  const size_t nCount = pPage->GetObjCount();
1032  for( size_t i=0; i<nCount; ++i )
1033  {
1034  pTemp = pPage->GetObj(i);
1035  sal_uInt16 nCmpId;
1036  switch( pTemp->GetObjIdentifier() )
1037  {
1038  case OBJ_GRUP:
1039  case OBJ_TEXT:
1040  case OBJ_LINE:
1041  case OBJ_RECT:
1042  case OBJ_CUSTOMSHAPE:
1043  case OBJ_CIRC:
1044  case OBJ_SECT:
1045  case OBJ_CARC:
1046  case OBJ_CCUT:
1047  case OBJ_POLY:
1048  case OBJ_PLIN:
1049  case OBJ_PATHLINE:
1050  case OBJ_PATHFILL:
1051  case OBJ_FREELINE:
1052  case OBJ_FREEFILL:
1053  case OBJ_PATHPOLY:
1054  case OBJ_PATHPLIN:
1055  case OBJ_CAPTION:
1056  nCmpId = OBJ_GRUP;
1057  break;
1058  default:
1059  nCmpId = pTemp->GetObjIdentifier();
1060  }
1061  if(nCmpId == OBJ_GRUP /*dynamic_cast< const SdrObjGroup *>( pTemp ) != nullptr*/ && pTemp->GetName() == pCnt->GetName())
1062  {
1063  return pTemp->GetDescription();
1064  }
1065  }
1066  }
1067  }
1068  break;
1069  case ContentTypeId::GRAPHIC :
1070  case ContentTypeId::OLE :
1071  case ContentTypeId::FRAME :
1072  {
1073  //Can't find the function "GetLongDescription". Need to verify again.
1074  const SwFlyFrameFormat* pFlyFormat = m_pActiveShell->GetDoc()->FindFlyByName( pCnt->GetName());
1075  if( pFlyFormat )
1076  return pFlyFormat->GetDescription();
1077  }
1078  break;
1079  default: break;
1080  }
1081  return OUString();
1082 }
1083 
1084 // Drag&Drop methods
1085 
1086 void SwContentTree::StartDrag( sal_Int8 nAction, const Point& rPosPixel )
1087 {
1089  {
1090  ReleaseMouse();
1091 
1093 
1095  if( FillTransferData( *pContainer, nDragMode ))
1096  {
1098  pContainer->StartDrag( this, nDragMode, GetDragFinishedHdl() );
1099  }
1100  }
1101  else
1102  SvTreeListBox::StartDrag( nAction, rPosPixel );
1103 }
1104 
1106 {
1107  // To prevent the removing of the selected entry in external drag and drop
1108  // the drag action mustn't be MOVE.
1110  SwContentTree::SetInDrag(false);
1111  m_bIsInternalDrag = false;
1112 }
1113 
1114 // QueryDrop will be executed in the navigator
1115 
1117 {
1118  sal_Int8 nRet = DND_ACTION_NONE;
1119  if( m_bIsRoot )
1120  {
1121  if( m_bIsOutlineMoveable )
1122  nRet = SvTreeListBox::AcceptDrop( rEvt );
1123  }
1124  else if( !bIsInDrag )
1125  nRet = GetParentWindow()->AcceptDrop();
1126  return nRet;
1127 }
1128 
1129 // Drop will be executed in the navigator
1130 
1131 static void* lcl_GetOutlineKey( SwContentTree* pTree, SwOutlineContent const * pContent)
1132 {
1133  void* key = nullptr;
1134  if( pTree && pContent )
1135  {
1136  SwWrtShell* pShell = pTree->GetWrtShell();
1137  auto const nPos = pContent->GetOutlinePos();
1138 
1139  key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ));
1140  }
1141  return key;
1142 }
1143 
1145 {
1146  SvTreeListEntry* pEntry = pTargetEntry;
1147  if( pEntry && ( m_nRootType == ContentTypeId::OUTLINE ) && lcl_IsContent( pEntry ) )
1148  {
1149  assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1150  SwOutlineContent* pOutlineContent = static_cast<SwOutlineContent*>(pEntry->GetUserData());
1151  if( pOutlineContent )
1152  {
1153  void* key = lcl_GetOutlineKey(this, pOutlineContent);
1154  if( !mOutLineNodeMap[key] )
1155  {
1156  while( pEntry->HasChildren() )
1157  {
1158  SvTreeListEntry* pChildEntry = FirstChild( pEntry );
1159  while( pChildEntry )
1160  {
1161  pEntry = pChildEntry;
1162  pChildEntry = pChildEntry->NextSibling();
1163  }
1164  }
1165  pTargetEntry = pEntry;
1166  }
1167  }
1168  }
1169  if( m_bIsRoot )
1170  return SvTreeListBox::ExecuteDrop( rEvt );
1172 }
1173 
1174 // Handler for Dragging and ContextMenu
1175 
1177 {
1178  auto pPop = VclPtr<PopupMenu>::Create();
1179  VclPtrInstance<PopupMenu> pSubPop1;
1180  VclPtrInstance<PopupMenu> pSubPop2;
1181  VclPtrInstance<PopupMenu> pSubPop3;
1182  VclPtrInstance<PopupMenu> pSubPop4; // Edit
1183  bool bSubPop4 = false;
1184 
1185  for(int i = 1; i <= MAXLEVEL; ++i)
1186  {
1187  pSubPop1->InsertItem(i + 100, OUString::number(i), MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
1188  }
1189  pSubPop1->CheckItem(100 + m_nOutlineLevel);
1190  for(int i=0; i < 3; ++i)
1191  {
1192  pSubPop2->InsertItem(i + 201, m_aContextStrings[
1193  IDX_STR_HYPERLINK + i], MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
1194  }
1195  pSubPop2->CheckItem(201 + static_cast<int>(GetParentWindow()->GetRegionDropMode()));
1196  // Insert the list of the open files
1197  sal_uInt16 nId = 301;
1198  const SwView* pActiveView = ::GetActiveView();
1199  SwView *pView = SwModule::GetFirstView();
1200  while (pView)
1201  {
1202  OUString sInsert = pView->GetDocShell()->GetTitle();
1203  if(pView == pActiveView)
1204  {
1205  sInsert += "(";
1206  sInsert += m_aContextStrings[IDX_STR_ACTIVE];
1207  sInsert += ")";
1208  }
1209  pSubPop3->InsertItem(nId, sInsert, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
1210  if (State::CONSTANT == m_eState && m_pActiveShell == &pView->GetWrtShell())
1211  pSubPop3->CheckItem(nId);
1212  pView = SwModule::GetNextView(pView);
1213  nId++;
1214  }
1215  pSubPop3->InsertItem(nId++, m_aContextStrings[IDX_STR_ACTIVE_VIEW], MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
1216  if(m_pHiddenShell)
1217  {
1218  OUString sHiddenEntry = m_pHiddenShell->GetView().GetDocShell()->GetTitle();
1219  sHiddenEntry += " ( ";
1220  sHiddenEntry += m_aContextStrings[IDX_STR_HIDDEN];
1221  sHiddenEntry += " )";
1222  pSubPop3->InsertItem(nId, sHiddenEntry, MenuItemBits::AUTOCHECK | MenuItemBits::RADIOCHECK);
1223  }
1224 
1225  if (State::ACTIVE == m_eState)
1226  pSubPop3->CheckItem( --nId );
1227  else if (State::HIDDEN == m_eState)
1228  pSubPop3->CheckItem( nId );
1229 
1230  pPop->InsertItem( 1, m_aContextStrings[IDX_STR_OUTLINE_LEVEL]);
1231  pPop->InsertItem(2, m_aContextStrings[IDX_STR_DRAGMODE]);
1232  pPop->InsertItem(3, m_aContextStrings[IDX_STR_DISPLAY]);
1233  // Now edit
1234  SvTreeListEntry* pEntry = nullptr;
1235  // Edit only if the shown content is coming from the current view.
1236  if ((State::ACTIVE == m_eState || m_pActiveShell == pActiveView->GetWrtShellPtr())
1237  && nullptr != (pEntry = FirstSelected()) && lcl_IsContent(pEntry))
1238  {
1239  assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1240  const SwContentType* pContType = static_cast<SwContent*>(pEntry->GetUserData())->GetParent();
1241  const ContentTypeId nContentType = pContType->GetType();
1242  bool bReadonly = m_pActiveShell->GetView().GetDocShell()->IsReadOnly();
1243  bool bVisible = !static_cast<SwContent*>(pEntry->GetUserData())->IsInvisible();
1244  bool bProtected = static_cast<SwContent*>(pEntry->GetUserData())->IsProtect();
1245  bool bEditable = pContType->IsEditable() &&
1246  ((bVisible && !bProtected) ||ContentTypeId::REGION == nContentType);
1247  bool bDeletable = pContType->IsDeletable() &&
1248  ((bVisible && !bProtected) ||ContentTypeId::REGION == nContentType);
1249  bool bRenamable = bEditable && !bReadonly &&
1250  (ContentTypeId::TABLE == nContentType ||
1251  ContentTypeId::FRAME == nContentType ||
1252  ContentTypeId::GRAPHIC == nContentType ||
1253  ContentTypeId::OLE == nContentType ||
1254  ContentTypeId::BOOKMARK == nContentType ||
1255  ContentTypeId::REGION == nContentType||
1256  ContentTypeId::INDEX == nContentType);
1257 
1258  if(!bReadonly && (bEditable || bDeletable))
1259  {
1260  if(ContentTypeId::INDEX == nContentType)
1261  {
1262  bSubPop4 = true;
1263  pSubPop4->InsertItem(401, m_sRemoveIdx);
1264  pSubPop4->InsertItem(402, m_sUpdateIdx);
1265 
1266  const SwTOXBase* pBase = static_cast<SwTOXBaseContent*>(pEntry->GetUserData())->GetTOXBase();
1267  if(!pBase->IsTOXBaseInReadonly())
1269  pSubPop4->InsertItem(405, m_sReadonlyIdx);
1270 
1271  pSubPop4->CheckItem( 405, SwEditShell::IsTOXBaseReadonly(*pBase));
1273  }
1274  else if(ContentTypeId::TABLE == nContentType)
1275  {
1276  bSubPop4 = true;
1278  pSubPop4->InsertItem(404, m_sUnprotTable);
1279  bool bFull = false;
1280  OUString sTableName = static_cast<SwContent*>(pEntry->GetUserData())->GetName();
1281  bool bProt = m_pActiveShell->HasTableAnyProtection( &sTableName, &bFull );
1282  pSubPop4->EnableItem(403, !bFull );
1283  pSubPop4->EnableItem(404, bProt );
1285  }
1286  else
1287  {
1288 
1289  if(bEditable && bDeletable)
1290  {
1293  bSubPop4 = true;
1294  }
1295  else if(bEditable)
1296  pPop->InsertItem(403, m_aContextStrings[IDX_STR_EDIT_ENTRY]);
1297  else if(bDeletable)
1298  {
1300  }
1301  }
1302  //Rename object
1303  if(bRenamable)
1304  {
1305  if(bSubPop4)
1306  pSubPop4->InsertItem(502, m_sRename);
1307  else
1308  pPop->InsertItem(502, m_sRename);
1309  }
1310 
1311  if(bSubPop4)
1312  {
1313  pPop->InsertItem(4, pContType->GetSingleName());
1314  pPop->SetPopupMenu(4, pSubPop4);
1315  }
1316  }
1317  }
1318  else if( pEntry )
1319  {
1320  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1321  SwContentType* pType = static_cast<SwContentType*>(pEntry->GetUserData());
1322  if(ContentTypeId::OUTLINE == pType->GetType())
1323  {
1324  pPop->InsertSeparator();
1326  }
1327  if ( (pType->GetType() == ContentTypeId::POSTIT) && (!m_pActiveShell->GetView().GetDocShell()->IsReadOnly()) && ( pType->GetMemberCount() > 0) )
1328  {
1329  bSubPop4 = true;
1330  pSubPop4->InsertItem(600, m_sPostItShow );
1331  pSubPop4->InsertItem(601, m_sPostItHide );
1332  pSubPop4->InsertItem(602, m_sPostItDelete );
1333  pPop->InsertItem(4, pType->GetSingleName());
1334  pPop->SetPopupMenu(4, pSubPop4);
1335  }
1336  }
1337 
1338  pPop->SetPopupMenu( 1, pSubPop1 );
1339  pPop->SetPopupMenu( 2, pSubPop2 );
1340  pPop->SetPopupMenu( 3, pSubPop3 );
1341  if (!bSubPop4)
1342  pSubPop4.disposeAndClear();
1343  return pPop;
1344 }
1345 
1346 // Indentation for outlines (and sections)
1347 
1349 {
1350  sal_IntPtr nLevel = 0;
1351  if(lcl_IsContent(pEntry))
1352  {
1353  nLevel++;
1354  assert(pEntry->GetUserData() == nullptr || dynamic_cast<SwContent *>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1355  SwContent* pCnt = static_cast<SwContent *>(pEntry->GetUserData());
1356  const SwContentType* pParent;
1357  if(pCnt && nullptr != (pParent = pCnt->GetParent()))
1358  {
1359  if(pParent->GetType() == ContentTypeId::OUTLINE)
1360  nLevel = nLevel + static_cast<SwOutlineContent*>(pCnt)->GetOutlineLevel();
1361  else if(pParent->GetType() == ContentTypeId::REGION)
1362  nLevel = nLevel + static_cast<SwRegionContent*>(pCnt)->GetRegionLevel();
1363  }
1364  }
1365  return nLevel * 10 + (m_bIsRoot ? 0 : 5) + pTab->GetPos(); //determined empirically
1366 }
1367 
1368 // Content will be integrated into the Box only on demand.
1369 
1371 {
1372  // Is this a content type?
1373  if(lcl_IsContentType(pParent))
1374  {
1375  if(!pParent->HasChildren())
1376  {
1377  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pParent->GetUserData())));
1378  SwContentType* pCntType = static_cast<SwContentType*>(pParent->GetUserData());
1379 
1380  const size_t nCount = pCntType->GetMemberCount();
1381  // Add for outline plus/minus
1382  if(pCntType->GetType() == ContentTypeId::OUTLINE)
1383  {
1384  SvTreeListEntry* pChild = nullptr;
1385  for(size_t i = 0; i < nCount; ++i)
1386  {
1387  const SwContent* pCnt = pCntType->GetMember(i);
1388  if(pCnt)
1389  {
1390  const auto nLevel = static_cast<const SwOutlineContent*>(pCnt)->GetOutlineLevel();
1391  OUString sEntry = pCnt->GetName();
1392  if(sEntry.isEmpty())
1393  sEntry = m_sSpace;
1394  if(!pChild || (nLevel == 0))
1395  pChild = InsertEntry(sEntry, pParent, false, TREELIST_APPEND,const_cast<SwContent *>(pCnt));
1396  else
1397  {
1398  //back search parent.
1399  if(static_cast<const SwOutlineContent*>(pCntType->GetMember(i-1))->GetOutlineLevel() < nLevel)
1400  pChild = InsertEntry(sEntry, pChild, false, TREELIST_APPEND, const_cast<SwContent *>(pCnt));
1401  else
1402  {
1403  pChild = Prev(pChild);
1404  assert(!pChild || lcl_IsContentType(pChild) || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pChild->GetUserData())));
1405  while(pChild &&
1406  lcl_IsContent(pChild) &&
1407  (static_cast<SwOutlineContent*>(pChild->GetUserData())->GetOutlineLevel() >= nLevel)
1408  )
1409  {
1410  pChild = Prev(pChild);
1411  }
1412  if(pChild)
1413  pChild = InsertEntry(sEntry, pChild,
1414  false, TREELIST_APPEND, const_cast<SwContent *>(pCnt));
1415  }
1416  }
1417  }
1418  }
1419  }
1420  else
1421  {
1422  for(size_t i = 0; i < nCount; ++i)
1423  {
1424  const SwContent* pCnt = pCntType->GetMember(i);
1425  if (pCnt)
1426  {
1427  OUString sEntry = pCnt->GetName();
1428  if (sEntry.isEmpty())
1429  sEntry = m_sSpace;
1430  InsertEntry(sEntry, pParent, false, TREELIST_APPEND, const_cast<SwContent *>(pCnt));
1431  }
1432  }
1433  }
1434  }
1435  }
1436 }
1437 
1439 {
1440  SdrObject *pRetObj = nullptr;
1441  switch(pCnt->GetParent()->GetType())
1442  {
1444  {
1445  SdrView* pDrawView = m_pActiveShell->GetDrawView();
1446  if (pDrawView)
1447  {
1449  SdrPage* pPage = pDrawModel->GetPage(0);
1450  const size_t nCount = pPage->GetObjCount();
1451 
1452  for( size_t i=0; i<nCount; ++i )
1453  {
1454  SdrObject* pTemp = pPage->GetObj(i);
1455  if( pTemp->GetName() == pCnt->GetName())
1456  {
1457  pRetObj = pTemp;
1458  break;
1459  }
1460  }
1461  }
1462  break;
1463  }
1464  default:
1465  pRetObj = nullptr;
1466  }
1467  return pRetObj;
1468 }
1469 
1471 {
1472  if (!m_bIsRoot
1473  || (lcl_IsContentType(pParent) && static_cast<SwContentType*>(pParent->GetUserData())->GetType() == ContentTypeId::OUTLINE)
1475  {
1476  if(lcl_IsContentType(pParent))
1477  {
1478  SwContentType* pCntType = static_cast<SwContentType*>(pParent->GetUserData());
1479  const sal_Int32 nOr = 1 << static_cast<int>(pCntType->GetType()); //linear -> Bitposition
1480  if (State::HIDDEN != m_eState)
1481  {
1482  m_nActiveBlock |= nOr;
1484  }
1485  else
1486  m_nHiddenBlock |= nOr;
1487  if(pCntType->GetType() == ContentTypeId::OUTLINE)
1488  {
1489  std::map< void*, bool > aCurrOutLineNodeMap;
1490 
1491  SwWrtShell* pShell = GetWrtShell();
1492  bool bBool = SvTreeListBox::Expand(pParent);
1493  SvTreeListEntry* pChild = Next(pParent);
1494  while(pChild && lcl_IsContent(pChild) && pParent->HasChildren())
1495  {
1496  if(pChild->HasChildren())
1497  {
1498  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pChild->GetUserData())));
1499  auto const nPos = static_cast<SwOutlineContent*>(pChild->GetUserData())->GetOutlinePos();
1500  void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ));
1501  aCurrOutLineNodeMap.emplace( key, false );
1502  std::map<void*, bool>::iterator iter = mOutLineNodeMap.find( key );
1503  if( iter != mOutLineNodeMap.end() && mOutLineNodeMap[key])
1504  {
1505  aCurrOutLineNodeMap[key] = true;
1506  SvTreeListBox::Expand(pChild);
1507  }
1508  }
1509  pChild = Next(pChild);
1510  }
1511  mOutLineNodeMap = aCurrOutLineNodeMap;
1512  return bBool;
1513  }
1514 
1515  }
1516  else if( lcl_IsContent(pParent) )
1517  {
1518  SwWrtShell* pShell = GetWrtShell();
1519  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pParent->GetUserData())));
1520  auto const nPos = static_cast<SwOutlineContent*>(pParent->GetUserData())->GetOutlinePos();
1521  void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ));
1522  mOutLineNodeMap[key] = true;
1523  }
1524  }
1525  return SvTreeListBox::Expand(pParent);
1526 }
1527 
1529 {
1530  if (!m_bIsRoot
1531  || (lcl_IsContentType(pParent) && static_cast<SwContentType*>(pParent->GetUserData())->GetType() == ContentTypeId::OUTLINE)
1533  {
1534  if(lcl_IsContentType(pParent))
1535  {
1536  if(m_bIsRoot)
1537  return false;
1538  SwContentType* pCntType = static_cast<SwContentType*>(pParent->GetUserData());
1539  const sal_Int32 nAnd = ~(1 << static_cast<int>(pCntType->GetType()));
1540  if (State::HIDDEN != m_eState)
1541  {
1542  m_nActiveBlock &= nAnd;
1544  }
1545  else
1546  m_nHiddenBlock &= nAnd;
1547  }
1548  else if( lcl_IsContent(pParent) )
1549  {
1550  SwWrtShell* pShell = GetWrtShell();
1551  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pParent->GetUserData())));
1552  auto const nPos = static_cast<SwOutlineContent*>(pParent->GetUserData())->GetOutlinePos();
1553  void* key = static_cast<void*>(pShell->getIDocumentOutlineNodesAccess()->getOutlineNode( nPos ));
1554  mOutLineNodeMap[key] = false;
1555  }
1556  }
1557 
1558  return SvTreeListBox::Collapse(pParent);
1559 }
1560 
1561 // Also on double click will be initially opened only.
1562 
1563 IMPL_LINK_NOARG(SwContentTree, ContentDoubleClickHdl, SvTreeListBox*, bool)
1564 {
1565  SvTreeListEntry* pEntry = GetCurEntry();
1566  // Is it a content type?
1567  OSL_ENSURE(pEntry, "no current entry!");
1568  if(pEntry)
1569  {
1570  if(lcl_IsContentType(pEntry) && !pEntry->HasChildren())
1571  {
1572  RequestingChildren(pEntry);
1573  }
1574  else if (!lcl_IsContentType(pEntry) && (State::HIDDEN != m_eState))
1575  {
1576  if (State::CONSTANT == m_eState)
1577  {
1578  m_pActiveShell->GetView().GetViewFrame()->GetWindow().ToTop();
1579  }
1580  //Jump to content type:
1581  assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1582  SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
1583  OSL_ENSURE( pCnt, "no UserData");
1584  GotoContent(pCnt);
1585  if(pCnt->GetParent()->GetType() == ContentTypeId::FRAME)
1586  m_pActiveShell->EnterStdMode();
1587  return false; // treelist processing finished
1588  }
1589  return true; // signal more to be done, i.e. expand/collapse children
1590  }
1591  return false;
1592 }
1593 
1594 namespace
1595 {
1596  BitmapEx GetBitmapForContentTypeId(ContentTypeId eType)
1597  {
1598  OUString sResId;
1599 
1600  switch (eType)
1601  {
1603  sResId = RID_BMP_NAVI_OUTLINE;
1604  break;
1605  case ContentTypeId::TABLE:
1606  sResId = RID_BMP_NAVI_TABLE;
1607  break;
1608  case ContentTypeId::FRAME:
1609  sResId = RID_BMP_NAVI_FRAME;
1610  break;
1612  sResId = RID_BMP_NAVI_GRAPHIC;
1613  break;
1614  case ContentTypeId::OLE:
1615  sResId = RID_BMP_NAVI_OLE;
1616  break;
1618  sResId = RID_BMP_NAVI_BOOKMARK;
1619  break;
1620  case ContentTypeId::REGION:
1621  sResId = RID_BMP_NAVI_REGION;
1622  break;
1624  sResId = RID_BMP_NAVI_URLFIELD;
1625  break;
1627  sResId = RID_BMP_NAVI_REFERENCE;
1628  break;
1629  case ContentTypeId::INDEX:
1630  sResId = RID_BMP_NAVI_INDEX;
1631  break;
1632  case ContentTypeId::POSTIT:
1633  sResId = RID_BMP_NAVI_POSTIT;
1634  break;
1636  sResId = RID_BMP_NAVI_DRAWOBJECT;
1637  break;
1639  SAL_WARN("sw.ui", "ContentTypeId::UNKNOWN has no bitmap preview");
1640  break;
1641  }
1642 
1643  return BitmapEx(sResId);
1644  };
1645 }
1646 
1647 void SwContentTree::Display( bool bActive )
1648 {
1649  // First read the selected entry to select it later again if necessary
1650  // -> the user data here are no longer valid!
1651  SvTreeListEntry* pOldSelEntry = FirstSelected();
1652  OUString sEntryName; // Name of the entry
1653  sal_uLong nEntryRelPos = 0; // relative position to their parent
1654  sal_uInt32 nOldEntryCount = GetEntryCount();
1655  sal_Int32 nOldScrollPos = 0;
1656  if(pOldSelEntry)
1657  {
1658  ScrollBar* pVScroll = GetVScroll();
1659  if(pVScroll && pVScroll->IsVisible())
1660  nOldScrollPos = pVScroll->GetThumbPos();
1661 
1662  sEntryName = GetEntryText(pOldSelEntry);
1663  SvTreeListEntry* pParantEntry = pOldSelEntry;
1664  while( GetParent(pParantEntry))
1665  {
1666  pParantEntry = GetParent(pParantEntry);
1667  }
1668  if(GetParent(pOldSelEntry))
1669  {
1670  nEntryRelPos = GetModel()->GetAbsPos(pOldSelEntry) - GetModel()->GetAbsPos(pParantEntry);
1671  }
1672  }
1673  Clear();
1674  SetUpdateMode( false );
1675  if (!bActive)
1677  else if (State::HIDDEN == m_eState)
1679  SwWrtShell* pShell = GetWrtShell();
1680  const bool bReadOnly = !pShell || pShell->GetView().GetDocShell()->IsReadOnly();
1681  if(bReadOnly != m_bIsLastReadOnly)
1682  {
1683  m_bIsLastReadOnly = bReadOnly;
1684  bool bDisable = pShell == nullptr || bReadOnly;
1685  SwNavigationPI* pNavi = GetParentWindow();
1686  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("up"), !bDisable);
1687  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("down"), !bDisable);
1688  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("promote"), !bDisable);
1689  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("demote"), !bDisable);
1690  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("reminder"), !bDisable);
1691  }
1692  if(pShell)
1693  {
1694  SvTreeListEntry* pSelEntry = nullptr;
1696  {
1697  for( ContentTypeId nCntType : o3tl::enumrange<ContentTypeId>() )
1698  {
1699  std::unique_ptr<SwContentType>& rpContentT = bActive ?
1700  m_aActiveContentArr[nCntType] :
1701  m_aHiddenContentArr[nCntType];
1702  if(!rpContentT)
1703  rpContentT.reset(new SwContentType(pShell, nCntType, m_nOutlineLevel ));
1704 
1705  OUString sEntry = rpContentT->GetName();
1706  SvTreeListEntry* pEntry;
1707  Image aImage(GetBitmapForContentTypeId(nCntType));
1708  bool bChOnDemand = 0 != rpContentT->GetMemberCount();
1709  pEntry = InsertEntry(sEntry, aImage, aImage,
1710  nullptr, bChOnDemand, TREELIST_APPEND, rpContentT.get());
1711  if(nCntType == m_nLastSelType)
1712  pSelEntry = pEntry;
1713  sal_Int32 nExpandOptions = (State::HIDDEN == m_eState)
1714  ? m_nHiddenBlock
1715  : m_nActiveBlock;
1716  if(nExpandOptions & (1 << static_cast<int>(nCntType)))
1717  {
1718  Expand(pEntry);
1719  if(nEntryRelPos && nCntType == m_nLastSelType)
1720  {
1721  // Now maybe select a additional child
1722  SvTreeListEntry* pChild = pEntry;
1723  SvTreeListEntry* pTemp = nullptr;
1724  sal_uLong nPos = 1;
1725  while(nullptr != (pChild = Next(pChild)))
1726  {
1727  // The old text will be slightly favored
1728  if(sEntryName == GetEntryText(pChild) ||
1729  nPos == nEntryRelPos )
1730  {
1731  pSelEntry = pChild;
1732  break;
1733  }
1734  pTemp = pChild;
1735  nPos++;
1736  }
1737  if(!pSelEntry || lcl_IsContentType(pSelEntry))
1738  pSelEntry = pTemp;
1739  }
1740 
1741  }
1742  }
1743  if(pSelEntry)
1744  {
1745  MakeVisible(pSelEntry);
1746  Select(pSelEntry);
1747  }
1748  else
1749  nOldScrollPos = 0;
1750  }
1751  else
1752  {
1753  std::unique_ptr<SwContentType>& rpRootContentT = bActive ?
1756  if(!rpRootContentT)
1757  rpRootContentT.reset(new SwContentType(pShell, m_nRootType, m_nOutlineLevel ));
1758  Image aImage(GetBitmapForContentTypeId(m_nRootType));
1759  SvTreeListEntry* pParent = InsertEntry(
1760  rpRootContentT->GetName(), aImage, aImage,
1761  nullptr, false, TREELIST_APPEND, rpRootContentT.get());
1762 
1764  {
1765  for(size_t i = 0; i < rpRootContentT->GetMemberCount(); ++i)
1766  {
1767  const SwContent* pCnt = rpRootContentT->GetMember(i);
1768  if(pCnt)
1769  {
1770  OUString sEntry = pCnt->GetName();
1771  if(sEntry.isEmpty())
1772  sEntry = m_sSpace;
1773  InsertEntry( sEntry, pParent,
1774  false, TREELIST_APPEND, const_cast<SwContent *>(pCnt));
1775  }
1776  }
1777  }
1778  else
1779  RequestingChildren(pParent);
1780  Expand(pParent);
1782  {
1783  // find out where the cursor is
1784  const SwOutlineNodes::size_type nActPos = pShell->GetOutlinePos(MAXLEVEL);
1785  SvTreeListEntry* pEntry = First();
1786 
1787  while( nullptr != (pEntry = Next(pEntry)) )
1788  {
1789  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1790  if (static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos() == nActPos)
1791  {
1792  MakeVisible(pEntry);
1793  Select(pEntry);
1794  SetCurEntry(pEntry);
1795  }
1796  }
1797 
1798  }
1799  else
1800  {
1801  // Now maybe select a additional child
1802  SvTreeListEntry* pChild = pParent;
1803  SvTreeListEntry* pTemp = nullptr;
1804  sal_uLong nPos = 1;
1805  while(nullptr != (pChild = Next(pChild)))
1806  {
1807  // The old text will be slightly favored
1808  if(sEntryName == GetEntryText(pChild) ||
1809  nPos == nEntryRelPos )
1810  {
1811  pSelEntry = pChild;
1812  break;
1813  }
1814  pTemp = pChild;
1815  nPos++;
1816  }
1817  if(!pSelEntry)
1818  pSelEntry = pTemp;
1819  if(pSelEntry)
1820  {
1821  MakeVisible(pSelEntry);
1822  Select(pSelEntry);
1823  }
1824  }
1825  }
1826  }
1827  SetUpdateMode( true );
1828  ScrollBar* pVScroll = GetVScroll();
1829  if(GetEntryCount() == nOldEntryCount &&
1830  nOldScrollPos && pVScroll && pVScroll->IsVisible()
1831  && pVScroll->GetThumbPos() != nOldScrollPos)
1832  {
1833  sal_Int32 nDelta = pVScroll->GetThumbPos() - nOldScrollPos;
1834  ScrollOutputArea( static_cast<short>(nDelta) );
1835  }
1836 }
1837 
1839 {
1840  SetUpdateMode(false);
1842  SetUpdateMode(true);
1843 }
1844 
1846  sal_Int8& rDragMode )
1847 {
1848  SwWrtShell* pWrtShell = GetWrtShell();
1849  OSL_ENSURE(pWrtShell, "no Shell!");
1850  SvTreeListEntry* pEntry = GetCurEntry();
1851  if(!pEntry || lcl_IsContentType(pEntry) || !pWrtShell)
1852  return false;
1853  OUString sEntry;
1854  assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1855  SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
1856 
1857  const ContentTypeId nActType = pCnt->GetParent()->GetType();
1858  OUString sUrl;
1859  bool bOutline = false;
1860  OUString sOutlineText;
1861  switch( nActType )
1862  {
1864  {
1865  const SwOutlineNodes::size_type nPos = static_cast<SwOutlineContent*>(pCnt)->GetOutlinePos();
1866  OSL_ENSURE(nPos < pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNodesCount(),
1867  "outlinecnt changed");
1868 
1869  // make sure outline may actually be copied
1870  if( pWrtShell->IsOutlineCopyable( nPos ) )
1871  {
1872  const SwNumRule* pOutlRule = pWrtShell->GetOutlineNumRule();
1873  const SwTextNode* pTextNd =
1874  pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineNode(nPos);
1875  if (pTextNd && pOutlRule && pTextNd->IsNumbered(pWrtShell->GetLayout()))
1876  {
1877  SwNumberTree::tNumberVector aNumVector =
1878  pTextNd->GetNumberVector(pWrtShell->GetLayout());
1879  for( int nLevel = 0;
1880  nLevel <= pTextNd->GetActualListLevel();
1881  nLevel++ )
1882  {
1883  const SwNumberTree::tSwNumTreeNumber nVal = aNumVector[nLevel] + 1;
1884  sEntry += OUString::number( nVal - pOutlRule->Get(nLevel).GetStart() );
1885  sEntry += ".";
1886  }
1887  }
1888  sEntry += pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, pWrtShell->GetLayout(), false);
1889  sOutlineText = pWrtShell->getIDocumentOutlineNodesAccess()->getOutlineText(nPos, pWrtShell->GetLayout());
1890  m_bIsOutlineMoveable = static_cast<SwOutlineContent*>(pCnt)->IsMoveable();
1891  bOutline = true;
1892  }
1893  }
1894  break;
1895  case ContentTypeId::POSTIT:
1896  case ContentTypeId::INDEX:
1898  // cannot be inserted, neither as URL nor as section
1899  break;
1901  sUrl = static_cast<SwURLFieldContent*>(pCnt)->GetURL();
1902  [[fallthrough]];
1903  case ContentTypeId::OLE:
1906  break;
1907  else
1908  rDragMode &= ~( DND_ACTION_MOVE | DND_ACTION_LINK );
1909  [[fallthrough]];
1910  default:
1911  sEntry = GetEntryText(pEntry);
1912  }
1913 
1914  bool bRet = false;
1915  if(!sEntry.isEmpty())
1916  {
1917  const SwDocShell* pDocShell = pWrtShell->GetView().GetDocShell();
1918  if(sUrl.isEmpty())
1919  {
1920  if(pDocShell->HasName())
1921  {
1922  SfxMedium* pMedium = pDocShell->GetMedium();
1923  sUrl = pMedium->GetURLObject().GetURLNoMark();
1924  // only if a primarily link shall be integrated.
1925  bRet = true;
1926  }
1927  else if ( nActType == ContentTypeId::REGION || nActType == ContentTypeId::BOOKMARK )
1928  {
1929  // For field and bookmarks a link is also allowed
1930  // without a filename into its own document.
1931  bRet = true;
1932  }
1933  else if (State::CONSTANT == m_eState &&
1934  ( !::GetActiveView() ||
1935  m_pActiveShell != ::GetActiveView()->GetWrtShellPtr()))
1936  {
1937  // Urls of inactive views cannot dragged without
1938  // file names, also.
1939  bRet = false;
1940  }
1941  else
1942  {
1944  rDragMode = DND_ACTION_MOVE;
1945  }
1946 
1947  const OUString& rToken = pCnt->GetParent()->GetTypeToken();
1948  sUrl += "#" + sEntry;
1949  if(!rToken.isEmpty())
1950  {
1951  sUrl += OUStringLiteral1(cMarkSeparator) + rToken;
1952  }
1953  }
1954  else
1955  bRet = true;
1956 
1957  if( bRet )
1958  {
1959  // In Outlines of heading text must match
1960  // the real number into the description.
1961  if(bOutline)
1962  sEntry = sOutlineText;
1963 
1964  {
1965  NaviContentBookmark aBmk( sUrl, sEntry,
1966  GetParentWindow()->GetRegionDropMode(),
1967  pDocShell);
1968  aBmk.Copy( rTransfer );
1969  }
1970 
1971  // An INetBookmark must a be delivered to foreign DocShells
1972  if( pDocShell->HasName() )
1973  {
1974  INetBookmark aBkmk( sUrl, sEntry );
1975  rTransfer.CopyINetBookmark( aBkmk );
1976  }
1977  }
1978  }
1979  return bRet;
1980 }
1981 
1983 {
1984  if(!m_bIsRoot)
1985  {
1986  SvTreeListEntry* pEntry = GetCurEntry();
1987  const SwContentType* pCntType;
1988  if(pEntry)
1989  {
1990  if(lcl_IsContentType(pEntry))
1991  {
1992  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1993  pCntType = static_cast<SwContentType*>(pEntry->GetUserData());
1994  }
1995  else
1996  {
1997  assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
1998  pCntType = static_cast<SwContent*>(pEntry->GetUserData())->GetParent();
1999  }
2000  m_nRootType = pCntType->GetType();
2001  m_bIsRoot = true;
2004  {
2005  SetSelectionMode(SelectionMode::Multiple);
2006  SetDragDropMode(DragDropMode::CTRL_MOVE |
2007  DragDropMode::CTRL_COPY |
2008  DragDropMode::ENABLE_TOP);
2009  }
2010  }
2011  }
2012  else
2013  {
2014  SetSelectionMode(SelectionMode::Single);
2016  m_bIsRoot = false;
2019  if( m_bIsKeySpace )
2020  {
2021  HideFocus();
2023  m_bIsKeySpace = false;
2024  }
2025  }
2028  xBox->CheckItem(xBox->GetItemId("root"), m_bIsRoot);
2029 }
2030 
2032 {
2033 
2034 // - Run through the local array and the Treelistbox in parallel.
2035 // - Are the records not expanded, they are discarded only in the array
2036 // and the content type will be set as the new UserData.
2037 // - Is the root mode is active only this will be updated.
2038 
2039 // Valid for the displayed content types is:
2040 // the Memberlist will be erased and the membercount will be updated
2041 // If content will be checked, the memberlists will be replenished
2042 // at the same time. Once a difference occurs it will be only replenished
2043 // no longer checked. Finally, the box is filled again.
2044 
2045  bool bRepaint = false;
2046  bool bInvalidate = false;
2047 
2048  if (State::HIDDEN == m_eState)
2049  {
2051  {
2052  if(m_aActiveContentArr[i])
2053  m_aActiveContentArr[i]->Invalidate();
2054  }
2055  }
2056  else if(m_bIsRoot)
2057  {
2058  bool bOutline = false;
2059  SvTreeListEntry* pEntry = First();
2060  if(!pEntry)
2061  bRepaint = true;
2062  else
2063  {
2064  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2065  const ContentTypeId nType = static_cast<SwContentType*>(pEntry->GetUserData())->GetType();
2066  bOutline = m_nRootType == ContentTypeId::OUTLINE;
2067  SwContentType* pArrType = m_aActiveContentArr[nType].get();
2068  if(!pArrType)
2069  bRepaint = true;
2070  else
2071  {
2072  SvTreeListEntry* pFirstSel;
2073  if(bOutline &&
2074  nullptr != ( pFirstSel = FirstSelected()) &&
2075  lcl_IsContent(pFirstSel))
2076  {
2077  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirstSel->GetUserData())));
2078  const auto nSelLevel =
2079  static_cast<SwOutlineContent*>(pFirstSel->GetUserData())->GetOutlineLevel();
2080  SwWrtShell* pSh = GetWrtShell();
2081  const SwOutlineNodes::size_type nOutlinePos = pSh->GetOutlinePos(MAXLEVEL);
2082  if (nOutlinePos != SwOutlineNodes::npos &&
2083  pSh->getIDocumentOutlineNodesAccess()->getOutlineLevel(nOutlinePos) != nSelLevel)
2084  bRepaint = true;
2085  }
2086 
2087  pArrType->Init(&bInvalidate);
2088  pArrType->FillMemberList();
2089  pEntry->SetUserData(static_cast<void*>(pArrType));
2090  if(!bRepaint)
2091  {
2092  if(GetChildCount(pEntry) != pArrType->GetMemberCount())
2093  bRepaint = true;
2094  else
2095  {
2096  const size_t nChildCount = GetChildCount(pEntry);
2097  for(size_t j = 0; j < nChildCount; ++j)
2098  {
2099  pEntry = Next(pEntry);
2100  assert(pEntry);
2101  const SwContent* pCnt = pArrType->GetMember(j);
2102  pEntry->SetUserData(const_cast<SwContent *>(pCnt));
2103  OUString sEntryText = GetEntryText(pEntry);
2104  if( sEntryText != pCnt->GetName() &&
2105  !(sEntryText == m_sSpace && pCnt->GetName().isEmpty()))
2106  bRepaint = true;
2107  }
2108  }
2109  }
2110  }
2111  }
2112  if( !bRepaint && bOutline )
2113  {
2114  // find out where the cursor is
2116  SvTreeListEntry* pFirstEntry = First();
2117 
2118  while( nullptr != (pFirstEntry = Next(pFirstEntry)) )
2119  {
2120  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirstEntry->GetUserData())));
2121  if (static_cast<SwOutlineContent*>(pFirstEntry->GetUserData())->GetOutlinePos() == nActPos)
2122  {
2123  if(FirstSelected() != pFirstEntry)
2124  {
2125  Select(pFirstEntry);
2126  MakeVisible(pFirstEntry);
2127  }
2128  }
2129  else
2130  Select(pFirstEntry, false);
2131  }
2132 
2133  }
2134 
2135  }
2136  else
2137  {
2138  SvTreeListEntry* pEntry = First();
2139  while ( pEntry )
2140  {
2141  bool bNext = true; // at least a next must be
2142  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2143  SwContentType* pTreeType = static_cast<SwContentType*>(pEntry->GetUserData());
2144  const size_t nTreeCount = pTreeType->GetMemberCount();
2145  const ContentTypeId nType = pTreeType->GetType();
2146  SwContentType* pArrType = m_aActiveContentArr[nType].get();
2147  if(!pArrType)
2148  bRepaint = true;
2149  else
2150  {
2151  pArrType->Init(&bInvalidate);
2152  pEntry->SetUserData(static_cast<void*>(pArrType));
2153  if(IsExpanded(pEntry))
2154  {
2155  bool bLevelOrVisibiblityChanged = false;
2156  // bLevelOrVisibiblityChanged is set if outlines have changed their level
2157  // or if the visibility of objects (frames, sections, tables) has changed
2158  // i.e. in header/footer
2159  pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
2160  const size_t nChildCount = GetChildCount(pEntry);
2161  if((nType == ContentTypeId::OUTLINE) && bLevelOrVisibiblityChanged)
2162  bRepaint = true;
2163  if(bLevelOrVisibiblityChanged)
2164  bInvalidate = true;
2165 
2166  if(nChildCount != pArrType->GetMemberCount())
2167  bRepaint = true;
2168  else
2169  {
2170  for(size_t j = 0; j < nChildCount; ++j)
2171  {
2172  pEntry = Next(pEntry);
2173  assert(pEntry);
2174  bNext = false;
2175  const SwContent* pCnt = pArrType->GetMember(j);
2176  pEntry->SetUserData(const_cast<SwContent *>(pCnt));
2177  OUString sEntryText = GetEntryText(pEntry);
2178  if( sEntryText != pCnt->GetName() &&
2179  !(sEntryText == m_sSpace && pCnt->GetName().isEmpty()))
2180  bRepaint = true;
2181  }
2182  }
2183 
2184  }
2185  else if(pEntry->HasChildren())
2186  {
2187  // was the entry once opened, then must also the
2188  // invisible records be examined.
2189  // At least the user data must be updated.
2190  bool bLevelOrVisibiblityChanged = false;
2191  // bLevelOrVisibiblityChanged is set if outlines have changed their level
2192  // or if the visibility of objects (frames, sections, tables) has changed
2193  // i.e. in header/footer
2194  pArrType->FillMemberList(&bLevelOrVisibiblityChanged);
2195  bool bRemoveChildren = false;
2196  const size_t nChildCount = GetChildCount(pEntry);
2197  if( nChildCount != pArrType->GetMemberCount() )
2198  {
2199  bRemoveChildren = true;
2200  }
2201  else
2202  {
2203  SvTreeListEntry* pChild = FirstChild(pEntry);
2204  for(size_t j = 0; j < nChildCount; ++j)
2205  {
2206  const SwContent* pCnt = pArrType->GetMember(j);
2207  assert(pChild);
2208  pChild->SetUserData(const_cast<SwContent *>(pCnt));
2209  OUString sEntryText = GetEntryText(pChild);
2210  if( sEntryText != pCnt->GetName() &&
2211  !(sEntryText == m_sSpace && pCnt->GetName().isEmpty()))
2212  bRemoveChildren = true;
2213  pChild = Next(pChild);
2214  }
2215  }
2216  if(bRemoveChildren)
2217  {
2218  for(size_t j = 0; j < nChildCount; ++j)
2219  {
2220  SvTreeListEntry *const pRemove = FirstChild(pEntry);
2221  assert(pRemove);
2222  GetModel()->Remove(pRemove);
2223  }
2224  }
2225  if(!nChildCount)
2226  {
2227  pEntry->EnableChildrenOnDemand(false);
2228  InvalidateEntry(pEntry);
2229  }
2230 
2231  }
2232  else if((nTreeCount != 0)
2233  != (pArrType->GetMemberCount()!=0))
2234  {
2235  bRepaint = true;
2236  }
2237  }
2238  // The Root-Entry has to be found now
2239  while( pEntry && (bNext || GetParent(pEntry ) ))
2240  {
2241  pEntry = Next(pEntry);
2242  bNext = false;
2243  }
2244  }
2245  }
2246  if(!bRepaint && bInvalidate)
2247  Invalidate();
2248  return bRepaint;
2249 }
2250 
2252 {
2253  SvTreeListEntry* pEntry = FirstSelected();
2254  if(pEntry)
2255  {
2256  // If clear is called by TimerUpdate:
2257  // Only for root can the validity of the UserData be guaranteed.
2258  SvTreeListEntry* pParent;
2259  while(nullptr != (pParent = GetParent(pEntry)))
2260  pEntry = pParent;
2261  if(pEntry->GetUserData() && lcl_IsContentType(pEntry))
2262  {
2263  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2264  m_nLastSelType = static_cast<SwContentType*>(pEntry->GetUserData())->GetType();
2265  }
2266  }
2267  pEntry = First();
2268  while(pEntry)
2269  {
2270  pEntry->SetUserData(nullptr);
2271  pEntry = Next(pEntry);
2272  }
2273 }
2274 
2276 {
2277  m_pHiddenShell = pSh;
2281  {
2282  m_aHiddenContentArr[i].reset();
2283  }
2284  Display(false);
2285 
2287 }
2288 
2290 {
2291  if(m_bIsInternalDrag)
2292  m_bDocChgdInDragging = true;
2293  bool bClear = m_pActiveShell != pSh;
2294  if (State::ACTIVE == m_eState && bClear)
2295  {
2296  if (m_pActiveShell)
2298  m_pActiveShell = pSh;
2300  Clear();
2301  }
2302  else if (State::CONSTANT == m_eState)
2303  {
2304  if (m_pActiveShell)
2306  m_pActiveShell = pSh;
2308  bClear = true;
2309  }
2310  // Only if it is the active view, the array will be deleted and
2311  // the screen filled new.
2312  if (State::ACTIVE == m_eState && bClear)
2313  {
2314  if (m_pActiveShell)
2318  {
2319  m_aActiveContentArr[i].reset();
2320  }
2321  Display(true);
2322  }
2323 }
2324 
2326 {
2327  if (m_pActiveShell)
2329  m_pActiveShell = pSh;
2331  StartListening(*m_pActiveShell->GetView().GetDocShell());
2334  {
2335  m_aActiveContentArr[i].reset();
2336  }
2337  Display(true);
2338 }
2339 
2340 
2342 {
2343  SfxViewEventHint const*const pVEHint(dynamic_cast<SfxViewEventHint const*>(&rHint));
2344  SwXTextView* pDyingShell = nullptr;
2345  if (m_pActiveShell && pVEHint && pVEHint->GetEventName() == "OnViewClosed")
2346  pDyingShell = dynamic_cast<SwXTextView*>(pVEHint->GetController().get());
2347  if (pDyingShell && pDyingShell->GetView() == &m_pActiveShell->GetView())
2348  {
2349  SetActiveShell(nullptr); // our view is dying, clear our pointers to it
2350  }
2351  else
2352  {
2353  SfxListener::Notify(rBC, rHint);
2354  }
2355  switch (rHint.GetId())
2356  {
2357  case SfxHintId::DocChanged:
2358  m_bViewHasChanged = true;
2359  break;
2360  case SfxHintId::ModeChanged:
2361  if (SwWrtShell* pShell = GetWrtShell())
2362  {
2363  const bool bReadOnly = pShell->GetView().GetDocShell()->IsReadOnly();
2364  if (bReadOnly != m_bIsLastReadOnly)
2365  {
2366  m_bIsLastReadOnly = bReadOnly;
2367  Select(GetCurEntry());
2368  }
2369  }
2370  break;
2371  default:
2372  break;
2373  }
2374 }
2375 
2376 
2377 
2378 void SwContentTree::ExecCommand(const OUString& rCmd, bool bOutlineWithChildren)
2379 {
2380  const bool bUp = rCmd == "up";
2381  const bool bUpDown = bUp || rCmd == "down";
2382  const bool bLeft = rCmd == "promote";
2383  const bool bLeftRight = bLeft || rCmd == "demote";
2384  if (!bUpDown && !bLeftRight)
2385  return;
2386  if (GetWrtShell()->GetView().GetDocShell()->IsReadOnly() ||
2387  (State::ACTIVE != m_eState &&
2388  (State::CONSTANT != m_eState || m_pActiveShell != GetParentWindow()->GetCreateView()->GetWrtShellPtr())))
2389  {
2390  return;
2391  }
2392 
2393  SwWrtShell *const pShell = GetWrtShell();
2394  sal_Int8 nActOutlineLevel = m_nOutlineLevel;
2395  SwOutlineNodes::size_type nActPos = pShell->GetOutlinePos(nActOutlineLevel);
2396 
2397  std::vector<SvTreeListEntry*> selected;
2398  for (SvTreeListEntry * pEntry = FirstSelected(); pEntry; pEntry = NextSelected(pEntry))
2399  {
2400  // it's possible to select the root node too which is a really bad idea
2401  bool bSkip = lcl_IsContentType(pEntry);
2402  // filter out children of selected parents so they don't get promoted
2403  // or moved twice (except if there is Ctrl modifier, since in that
2404  // case children are re-parented)
2405  if ((bLeftRight || bOutlineWithChildren) && !selected.empty())
2406  {
2407  for (auto pParent = GetParent(pEntry); pParent; pParent = GetParent(pParent))
2408  {
2409  if (selected.back() == pParent)
2410  {
2411  bSkip = true;
2412  break;
2413  }
2414  }
2415  }
2416  if (!bSkip)
2417  {
2418  selected.push_back(pEntry);
2419  }
2420  }
2421  if (bUpDown && !bUp)
2422  { // to move down, start at the end!
2423  std::reverse(selected.begin(), selected.end());
2424  }
2425 
2426  bool bStartedAction = false;
2427  for (auto const pCurrentEntry : selected)
2428  {
2429  assert(pCurrentEntry && lcl_IsContent(pCurrentEntry));
2430  if (pCurrentEntry && lcl_IsContent(pCurrentEntry))
2431  {
2432  assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pCurrentEntry->GetUserData())));
2434  static_cast<SwContent*>(pCurrentEntry->GetUserData())->GetParent()->GetType()
2436  {
2437  nActPos = static_cast<SwOutlineContent*>(pCurrentEntry->GetUserData())->GetOutlinePos();
2438  }
2439  }
2440  if (nActPos == SwOutlineNodes::npos || (bUpDown && !pShell->IsOutlineMovable(nActPos)))
2441  {
2442  continue;
2443  }
2444 
2445  if (!bStartedAction)
2446  {
2447  pShell->StartAllAction();
2448  pShell->StartUndo(bLeftRight ? SwUndoId::OUTLINE_LR : SwUndoId::OUTLINE_UD);
2449  bStartedAction = true;
2450  }
2451  pShell->GotoOutline( nActPos); // If text selection != box selection
2452  pShell->Push();
2453  pShell->MakeOutlineSel(nActPos, nActPos, bOutlineWithChildren);
2454  if (bUpDown)
2455  {
2456  sal_uLong const nEntryAbsPos(GetModel()->GetAbsPos(pCurrentEntry));
2457  SwOutlineNodes::difference_type nDir = bUp ? -1 : 1;
2458  if (!bOutlineWithChildren && ((nDir == -1 && nActPos > 0) ||
2459  (nDir == 1 && nEntryAbsPos < GetEntryCount() - 2)))
2460  {
2461  pShell->MoveOutlinePara( nDir );
2462  // Set cursor back to the current position
2463  pShell->GotoOutline( nActPos + nDir);
2464  }
2465  else if (bOutlineWithChildren && pCurrentEntry)
2466  {
2467  SwOutlineNodes::size_type nActEndPos = nActPos;
2468  SvTreeListEntry* pEntry = pCurrentEntry;
2469  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pCurrentEntry->GetUserData())));
2470  const auto nActLevel = static_cast<SwOutlineContent*>(
2471  pCurrentEntry->GetUserData())->GetOutlineLevel();
2472  pEntry = Next(pEntry);
2473  while (pEntry && lcl_IsContent(pEntry))
2474  {
2475  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2476  if (nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel())
2477  break;
2478  nActEndPos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
2479  pEntry = Next(pEntry);
2480  }
2481  if (nDir == 1)
2482  {
2483  // If the last entry is to be moved we're done
2484  if (pEntry && lcl_IsContent(pEntry))
2485  {
2486  // pEntry now points to the entry following the last
2487  // selected entry.
2488  SwOutlineNodes::size_type nDest = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
2489  // here needs to found the next entry after next.
2490  // The selection must be inserted in front of that.
2491  while (pEntry)
2492  {
2493  pEntry = Next(pEntry);
2494  assert(pEntry == nullptr || !lcl_IsContent(pEntry) || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2495  // nDest++ may only executed if pEntry != 0
2496  if (pEntry)
2497  {
2498  if (!lcl_IsContent(pEntry) ||
2499  nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel())
2500  {
2501  break;
2502  }
2503  else
2504  {
2505  nDest = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
2506  }
2507  }
2508  }
2509  nDir = nDest - nActEndPos;
2510  // If no entry was found that allows insertion before
2511  // it, we just move it to the end.
2512  }
2513  else
2514  nDir = 0;
2515  }
2516  else
2517  {
2518  SwOutlineNodes::size_type nDest = nActPos;
2519  pEntry = pCurrentEntry;
2520  while (pEntry && nDest)
2521  {
2522  pEntry = Prev(pEntry);
2523  assert(pEntry == nullptr || !lcl_IsContent(pEntry) || dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2524  if (pEntry && lcl_IsContent(pEntry))
2525  {
2526  nDest = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
2527  }
2528  else
2529  {
2530  nDest = 0; // presumably?
2531  }
2532  if (pEntry &&
2533  (!lcl_IsContent(pEntry)
2534  || nActLevel >= static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlineLevel()))
2535  {
2536  break;
2537  }
2538  }
2539  nDir = nDest - nActPos;
2540  }
2541  if (nDir)
2542  {
2543  pShell->MoveOutlinePara( nDir );
2544  // Set cursor back to the current position
2545  pShell->GotoOutline(nActPos + nDir);
2546  }
2547  }
2548  }
2549  else
2550  {
2551  if (!pShell->IsProtectedOutlinePara())
2552  pShell->OutlineUpDown(bLeft ? -1 : 1);
2553  }
2554 
2555  pShell->ClearMark();
2556  pShell->Pop(SwCursorShell::PopMode::DeleteCurrent); // Cursor is now back at the current heading.
2557  }
2558 
2559  if (bStartedAction)
2560  {
2561  pShell->EndUndo();
2562  pShell->EndAllAction();
2565  Display(true);
2566  if (!m_bIsRoot)
2567  {
2568  const SwOutlineNodes::size_type nCurrPos = pShell->GetOutlinePos(MAXLEVEL);
2569  SvTreeListEntry* pFirst = First();
2570 
2571  while (nullptr != (pFirst = Next(pFirst)) && lcl_IsContent(pFirst))
2572  {
2573  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pFirst->GetUserData())));
2574  if (static_cast<SwOutlineContent*>(pFirst->GetUserData())->GetOutlinePos() == nCurrPos)
2575  {
2576  Select(pFirst);
2577  MakeVisible(pFirst);
2578  }
2579  }
2580  }
2581  }
2582 }
2583 
2585 {
2587 }
2588 
2590  const tools::Rectangle& rRect )
2591 {
2592  // Start the update timer on the first paint; avoids
2593  // flicker on the first reveal.
2594  m_aUpdTimer.Start();
2595  SvTreeListBox::Paint( rRenderContext, rRect );
2596 }
2597 
2599 {
2600  m_aUpdTimer.Stop();
2602 }
2603 
2605 IMPL_LINK_NOARG(SwContentTree, TimerUpdate, Timer *, void)
2606 {
2607  if (IsDisposed())
2608  return;
2609 
2610  // No update while drag and drop.
2611  // Query view because the Navigator is cleared too late.
2612  SwView* pView = GetParentWindow()->GetCreateView();
2613  if( (!HasFocus() || m_bViewHasChanged) &&
2614  !bIsInDrag && !m_bIsInternalDrag && pView &&
2615  pView->GetWrtShellPtr() && !pView->GetWrtShellPtr()->ActionPend() )
2616  {
2617  m_bViewHasChanged = false;
2618  m_bIsIdleClear = false;
2619  SwWrtShell* pActShell = pView->GetWrtShellPtr();
2620  if (State::CONSTANT == m_eState && !lcl_FindShell(m_pActiveShell))
2621  {
2622  SetActiveShell(pActShell);
2623  GetParentWindow()->UpdateListBox();
2624  }
2625 
2626  if (State::ACTIVE == m_eState && pActShell != GetWrtShell())
2627  {
2628  SetActiveShell(pActShell);
2629  }
2630  else if ((State::ACTIVE == m_eState || (State::CONSTANT == m_eState && pActShell == GetWrtShell())) &&
2631  HasContentChanged())
2632  {
2633  FindActiveTypeAndRemoveUserData();
2634  Display(true);
2635  }
2636  }
2637  else if (!pView && State::ACTIVE == m_eState && !m_bIsIdleClear)
2638  {
2639  if(m_pActiveShell)
2640  {
2641  SetActiveShell(nullptr);
2642  }
2643  Clear();
2644  m_bIsIdleClear = true;
2645  }
2646 }
2647 
2649  TransferDataContainer& rContainer,
2650  SvTreeListEntry* pEntry )
2651 {
2652  DragDropMode eMode = DragDropMode(0);
2654  GetModel()->GetAbsPos( pEntry ) > 0
2655  && !GetWrtShell()->GetView().GetDocShell()->IsReadOnly())
2656  eMode = GetDragDropMode();
2657  else if (State::ACTIVE != m_eState && GetWrtShell()->GetView().GetDocShell()->HasName())
2658  eMode = DragDropMode::APP_COPY;
2659 
2660  sal_Int8 nDragMode;
2661  FillTransferData( rContainer, nDragMode );
2662  m_bDocChgdInDragging = false;
2663  m_bIsInternalDrag = true;
2664  return eMode;
2665 }
2666 // After the drag the current paragraph will be moved w i t h the children.
2667 
2669  SvTreeListEntry* pEntry, SvTreeListEntry*& , sal_uLong& )
2670 {
2672  {
2673  SwOutlineNodes::size_type nTargetPos = 0;
2674  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2675  SwOutlineNodes::size_type nSourcePos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
2676  if(!lcl_IsContent(pTarget))
2677  nTargetPos = SwOutlineNodes::npos;
2678  else
2679  {
2680  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pTarget->GetUserData())));
2681  nTargetPos = static_cast<SwOutlineContent*>(pTarget->GetUserData())->GetOutlinePos();
2682  }
2683  if( MAXLEVEL > m_nOutlineLevel && // Not all layers are displayed.
2684  nTargetPos != SwOutlineNodes::npos)
2685  {
2686  SvTreeListEntry* pNext = Next(pTarget);
2687  if(pNext)
2688  {
2689  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pNext->GetUserData())));
2690  nTargetPos = static_cast<SwOutlineContent*>(pNext->GetUserData())->GetOutlinePos() - 1;
2691  }
2692  else
2694  }
2695 
2696  OSL_ENSURE( pEntry &&
2697  lcl_IsContent(pEntry),"Source == 0 or Source has no Content" );
2698  GetParentWindow()->MoveOutline( nSourcePos,
2699  nTargetPos,
2700  true);
2701 
2703  Display(true);
2704  }
2705  //TreeListBox will be reloaded from the document
2706  return TRISTATE_FALSE;
2707 }
2708 
2709 // After the drag the current paragraph will be moved w i t h o u t the children.
2710 
2712  SvTreeListEntry* pEntry, SvTreeListEntry*& , sal_uLong& )
2713 {
2715  {
2716  SwOutlineNodes::size_type nTargetPos = 0;
2717  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2718  SwOutlineNodes::size_type nSourcePos = static_cast<SwOutlineContent*>(pEntry->GetUserData())->GetOutlinePos();
2719  if(!lcl_IsContent(pTarget))
2720  nTargetPos = SwOutlineNodes::npos;
2721  else
2722  {
2723  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pTarget->GetUserData())));
2724  nTargetPos = static_cast<SwOutlineContent*>(pTarget->GetUserData())->GetOutlinePos();
2725  }
2726 
2727  if( MAXLEVEL > m_nOutlineLevel && // Not all layers are displayed.
2728  nTargetPos != SwOutlineNodes::npos)
2729  {
2730  SvTreeListEntry* pNext = Next(pTarget);
2731  if(pNext)
2732  {
2733  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pNext->GetUserData())));
2734  nTargetPos = static_cast<SwOutlineContent*>(pNext->GetUserData())->GetOutlinePos() - 1;
2735  }
2736  else
2738  }
2739 
2740  OSL_ENSURE( pEntry &&
2741  lcl_IsContent(pEntry),"Source == 0 or Source has no Content" );
2742  GetParentWindow()->MoveOutline( nSourcePos, nTargetPos, false);
2743 
2744  //TreeListBox will be reloaded from the document
2746  Display(true);
2747  }
2748  return TRISTATE_FALSE;
2749 }
2750 
2751 // No drop before the first entry - it's a SwContentType
2752 
2754 {
2755  return pEntry != nullptr;
2756 }
2757 
2758 // If a Ctrl + DoubleClick are executed in an open area,
2759 // then the base function of the control is to be called.
2760 
2762 {
2763  Point aPos( rMEvt.GetPosPixel());
2764  SvTreeListEntry* pEntry = GetEntry( aPos, true );
2765  if( !pEntry && rMEvt.IsLeft() && rMEvt.IsMod1() && (rMEvt.GetClicks() % 2) == 0)
2766  Control::MouseButtonDown( rMEvt );
2767  else
2768  {
2769  if( pEntry && (rMEvt.GetClicks() % 2) == 0)
2770  {
2771  SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
2772  const ContentTypeId nActType = pCnt->GetParent()->GetType();
2774  }
2776  }
2777 }
2778 
2779 // Update immediately
2780 
2782 {
2783  SwView* pActView = GetParentWindow()->GetCreateView();
2784  if(pActView)
2785  {
2786  SwWrtShell* pActShell = pActView->GetWrtShellPtr();
2787  if (State::CONSTANT == m_eState && !lcl_FindShell(m_pActiveShell))
2788  {
2789  SetActiveShell(pActShell);
2790  }
2791 
2792  if (State::ACTIVE == m_eState && pActShell != GetWrtShell())
2793  SetActiveShell(pActShell);
2794  else if ((State::ACTIVE == m_eState || (State::CONSTANT == m_eState && pActShell == GetWrtShell())) &&
2796  {
2797  Display(true);
2798  }
2799  }
2800  else if (State::ACTIVE == m_eState)
2801  Clear();
2803 }
2804 
2806 {
2807  const vcl::KeyCode aCode = rEvent.GetKeyCode();
2808  if(aCode.GetCode() == KEY_RETURN)
2809  {
2810  SvTreeListEntry* pEntry = FirstSelected();
2811  if ( pEntry )
2812  {
2813  switch(aCode.GetModifier())
2814  {
2815  case KEY_MOD2:
2816  // Switch boxes
2818  break;
2819  case KEY_MOD1:
2820  // Switch RootMode
2821  ToggleToRoot();
2822  break;
2823  case 0:
2824  if(lcl_IsContentType(pEntry))
2825  {
2826  IsExpanded(pEntry) ? Collapse(pEntry) : Expand(pEntry);
2827  }
2828  else
2829  ContentDoubleClickHdl(nullptr);
2830  break;
2831  }
2832  }
2833  }
2834  else if(aCode.GetCode() == KEY_DELETE && 0 == aCode.GetModifier())
2835  {
2836  SvTreeListEntry* pEntry = FirstSelected();
2837  assert(!pEntry || dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData())));
2838  if(pEntry &&
2839  lcl_IsContent(pEntry) &&
2840  static_cast<SwContent*>(pEntry->GetUserData())->GetParent()->IsDeletable() &&
2842  {
2844  m_bViewHasChanged = true;
2846  TimerUpdate(&m_aUpdTimer);
2847  GrabFocus();
2848  }
2849  }
2850  //Make KEY_SPACE has same function as DoubleClick ,
2851  //and realize multi-selection .
2852  else if(aCode.GetCode() == KEY_SPACE && 0 == aCode.GetModifier())
2853  {
2854  SvTreeListEntry* pEntry = GetCurEntry();
2855  if(pEntry)
2856  {
2857  if( GetChildCount( pEntry ) == 0 )
2858  m_bIsKeySpace = true;
2859  Point tempPoint = GetEntryPosition( pEntry );//Change from "GetEntryPos" to "GetEntryPosition" for acc migration
2860  m_aOldRectangle = GetFocusRect(pEntry, tempPoint.Y());
2861 
2862  if (State::HIDDEN != m_eState)
2863  {
2864  if (State::CONSTANT == m_eState)
2865  {
2867  }
2868 
2869  SwContent* pCnt = dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pEntry->GetUserData()));
2870 
2871  if (pCnt && pCnt->GetParent()->GetType() == ContentTypeId::DRAWOBJECT)
2872  {
2873  SdrView* pDrawView = m_pActiveShell->GetDrawView();
2874  if (pDrawView)
2875  {
2876  pDrawView->SdrEndTextEdit();
2877 
2879  SdrPage* pPage = pDrawModel->GetPage(0);
2880  const size_t nCount = pPage->GetObjCount();
2881  bool hasObjectMarked = false;
2882 
2883  if (SdrObject* pObject = GetDrawingObjectsByContent(pCnt))
2884  {
2885  SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
2886  if( pPV )
2887  {
2888  bool bUnMark = pDrawView->IsObjMarked(pObject);
2889  pDrawView->MarkObj( pObject, pPV, bUnMark);
2890 
2891  }
2892  }
2893  for( size_t i=0; i<nCount; ++i )
2894  {
2895  SdrObject* pTemp = pPage->GetObj(i);
2896  bool bMark = pDrawView->IsObjMarked(pTemp);
2897  switch( pTemp->GetObjIdentifier() )
2898  {
2899  case OBJ_GRUP:
2900  case OBJ_TEXT:
2901  case OBJ_LINE:
2902  case OBJ_RECT:
2903  case OBJ_CIRC:
2904  case OBJ_SECT:
2905  case OBJ_CARC:
2906  case OBJ_CCUT:
2907  case OBJ_POLY:
2908  case OBJ_PLIN:
2909  case OBJ_PATHLINE:
2910  case OBJ_PATHFILL:
2911  case OBJ_FREELINE:
2912  case OBJ_FREEFILL:
2913  case OBJ_PATHPOLY:
2914  case OBJ_PATHPLIN:
2915  case OBJ_CAPTION:
2916  case OBJ_CUSTOMSHAPE:
2917  if( bMark )
2918  hasObjectMarked = true;
2919  break;
2920  default:
2921  if ( bMark )
2922  {
2923  SdrPageView* pPV = pDrawView->GetSdrPageView/*GetPageViewPvNum*/(/*0*/);
2924  if (pPV)
2925  {
2926  pDrawView->MarkObj(pTemp, pPV, true);
2927  }
2928  }
2929  }
2930  //mod end
2931  }
2932  if ( !hasObjectMarked )
2933  {
2934  SwEditWin& rEditWindow = m_pActiveShell->GetView().GetEditWin();
2935  vcl::KeyCode tempKeycode( KEY_ESCAPE );
2936  KeyEvent rKEvt( 0 , tempKeycode );
2937  static_cast<vcl::Window*>(&rEditWindow)->KeyInput( rKEvt );
2938  }
2939  }
2940  }
2941 
2942  m_bViewHasChanged = true;
2943  }
2944  }
2945 
2946  }
2947  else
2948  SvTreeListBox::KeyInput(rEvent);
2949 
2950 }
2951 
2953 {
2954  bool bCallBase = true;
2955  if( rHEvt.GetMode() & HelpEventMode::QUICK )
2956  {
2957  Point aPos( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ));
2958  SvTreeListEntry* pEntry = GetEntry( aPos );
2959  if( pEntry )
2960  {
2962  bool bBalloon = false;
2963  bool bContent = false;
2964  void* pUserData = pEntry->GetUserData();
2965  if(lcl_IsContentType(pEntry))
2966  {
2967  assert(dynamic_cast<SwContentType*>(static_cast<SwTypeNumber*>(pUserData)));
2968  nType = static_cast<SwContentType*>(pUserData)->GetType();
2969  }
2970  else
2971  {
2972  assert(dynamic_cast<SwContent*>(static_cast<SwTypeNumber*>(pUserData)));
2973  nType = static_cast<SwContent*>(pUserData)->GetParent()->GetType();
2974  bContent = true;
2975  }
2976  OUString sEntry;
2977  bool bRet = false;
2978  if(bContent)
2979  {
2980  switch( nType )
2981  {
2983  assert(dynamic_cast<SwURLFieldContent*>(static_cast<SwTypeNumber*>(pUserData)));
2984  sEntry = static_cast<SwURLFieldContent*>(pUserData)->GetURL();
2985  bRet = true;
2986  break;
2987 
2988  case ContentTypeId::POSTIT:
2989  assert(dynamic_cast<SwPostItContent*>(static_cast<SwTypeNumber*>(pUserData)));
2990  sEntry = static_cast<SwPostItContent*>(pUserData)->GetName();
2991  bRet = true;
2993  bBalloon = true;
2994  break;
2996  assert(dynamic_cast<SwOutlineContent*>(static_cast<SwTypeNumber*>(pUserData)));
2997  sEntry = static_cast<SwOutlineContent*>(pUserData)->GetName();
2998  bRet = true;
2999  break;
3001  assert(dynamic_cast<SwGraphicContent*>(static_cast<SwTypeNumber*>(pUserData)));
3002  sEntry = static_cast<SwGraphicContent*>(pUserData)->GetLink();
3003  bRet = true;
3004  break;
3005  default: break;
3006  }
3007  if(static_cast<SwContent*>(pUserData)->IsInvisible())
3008  {
3009  if(!sEntry.isEmpty())
3010  sEntry += ", ";
3011  sEntry += m_sInvisible;
3012  bRet = true;
3013  }
3014  }
3015  else
3016  {
3017  const size_t nMemberCount = static_cast<SwContentType*>(pUserData)->GetMemberCount();
3018  sEntry = OUString::number(nMemberCount);
3019  sEntry += " ";
3020  sEntry += nMemberCount == 1
3021  ? static_cast<SwContentType*>(pUserData)->GetSingleName()
3022  : static_cast<SwContentType*>(pUserData)->GetName();
3023  bRet = true;
3024  }
3025  if(bRet)
3026  {
3027  SvLBoxTab* pTab;
3028  SvLBoxItem* pItem = GetItem( pEntry, aPos.X(), &pTab );
3029  if (pItem && SvLBoxItemType::String == pItem->GetType())
3030  {
3031  aPos = GetEntryPosition( pEntry );
3032 
3033  aPos.setX( GetTabPos( pEntry, pTab ) );
3034  Size aSize( pItem->GetSize( this, pEntry ) );
3035 
3036  if((aPos.X() + aSize.Width()) > GetSizePixel().Width())
3037  aSize.setWidth( GetSizePixel().Width() - aPos.X() );
3038 
3039  aPos = OutputToScreenPixel(aPos);
3040  tools::Rectangle aItemRect( aPos, aSize );
3041  if(bBalloon)
3042  {
3043  aPos.AdjustX(aSize.Width() );
3044  Help::ShowBalloon( this, aPos, aItemRect, sEntry );
3045  }
3046  else
3047  Help::ShowQuickHelp( this, aItemRect, sEntry,
3048  QuickHelpFlags::Left|QuickHelpFlags::VCenter );
3049  bCallBase = false;
3050  }
3051  }
3052  else
3053  {
3054  Help::ShowQuickHelp( this, tools::Rectangle(), OUString() );
3055  bCallBase = false;
3056  }
3057  }
3058  }
3059  if( bCallBase )
3060  Window::RequestHelp( rHEvt );
3061 }
3062 
3063 void SwContentTree::ExecuteContextMenuAction( sal_uInt16 nSelectedPopupEntry )
3064 {
3065  SvTreeListEntry* pFirst = FirstSelected();
3066  switch( nSelectedPopupEntry )
3067  {
3068  //Outlinelevel
3069  case 101:
3070  case 102:
3071  case 103:
3072  case 104:
3073  case 105:
3074  case 106:
3075  case 107:
3076  case 108:
3077  case 109:
3078  case 110:
3079  nSelectedPopupEntry -= 100;
3080  if(m_nOutlineLevel != nSelectedPopupEntry )
3081  SetOutlineLevel(static_cast<sal_Int8>(nSelectedPopupEntry));
3082  break;
3083  case 201:
3084  case 202:
3085  case 203:
3086  GetParentWindow()->SetRegionDropMode(static_cast<RegionMode>(nSelectedPopupEntry - 201));
3087  break;
3088  case 401:
3089  case 402:
3090  EditEntry(pFirst, nSelectedPopupEntry == 401 ? EditEntryMode::RMV_IDX : EditEntryMode::UPD_IDX);
3091  break;
3092  // Edit entry
3093  case 403:
3094  EditEntry(pFirst, EditEntryMode::EDIT);
3095  break;
3096  case 404:
3098  break;
3099  case 405 :
3100  {
3101  const SwTOXBase* pBase = static_cast<SwTOXBaseContent*>(pFirst->GetUserData())
3102  ->GetTOXBase();
3104  }
3105  break;
3106  case 4:
3107  break;
3108  case 501:
3110  break;
3111  case 502 :
3113  break;
3114  case 600:
3116  break;
3117  case 601:
3119  break;
3120  case 602:
3121  {
3124  break;
3125  }
3126  case 700:
3127  {
3129  break;
3130  }
3131  //Display
3132  default:
3133  if(nSelectedPopupEntry > 300 && nSelectedPopupEntry < 400)
3134  {
3135  nSelectedPopupEntry -= 300;
3136  SwView *pView = SwModule::GetFirstView();
3137  while (pView)
3138  {
3139  nSelectedPopupEntry --;
3140  if(nSelectedPopupEntry == 0)
3141  {
3142  SetConstantShell(&pView->GetWrtShell());
3143  break;
3144  }
3145  pView = SwModule::GetNextView(pView);
3146  }
3147  if(nSelectedPopupEntry)
3148  {
3149  m_bViewHasChanged = nSelectedPopupEntry == 1;
3150  m_eState = (nSelectedPopupEntry == 1) ? State::ACTIVE : State::HIDDEN;
3151  Display(nSelectedPopupEntry == 1);
3152  }
3153  }
3154  }
3156 }
3157 
3159 {
3160  m_nOutlineLevel = nSet;
3162  std::unique_ptr<SwContentType>& rpContentT = (State::ACTIVE == m_eState)
3165  if(rpContentT)
3166  {
3167  rpContentT->SetOutlineLevel(m_nOutlineLevel);
3168  rpContentT->Init();
3169  }
3171 }
3172 
3173 // Mode Change: Show dropped Doc
3174 
3176 {
3177  if(m_pHiddenShell)
3178  {
3180  Display(false);
3181  }
3182 }
3183 
3184 // Mode Change: Show active view
3185 
3187 {
3189  Display(true);
3191 }
3192 
3193 // Here the buttons for moving outlines are en-/disabled.
3194 bool SwContentTree::Select( SvTreeListEntry* pEntry, bool bSelect )
3195 {
3196  if(!pEntry)
3197  return false;
3198  bool bEnable = false;
3199  SvTreeListEntry* pParentEntry = GetParent(pEntry);
3200  while(pParentEntry && (!lcl_IsContentType(pParentEntry)))
3201  {
3202  pParentEntry = GetParent(pParentEntry);
3203  }
3204  if (!m_bIsLastReadOnly)
3205  {
3206  if (!IsVisible())
3207  bEnable = true;
3208  else if (pParentEntry)
3209  {
3211  (lcl_IsContent(pEntry) &&
3212  static_cast<SwContentType*>(pParentEntry->GetUserData())->GetType() == ContentTypeId::OUTLINE))
3213  {
3214  bEnable = true;
3215  }
3216  }
3217  }
3218  SwNavigationPI* pNavi = GetParentWindow();
3219  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("up"), bEnable);
3220  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("down"), bEnable);
3221  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("promote"), bEnable);
3222  pNavi->m_aContentToolBox->EnableItem(pNavi->m_aContentToolBox->GetItemId("demote"), bEnable);
3223 
3224  return SvTreeListBox::Select(pEntry, bSelect);
3225 }
3226 
3228 {
3229  m_nRootType = nType;
3230  m_bIsRoot = true;
3232 }
3233 
3234 OUString SwContentType::RemoveNewline(const OUString& rEntry)
3235 {
3236  if (rEntry.isEmpty())
3237  return rEntry;
3238 
3239  OUStringBuffer aEntry(rEntry);
3240  for (sal_Int32 i = 0; i < rEntry.getLength(); ++i)
3241  if(aEntry[i] == 10 || aEntry[i] == 13)
3242  aEntry[i] = 0x20;
3243 
3244  return aEntry.makeStringAndClear();
3245 }
3246 
3248 {
3249  SwContent* pCnt = static_cast<SwContent*>(pEntry->GetUserData());
3250  GotoContent(pCnt);
3251  const ContentTypeId nType = pCnt->GetParent()->GetType();
3252  sal_uInt16 nSlot = 0;
3253 
3254  uno::Reference< container::XNameAccess > xNameAccess, xSecond, xThird;
3255  switch(nType)
3256  {
3257  case ContentTypeId::TABLE :
3258  if(nMode == EditEntryMode::UNPROTECT_TABLE)
3259  {
3261  GetDoc()->UnProtectCells( pCnt->GetName());
3262  }
3263  else if(nMode == EditEntryMode::DELETE)
3264  {
3266  OUString sTable = SwResId(STR_TABLE_NAME);
3267  SwRewriter aRewriterTableName;
3268  aRewriterTableName.AddRule(UndoArg1, SwResId(STR_START_QUOTE));
3269  aRewriterTableName.AddRule(UndoArg2, pCnt->GetName());
3270  aRewriterTableName.AddRule(UndoArg3, SwResId(STR_END_QUOTE));
3271  sTable = aRewriterTableName.Apply(sTable);
3272 
3273  SwRewriter aRewriter;
3274  aRewriter.AddRule(UndoArg1, sTable);
3280  }
3281  else if(nMode == EditEntryMode::RENAME)
3282  {
3283  uno::Reference< frame::XModel > xModel = m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
3284  uno::Reference< text::XTextTablesSupplier > xTables(xModel, uno::UNO_QUERY);
3285  xNameAccess = xTables->getTextTables();
3286  }
3287  else
3288  nSlot = FN_FORMAT_TABLE_DLG;
3289  break;
3290 
3291  case ContentTypeId::GRAPHIC :
3292  if(nMode == EditEntryMode::DELETE)
3293  {
3295  }
3296  else if(nMode == EditEntryMode::RENAME)
3297  {
3298  uno::Reference< frame::XModel > xModel = m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
3299  uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY);
3300  xNameAccess = xGraphics->getGraphicObjects();
3301  uno::Reference< text::XTextFramesSupplier > xFrames(xModel, uno::UNO_QUERY);
3302  xSecond = xFrames->getTextFrames();
3303  uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY);
3304  xThird = xObjs->getEmbeddedObjects();
3305  }
3306  else
3307  nSlot = FN_FORMAT_GRAFIC_DLG;
3308  break;
3309 
3310  case ContentTypeId::FRAME :
3311  case ContentTypeId::OLE :
3312  if(nMode == EditEntryMode::DELETE)
3313  {
3315  }
3316  else if(nMode == EditEntryMode::RENAME)
3317  {
3318  uno::Reference< frame::XModel > xModel = m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
3319  uno::Reference< text::XTextFramesSupplier > xFrames(xModel, uno::UNO_QUERY);
3320  uno::Reference< text::XTextEmbeddedObjectsSupplier > xObjs(xModel, uno::UNO_QUERY);
3321  if(ContentTypeId::FRAME == nType)
3322  {
3323  xNameAccess = xFrames->getTextFrames();
3324  xSecond = xObjs->getEmbeddedObjects();
3325  }
3326  else
3327  {
3328  xNameAccess = xObjs->getEmbeddedObjects();
3329  xSecond = xFrames->getTextFrames();
3330  }
3331  uno::Reference< text::XTextGraphicObjectsSupplier > xGraphics(xModel, uno::UNO_QUERY);
3332  xThird = xGraphics->getGraphicObjects();
3333  }
3334  else
3335  nSlot = FN_FORMAT_FRAME_DLG;
3336  break;
3338  if(nMode == EditEntryMode::DELETE)
3339  {
3341  pMarkAccess->deleteMark( pMarkAccess->findMark(pCnt->GetName()) );
3342  }
3343  else if(nMode == EditEntryMode::RENAME)
3344  {
3345  uno::Reference< frame::XModel > xModel = m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
3346  uno::Reference< text::XBookmarksSupplier > xBkms(xModel, uno::UNO_QUERY);
3347  xNameAccess = xBkms->getBookmarks();
3348  }
3349  else
3350  nSlot = FN_INSERT_BOOKMARK;
3351  break;
3352 
3353  case ContentTypeId::REGION :
3354  if(nMode == EditEntryMode::RENAME)
3355  {
3356  uno::Reference< frame::XModel > xModel = m_pActiveShell->GetView().GetDocShell()->GetBaseModel();
3357  uno::Reference< text::XTextSectionsSupplier > xSects(xModel, uno::UNO_QUERY);
3358  xNameAccess = xSects->getTextSections();
3359  }
3360  else
3361  nSlot = FN_EDIT_REGION;
3362  break;
3363 
3365  nSlot = FN_EDIT_HYPERLINK;
3366  break;
3368  nSlot = FN_EDIT_FIELD;
3369  break;
3370 
3371  case ContentTypeId::POSTIT:
3373  if(nMode == EditEntryMode::DELETE)
3374  {
3377  }
3378  else
3379  {
3380  nSlot = FN_POSTIT;
3381  }
3382  break;
3383  case ContentTypeId::INDEX:
3384  {
3385  const SwTOXBase* pBase = static_cast<SwTOXBaseContent*>(pCnt)->GetTOXBase();
3386  switch(nMode)
3387  {
3388  case EditEntryMode::EDIT:
3389  if(pBase)
3390  {
3391  SwPtrItem aPtrItem( FN_INSERT_MULTI_TOX, const_cast<SwTOXBase *>(pBase));
3394  SfxCallMode::ASYNCHRON, { &aPtrItem });
3395 
3396  }
3397  break;
3399  case EditEntryMode::DELETE:
3400  {
3401  if( pBase )
3402  m_pActiveShell->DeleteTOX(*pBase, EditEntryMode::DELETE == nMode);
3403  }
3404  break;
3406  case EditEntryMode::RENAME:
3407  {
3409  Reference< XDocumentIndexesSupplier > xIndexes(xModel, UNO_QUERY);
3410  Reference< XIndexAccess> xIdxAcc(xIndexes->getDocumentIndexes());
3411  Reference< XNameAccess >xLocalNameAccess(xIdxAcc, UNO_QUERY);
3412  if(EditEntryMode::RENAME == nMode)
3413  xNameAccess = xLocalNameAccess;
3414  else if(xLocalNameAccess.is() && xLocalNameAccess->hasByName(pBase->GetTOXName()))
3415  {
3416  Any aIdx = xLocalNameAccess->getByName(pBase->GetTOXName());
3417  Reference< XDocumentIndex> xIdx;
3418  if(aIdx >>= xIdx)
3419  xIdx->update();
3420  }
3421  }
3422  break;
3423  default: break;
3424  }
3425  }
3426  break;
3428  if(EditEntryMode::DELETE == nMode)
3429  nSlot = SID_DELETE;
3430  break;
3431  default: break;
3432  }
3433  if(nSlot)
3435  GetDispatcher()->Execute(nSlot, SfxCallMode::ASYNCHRON);
3436  else if(xNameAccess.is())
3437  {
3438  uno::Any aObj = xNameAccess->getByName(pCnt->GetName());
3439  uno::Reference< uno::XInterface > xTmp;
3440  aObj >>= xTmp;
3441  uno::Reference< container::XNamed > xNamed(xTmp, uno::UNO_QUERY);
3444  if(xSecond.is())
3445  pDlg->SetAlternativeAccess( xSecond, xThird);
3446 
3447  OUString sForbiddenChars;
3448  if(ContentTypeId::BOOKMARK == nType)
3449  {
3450  sForbiddenChars = "/\\@:*?\";,.#";
3451  }
3452  else if(ContentTypeId::TABLE == nType)
3453  {
3454  sForbiddenChars = " .<>";
3455  }
3456  pDlg->SetForbiddenChars(sForbiddenChars);
3457  pDlg->Execute();
3458  }
3459 }
3460 
3462 {
3464 
3465  bool bSel = false;
3466  switch(pCnt->GetParent()->GetType())
3467  {
3468  case ContentTypeId::OUTLINE :
3469  {
3470  m_pActiveShell->GotoOutline(static_cast<SwOutlineContent*>(pCnt)->GetOutlinePos());
3471  }
3472  break;
3473  case ContentTypeId::TABLE :
3474  {
3475  m_pActiveShell->GotoTable(pCnt->GetName());
3476  }
3477  break;
3478  case ContentTypeId::FRAME :
3479  case ContentTypeId::GRAPHIC :
3480  case ContentTypeId::OLE :
3481  {
3482  if(m_pActiveShell->GotoFly(pCnt->GetName()))
3483  bSel = true;
3484  }
3485  break;
3487  {
3488  m_pActiveShell->GotoMark(pCnt->GetName());
3489  }
3490  break;
3491  case ContentTypeId::REGION :
3492  {
3493  m_pActiveShell->GotoRegion(pCnt->GetName());
3494  }
3495  break;
3497  {
3499  *static_cast<SwURLFieldContent*>(pCnt)->GetINetAttr() ))
3500  {
3501  m_pActiveShell->Right( CRSR_SKIP_CHARS, true, 1, false);
3502  m_pActiveShell->SwCursorShell::SelectTextAttr( RES_TXTATR_INETFMT, true );
3503  }
3504 
3505  }
3506  break;
3508  {
3510  }
3511  break;
3512  case ContentTypeId::INDEX:
3513  {
3514  const OUString& sName(pCnt->GetName());
3517  }
3518  break;
3519  case ContentTypeId::POSTIT:
3521  m_pActiveShell->GotoFormatField(*static_cast<SwPostItContent*>(pCnt)->GetPostIt());
3522  break;
3524  {
3526  SdrView* pDrawView = m_pActiveShell->GetDrawView();
3527  if (pDrawView)
3528  {
3529  pDrawView->SdrEndTextEdit();
3530  pDrawView->UnmarkAll();
3532  SdrPage* pPage = _pModel->GetPage(0);
3533  const size_t nCount = pPage->GetObjCount();
3534  for( size_t i=0; i<nCount; ++i )
3535  {
3536  SdrObject* pTemp = pPage->GetObj(i);
3537  if (pTemp->GetName() == pCnt->GetName())
3538  {
3539  SdrPageView* pPV = pDrawView->GetSdrPageView();
3540  if( pPV )
3541  {
3542  pDrawView->MarkObj( pTemp, pPV );
3543  }
3544  }
3545  }
3548  bSel = true;
3549  }
3550  }
3551  break;
3552  default: break;
3553  }
3554  if(bSel)
3555  {
3558  }
3559  SwView& rView = m_pActiveShell->GetView();
3560  rView.StopShellTimer();
3561  rView.GetPostItMgr()->SetActiveSidebarWin(nullptr);
3562  rView.GetEditWin().GrabFocus();
3563 
3564  // force scroll to cursor position when navigating to inactive document
3565  if(!bSel)
3566  {
3567  Point rPoint = m_pActiveShell->GetCursorDocPos();
3568  rPoint.setX(0);
3569  rView.SetVisArea(rPoint);
3570  }
3571 }
3572 
3573 // Now even the matching text::Bookmark
3575  :
3576  nDocSh(0),
3577  nDefDrag( RegionMode::NONE )
3578 {
3579 }
3580 
3582  const OUString& rDesc,
3583  RegionMode nDragType,
3584  const SwDocShell* pDocSh ) :
3585  aUrl( rUrl ),
3586  aDescr(rDesc),
3587  nDocSh(reinterpret_cast<sal_IntPtr>(pDocSh)),
3588  nDefDrag( nDragType )
3589 {
3590 }
3591 
3593 {
3594  rtl_TextEncoding eSysCSet = osl_getThreadTextEncoding();
3595 
3596  OString sStrBuf(OUStringToOString(aUrl, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) +
3597  OUStringToOString(aDescr, eSysCSet) + OString(NAVI_BOOKMARK_DELIM) +
3598  OString::number(static_cast<int>(nDefDrag)) + OString(NAVI_BOOKMARK_DELIM) +
3599  OString::number(nDocSh));
3600  rData.CopyByteString(SotClipboardFormatId::SONLK, sStrBuf);
3601 }
3602 
3604 {
3605  OUString sStr;
3606  bool bRet = rData.GetString( SotClipboardFormatId::SONLK, sStr );
3607  if( bRet )
3608  {
3609  sal_Int32 nPos = 0;
3610  aUrl = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
3611  aDescr = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos );
3612  nDefDrag= static_cast<RegionMode>( sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32() );
3613  nDocSh = sStr.getToken(0, NAVI_BOOKMARK_DELIM, nPos ).toInt32();
3614  }
3615  return bRet;
3616 }
3617 
3619 {
3620 public:
3621  explicit SwContentLBoxString(const OUString& rStr) : SvLBoxString(rStr) {}
3622 
3623  virtual void Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
3624  const SvViewDataEntry* pView, const SvTreeListEntry& rEntry) override;
3625 };
3626 
3628  const OUString& rStr ,const Image& rImg1,const Image& rImg2,
3629  SvLBoxButtonKind eButtonKind)
3630 {
3631  const size_t nColToHilite = 1; //0==Bitmap;1=="Column1";2=="Column2"
3632  SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2, eButtonKind );
3633  SvLBoxString& rCol = static_cast<SvLBoxString&>(pEntry->GetItem( nColToHilite ));
3634  pEntry->ReplaceItem(std::make_unique<SwContentLBoxString>(rCol.GetText()), nColToHilite);
3635 }
3636 
3637 void SwContentLBoxString::Paint(const Point& rPos, SvTreeListBox& rDev, vcl::RenderContext& rRenderContext,
3638  const SvViewDataEntry* pView, const SvTreeListEntry& rEntry)
3639 {
3640  if (lcl_IsContent(&rEntry) && static_cast<SwContent *>(rEntry.GetUserData())->IsInvisible())
3641  {
3642  vcl::Font aOldFont(rRenderContext.GetFont());
3643  vcl::Font aFont(aOldFont);
3644  aFont.SetColor(COL_LIGHTGRAY);
3645  rRenderContext.SetFont(aFont );
3646  rRenderContext.DrawText(rPos, GetText());
3647  rRenderContext.SetFont(aOldFont);
3648  }
3649  else
3650  {
3651  SvLBoxString::Paint(rPos, rDev, rRenderContext, pView, rEntry);
3652  }
3653 }
3654 
3656 {
3657  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
3658  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
3659  {
3661 
3662  Display(true);
3663  }
3664 
3665  SvTreeListBox::DataChanged( rDCEvt );
3666 }
3667 
3669 {
3670  return m_xDialog;
3671 }
3672 
3673 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool Expand(SvTreeListEntry *pParent) override
Expand - Remember the state for content types.
Definition: content.cxx:1470
static const char * STR_CONTENT_TYPE_ARY[]
Definition: content.cxx:213
SfxViewFrame * GetViewFrame() const
long Width() const
void StopShellTimer()
Definition: view.cxx:1759
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)
Base class for the following contact objects (frame + draw objects).
Definition: dcontact.hxx:66
void FillMemberList(bool *pbLevelChanged=nullptr)
Fill the List of contents.
Definition: content.cxx:520
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
void Init(bool *pbInvalidateWindow=nullptr)
Definition: content.cxx:283
ContentTypeId
Definition: swcont.hxx:28
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: content.cxx:2589
static void SetInDrag(bool bSet)
Definition: conttree.hxx:166
virtual bool IsProtect() const override
Definition: content.cxx:200
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 * >())
bool Right(sal_uInt16 nMode, bool bSelect, sal_uInt16 nCount, bool bBasicCall, bool bVisual=false)
Definition: move.cxx:119
void HideFocus()
SvTreeListEntry * NextSelected(SvTreeListEntry *pEntry) const
void CopyINetBookmark(const INetBookmark &rBkmk)
void SetSublistDontOpenWithDoubleClick(bool bDontOpen)
#define KEY_DELETE
size_t GetTableFrameFormatCount(bool bUsed=false) const
TABLE.
Definition: edfmt.cxx:103
#define FN_EDIT_REGION
Definition: cmdid.h:107
OUString m_sTypeToken
Definition: content.hxx:146
Marks a position in the document model.
Definition: pam.hxx:35
virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally=false)
OBJ_CUSTOMSHAPE
OUString const m_sPostItHide
Definition: conttree.hxx:89
SdrView * GetDrawView()
Definition: vnew.cxx:376
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: content.cxx:2761
void SetUserData(void *pPtr)
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:185
void MoveOutline(SwOutlineNodes::size_type nSource, SwOutlineNodes::size_type nTarget, bool bWithCilds)
Definition: navipi.cxx:100
virtual sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt) override
Definition: content.cxx:1144
#define KEY_SPACE
ContentTypeId m_nRootType
Definition: conttree.hxx:100
virtual void DragFinished(sal_Int8 nDropAction)
OUString GetTitle(sal_uInt16 nMaxLen=0) const
#define DND_ACTION_COPY
SwView * GetActiveView()
Definition: swmodul1.cxx:123
long AdjustX(long nHorzMove)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
virtual void DragFinished(sal_Int8) override
Definition: content.cxx:1105
void SetRegionDropMode(RegionMode nNewMode)
Definition: navipi.cxx:1128
void SetHiddenShell(SwWrtShell *pSh)
After a file is dropped on the Navigator, the new shell will be set.
Definition: content.cxx:2275
bool IsProtect() const
Definition: atrfld.cxx:335
virtual OUString getOutlineText(const tSortedOutlineNodeList::size_type nIdx, SwRootFrame const *pLayout, const bool bWithNumber=true, const bool bWithSpacesForLevel=false, const bool bWithFootnote=true) const =0
OUString m_aContextStrings[CONTEXT_COUNT+1]
Definition: conttree.hxx:81
virtual SvTreeListEntry * InsertEntry(const OUString &rText, SvTreeListEntry *pParent=nullptr, bool bChildrenOnDemand=false, sal_uLong nPos=TREELIST_APPEND, void *pUserData=nullptr, SvLBoxButtonKind eButtonKind=SvLBoxButtonKind::EnabledCheckbox)
signed char sal_Int8
SvTreeList * GetModel() const
virtual void RequestHelp(const HelpEvent &rHEvt) override
Definition: content.cxx:2952
void GotoContent(SwContent *pCnt)
Definition: content.cxx:3461
void ShowActualView()
Definition: content.cxx:3186
std::vector< SwNode * >::difference_type difference_type
SwWrtShell * m_pHiddenShell
Definition: conttree.hxx:92
const IDocumentOutlineNodes * getIDocumentOutlineNodesAccess() const
Definition: viewsh.cxx:2615
OBJ_TEXT
virtual void Paint(const Point &rPos, SvTreeListBox &rOutDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry) override
SfxDispatcher * GetDispatcher()
bool IsReadOnly(const OUString &rURL, bool *pbExist)
const_iterator begin() const
Definition: PostItMgr.hxx:182
const Size & GetSize(const SvTreeListBox *pView, const SvTreeListEntry *pEntry) const
void SetDoubleClickHdl(const Link< SvTreeListBox *, bool > &rNewHdl)
bool HasContentChanged()
Check if the displayed content is valid.
Definition: content.cxx:2031
sal_uIntPtr sal_uLong
void SetOutlineLevel(sal_Int32 nSet)
Definition: navicfg.hxx:57
bool MakeOutlineSel(SwOutlineNodes::size_type nSttPos, SwOutlineNodes::size_type nEndPos, bool bWithChildren)
Definition: crstrvl.cxx:1180
sal_uLong GetEntryCount() const
void disposeAndClear()
virtual ~SwContentTree() override
Definition: content.cxx:906
SvLBoxItem * GetItem(SvTreeListEntry *, long nX, SvLBoxTab **ppTab)
OUString GetDescription() const
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:322
SwRect FindLayoutRect(const bool bPrtArea=false, const Point *pPoint=nullptr) const
Definition: atrfrm.cxx:2633
#define RES_CONTENT_VISIBLE
Definition: hintids.hxx:308
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1690
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
Provides access to the marks of a document.
virtual OUString GetDescription() const
Definition: atrfrm.cxx:2774
SdrObject * GetObj(size_t nNum) const
OBJ_PATHPOLY
virtual Size GetSizePixel() const
#define FN_FORMAT_TABLE_DLG
Definition: cmdid.h:302
size_t GetObjCount() const
virtual bool NotifyAcceptDrop(SvTreeListEntry *) override
Definition: content.cxx:2753
#define KEY_MOD1
void GotoFormatField(const SwFormatField &rField)
Definition: move.cxx:660
bool addEntry(const SwPosition &rPos)
Definition: navmgr.cxx:169
sal_Int16 nId
bool GotoINetAttr(const SwTextINetFormat &rAttr)
Definition: move.cxx:599
long GetThumbPos() const
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:233
#define DND_ACTION_COPYMOVE
sal_uInt16 GetCode() const
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
void SetActiveSidebarWin(sw::annotation::SwAnnotationWin *p)
Definition: PostItMgr.cxx:2113
virtual void Paint(const Point &rPos, SvTreeListBox &rDev, vcl::RenderContext &rRenderContext, const SvViewDataEntry *pView, const SvTreeListEntry &rEntry) override
Definition: content.cxx:3637
void CopyByteString(SotClipboardFormatId nFormatId, const OString &rStr)
DataChangedEventType GetType() const
void EnterStdMode()
Definition: select.cxx:552
SwEditWin & GetEditWin()
Definition: view.hxx:403
OUString const m_sInvisible
Definition: conttree.hxx:87
bool m_bIsKeySpace
Definition: conttree.hxx:116
void SetCurEntry(SvTreeListEntry *_pEntry)
sal_Int8 ExecuteDrop(const ExecuteDropEvent &rEvt)
Definition: navipi.cxx:1087
VclPtr< SwNavigationPI > m_xDialog
Definition: conttree.hxx:75
bool IsTOXBaseInReadonly() const
Definition: doctxm.cxx:2020
const OUString & GetText() const
long GetPos() const
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
void SetHelpId(const OString &)
virtual bool Select(SvTreeListEntry *pEntry, bool bSelect=true) override
Definition: content.cxx:3194
OBJ_POLY
OBJ_FREEFILL
#define FN_FORMAT_GRAFIC_DLG
Definition: cmdid.h:301
SvTreeListEntry * GetCurEntry() const
sal_uInt8 GetOutlineLevel() const
Definition: conttree.hxx:204
void EndAllAction()
Definition: edws.cxx:96
void HideTree()
folded together will not be glidled
Definition: content.cxx:2598
virtual bool GetInfo(SfxPoolItem &) const override
Definition: calbck.cxx:206
#define FN_EDIT_FIELD
Definition: cmdid.h:69
bool GotoTable(const OUString &rName)
Definition: move.cxx:651
int GetActualListLevel() const
Returns the actual list level of this text node, when it is a list item.
Definition: ndtxt.cxx:4097
virtual void InitEntry(SvTreeListEntry *, const OUString &, const Image &, const Image &, SvLBoxButtonKind) override
Definition: content.cxx:3627
HelpEventMode GetMode() const
OUString const m_sUnprotTable
Definition: conttree.hxx:84
OBJ_PLIN
SfxHintId GetId() const
OBJ_RECT
static bool IsTOXBaseReadonly(const SwTOXBase &rTOXBase)
Definition: edtox.cxx:99
void EnableContextMenuHandling()
void UpdateListBox()
Definition: navipi.cxx:946
bool IsProtect() const
Definition: txtatr2.cxx:187
void SetVisArea(const tools::Rectangle &, bool bUpdateScrollbar=true)
Definition: viewport.cxx:209
bool DelRight()
Definition: delete.cxx:292
OUString GetEntryLongDescription(SvTreeListEntry *pEntry) const override
Definition: content.cxx:1010
void SetUpdateMode(bool)
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
void GetINetAttrs(SwGetINetAttrs &rArr)
Definition: editsh.cxx:693
IDocumentDrawModelAccess const & getIDocumentDrawModelAccess() const
Definition: doc.cxx:187
tools::Rectangle m_aOldRectangle
Definition: conttree.hxx:117
void MakeVisible(SvTreeListEntry *pEntry)
#define NAVI_BOOKMARK_DELIM
Definition: content.cxx:106
virtual TriState NotifyMoving(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uLong &rNewChildPos) override
Definition: content.cxx:2668
#define DND_ACTION_MOVE
sal_uLong GetAbsPos(SvTreeListEntry const *pEntry) const
SwNavigationMgr & GetNavigationMgr()
Definition: wrtsh.hxx:466
sal_uInt16 GetRefMarks(std::vector< OUString > *=nullptr) const
get the names of all references in a Doc
Definition: editsh.cxx:453
Used by the UI to modify the document model.
Definition: wrtsh.hxx:86
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
weld::Window * GetFrameWeld() const
ContentTypeId GetType() const
Definition: content.hxx:165
sal_uInt16 GetClicks() const
sal_uInt8 m_nOutlineLevel
Definition: conttree.hxx:102
static const char * STR_CONTEXT_ARY[]
Definition: content.cxx:836
OBJ_PATHPLIN
std::vector< SwFrameFormat const * > GetFlyFrameFormats(FlyCntType eType, bool bIgnoreTextBoxes)
Definition: feshview.cxx:2593
const OUString & GetValue() const
Definition: fmtinfmt.hxx:75
vcl::Window & GetWindow() const
void FindActiveTypeAndRemoveUserData()
Before any data will be deleted, the last active entry has to be found.
Definition: content.cxx:2251
virtual bool IsVisibleLayerId(SdrLayerID _nLayerId) const =0
method to determine, if a layer ID belongs to the visible ones.
bool GotoFly(const OUString &rName, FlyCntType eType=FLYCNTTYPE_ALL, bool bSelFrame=true)
Definition: move.cxx:590
const SwView & GetView() const
Definition: wrtsh.hxx:424
bool GotoNextTOXBase(const OUString *pName=nullptr)
Definition: move.cxx:642
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
void Top(const long nTop)
Definition: swrect.hxx:202
OBJ_CAPTION
void ScrollOutputArea(short nDeltaEntries)
virtual void GetFocus() override
FUNC_TYPE const nType
OUString const m_sSpace
Definition: conttree.hxx:76
#define FN_TABLE_SELECT_ALL
Definition: cmdid.h:341
SwContentType(SwWrtShell *pParent, ContentTypeId nType, sal_uInt8 nLevel)
Definition: content.cxx:268
DragDropMode
SwView * GetView()
Definition: unotxvw.hxx:136
#define KEY_MOD2
#define FN_INSERT_BOOKMARK
Definition: cmdid.h:187
void setX(long nX)
bool IsProtectedOutlinePara() const
Definition: ednumber.cxx:585
SvTreeListEntry * FirstSelected() const
const vcl::Font & GetFont() const
bool IsOutlineMovable(SwOutlineNodes::size_type nIdx) const
May an outline be moved or copied? Check whether it's in text body, not in table, and not read-only (...
Definition: ednumber.cxx:655
SwContentLBoxString(const OUString &rStr)
Definition: content.cxx:3621
void SetDragDropMode(DragDropMode)
virtual DragDropMode NotifyStartDrag(TransferDataContainer &rData, SvTreeListEntry *) override
Definition: content.cxx:2648
const OUString & GetName() const
Definition: format.hxx:111
virtual void KeyInput(const KeyEvent &rKEvt) override
std::vector< SwGetINetAttr > SwGetINetAttrs
Definition: editsh.hxx:128
bool Paste(TransferableDataHelper &rData)
Definition: content.cxx:3603
sal_Int32 GetActiveBlock() const
Definition: navicfg.hxx:74
bool GotoPrevTOXBase(const OUString *=nullptr)
jump to previous index
Definition: crstrvl.cxx:314
#define DND_ACTION_NONE
const SwTOXBase * GetTOX(sal_uInt16 nPos) const
Definition: edtox.cxx:233
TreeListBox for content indicator.
Definition: conttree.hxx:71
AllSettingsFlags GetFlags() const
SvTreeListEntry * NextSibling() const
void ToggleTree()
Definition: navipi.cxx:1149
const sal_uInt8 MAXLEVEL
Definition: swtypes.hxx:95
OBJ_PATHLINE
size_t GetMemberCount() const
Definition: content.hxx:163
virtual void InitEntry(SvTreeListEntry *, const OUString &, const Image &, const Image &, SvLBoxButtonKind)
OUString const m_sUpdateIdx
Definition: conttree.hxx:83
sal_uInt16 GetModifier() const
SwContent(const SwContentType *pCnt, const OUString &rName, long nYPos)
Definition: content.cxx:176
SwOutlineNodes::size_type GetOutlinePos() const
Definition: content.hxx:52
SwDoc * GetDoc() const
Definition: viewsh.hxx:284
void GetGrfNms(OUString *pGrfName, OUString *pFltName, const SwFlyFrameFormat *=nullptr) const
Returns the name and the filter name of a graphic if the pointer is on a graphic. ...
Definition: editsh.cxx:310
OUString GetObjTitle() const
Definition: atrfrm.cxx:3101
const IDocumentMarkAccess * getIDocumentMarkAccess() const
Provides access to the document bookmark interface.
Definition: viewsh.cxx:2592
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
void SetOutlineLevel(sal_uInt8 nSet)
Definition: content.cxx:3158
void UnmarkAll()
const IDocumentDrawModelAccess & getIDocumentDrawModelAccess() const
Provides access to the document draw model interface.
Definition: viewsh.cxx:2594
OBJ_SECT
size_type size() const
sal_Int8 AcceptDrop()
Definition: navipi.cxx:1072
css::uno::Reference< css::frame::XModel > GetBaseModel() const
const SwSectionFormat & GetSectionFormat(size_t nFormat) const
Definition: edsect.cxx:142
UNKNOWN
virtual tools::Rectangle GetFocusRect(SvTreeListEntry *, long nLine)
sal_Int32 m_nActiveBlock
Definition: conttree.hxx:98
void EditEntry(SvTreeListEntry const *pEntry, EditEntryMode nMode)
Definition: content.cxx:3247
void ToggleToRoot()
Switch the display to Root.
Definition: content.cxx:1982
sal_Int32 m_nHiddenBlock
Definition: conttree.hxx:99
bool m_bDocChgdInDragging
Definition: conttree.hxx:106
OUString GetEntryAltText(SvTreeListEntry *pEntry) const override
Definition: content.cxx:926
const Point & GetMousePosPixel() const
SvLBoxButtonKind
SwOutlineNodes::size_type GetOutlinePos(sal_uInt8 nLevel=UCHAR_MAX)
search "outline position" before previous outline node at given level
Definition: crstrvl.cxx:1157
const css::uno::Reference< css::frame::XController2 > & GetController() const
static bool bIsInDrag
Definition: conttree.hxx:114
void SetActiveShell(SwWrtShell *pSh)
Document change - set new Shell.
Definition: content.cxx:2289
size_t GetFlyCount(FlyCntType eType, bool bIgnoreTextBoxes=false) const
Iterate over flys - for Basic-collections.
Definition: feshview.cxx:2583
container_t::const_iterator const_iterator_t
SvTreeListEntry * pTargetEntry
virtual bool Collapse(SvTreeListEntry *pParent) override
Collapse - Remember the state for content types.
Definition: content.cxx:1528
const_iterator end() const
Definition: PostItMgr.hxx:183
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
void SetRootType(ContentTypeId nType)
Definition: content.cxx:3227
SwNavigationConfig * m_pConfig
Definition: conttree.hxx:94
virtual SwTextNode * getOutlineNode(const tSortedOutlineNodeList::size_type nIdx) const =0
virtual ~SwTypeNumber()
Definition: content.cxx:186
#define FN_EDIT_HYPERLINK
Definition: cmdid.h:135
SwNavigationPI * GetParentWindow()
Definition: content.cxx:3668
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
void clear()
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
Definition: content.cxx:1116
OBJ_LINE
virtual ~SwContentType() override
Definition: content.cxx:499
const SwFlyFrameFormat * FindFlyByName(const OUString &rName, SwNodeType nNdTyp=SwNodeType::NONE) const
Definition: doclay.cxx:1397
Style of a layout element.
Definition: frmfmt.hxx:57
void SetRootType(ContentTypeId nSet)
Definition: navicfg.hxx:48
RegionMode GetRegionDropMode() const
Definition: navipi.hxx:151
const SwContentType * GetParent() const
Definition: swcont.hxx:83
#define SW_MOD()
Definition: swmodule.hxx:255
virtual VclPtr< PopupMenu > CreateContextMenu() override
Definition: content.cxx:1176
static constexpr auto npos
Definition: ndarr.hxx:80
sal_uLong GetAbsPos(const SvTreeListEntry *pEntry) const
static OUString CleanEntry(const OUString &rEntry)
Definition: navipi.cxx:85
#define HID_NAVIGATOR_TREELIST
Definition: helpids.h:36
OUString const m_sReadonlyIdx
Definition: conttree.hxx:86
bool Remove(const SvTreeListEntry *pEntry)
void ToTop(ToTopFlags nFlags=ToTopFlags::NONE)
const OUString & GetSectionName() const
Definition: section.hxx:169
const SwPosition * GetPoint() const
Definition: pam.hxx:207
OUString GetURLNoMark(DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:229
OBJ_GRUP
virtual sal_uInt16 GetObjIdentifier() const
ScrollBar * GetVScroll()
RegionMode
Definition: swcont.hxx:51
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:59
SwFrameFormat * GetFormat()
Definition: dcontact.hxx:112
OUString Apply(const OUString &rStr) const
Definition: SwRewriter.cxx:43
static void * lcl_GetOutlineKey(SwContentTree *pTree, SwOutlineContent const *pContent)
Definition: content.cxx:1131
FlyCntType
Definition: flyenum.hxx:23
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2143
const SwTextINetFormat & rINetAttr
Definition: editsh.hxx:122
bool GetString(SotClipboardFormatId nFormat, OUString &rStr)
OUString sName
bool ActionPend() const
Definition: viewsh.hxx:199
int i
#define KEY_ESCAPE
TRISTATE_FALSE
OUString const m_sRename
Definition: conttree.hxx:85
std::shared_ptr< ::sw::mark::IMark > pMark_t
virtual int getOutlineLevel(const tSortedOutlineNodeList::size_type nIdx) const =0
const SdrPage * GetPage(sal_uInt16 nPgNum) const
Content type, knows it's contents and the WrtShell.
Definition: content.hxx:139
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:222
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
#define CTYPE_CNT
Definition: content.cxx:97
SvTreeListEntry * FirstChild(SvTreeListEntry *pParent) const
void * GetUserData() const
RegionMode nDefDrag
Definition: navicont.hxx:39
OString stripStart(const OString &rIn, sal_Char c)
sal_uInt16 GetTOXCount() const
Definition: edtox.cxx:219
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
virtual bool IsProtect() const
Definition: content.cxx:190
OUString GetTitle() const
enum SwContentTree::State m_eState
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
virtual tSortedOutlineNodeList::size_type getOutlineNodesCount() const =0
bool m_bViewHasChanged
Definition: conttree.hxx:112
virtual ~SwGraphicContent() override
Definition: content.cxx:205
virtual TriState NotifyCopying(SvTreeListEntry *pTarget, SvTreeListEntry *pEntry, SvTreeListEntry *&rpNewParent, sal_uLong &rNewChildPos) override
Definition: content.cxx:2711
virtual bool Collapse(SvTreeListEntry *pParent)
virtual void Start() override
static SwView * GetFirstView()
Definition: swmodul1.cxx:129
Link< sal_Int8, void > GetDragFinishedHdl() const
const SwTextINetFormat * pINetAttr
Definition: content.hxx:75
OUString const sText
Definition: editsh.hxx:121
VclPtr< SwNavHelpToolBox > m_aContentToolBox
Definition: navipi.hxx:71
size
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
Display
void Hide(const OUString &rAuthor)
Definition: PostItMgr.cxx:1659
const OUString & GetEventName() const
sal_uInt8 m_nOutlineLevel
Definition: content.hxx:149
bool HasName() const
SwNumberTree::tNumberVector GetNumberVector(SwRootFrame const *pLayout=nullptr) const
Definition: ndtxt.cxx:3989
std::unique_ptr< SwContentArr > m_pMember
Definition: content.hxx:143
void StartListening(SfxBroadcaster &rBroadcaster, DuplicateHandling eDuplicateHanding=DuplicateHandling::Unexpected)
void SetNodeDefaultImages()
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
SectionType
Definition: section.hxx:46
sal_uInt16 GetStart() const
virtual void ExecuteContextMenuAction(sal_uInt16 nSelectedPopupEntry) override
Definition: content.cxx:3063
#define DND_ACTION_LINK
virtual OUString GetEntryText(SvTreeListEntry *pEntry) const
const SvLBoxItem & GetItem(size_t nPos) const
DragDropMode GetDragDropMode() const
virtual bool Expand(SvTreeListEntry *pParent)
static const char * STR_CONTENT_TYPE_SINGLE_ARY[]
Definition: content.cxx:229
OUString const m_sRemoveIdx
Definition: conttree.hxx:82
DocumentType const eType
const SwNumRule * GetOutlineNumRule() const
Definition: ednumber.cxx:120
const sal_Unicode cMarkSeparator
Definition: swtypes.hxx:137
void SetTimeout(sal_uInt64 nTimeoutMs)
Point ScreenToOutputPixel(const Point &rPos) const
void GrabFocus()
#define RES_TXTATR_INETFMT
Definition: hintids.hxx:141
static void ShowQuickHelp(vcl::Window *pParent, const tools::Rectangle &rScreenRect, const OUString &rHelpText, QuickHelpFlags nStyle=QuickHelpFlags::NONE)
virtual void ShowFocus(const tools::Rectangle &rRect)
vcl::Window * GetParent() const
long X() const
virtual bool isOutlineInLayout(tSortedOutlineNodeList::size_type nIdx, SwRootFrame const &rLayout) const =0
static bool IsBalloonHelpEnabled()
void Invalidate()
Definition: content.cxx:515
OUString GetName() const
SwDocShell * GetDocShell()
Definition: view.cxx:1115
void EnableItem(sal_uInt16 nItemId, bool bEnable=true)
bool IsReadOnly() const
Point GetEntryPosition(SvTreeListEntry *) const
void CheckItem(sal_uInt16 nItemId, bool bCheck=true)
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: content.cxx:3655
SwSectionFormat * GetParent() const
Definition: section.hxx:356
virtual SdrLayerID GetLayer() const
virtual SvLBoxItemType GetType() const =0
void SetTOXBaseReadonly(const SwTOXBase &rTOXBase, bool bReadonly)
Definition: edtox.cxx:106
std::vector< tSwNumTreeNumber > tNumberVector
Point LogicToPixel(const Point &rLogicPt) const
void StartAction()
Definition: crsrsh.cxx:212
SvTreeListEntry * Next(SvTreeListEntry *pEntry) const
SwView * GetCreateView() const
Definition: navipi.cxx:1211
void ReleaseMouse()
EditEntryMode
Definition: conttree.hxx:44
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
IMPL_LINK_NOARG(SwContentTree, ContentDoubleClickHdl, SvTreeListBox *, bool)
Definition: content.cxx:1563
#define KEY_RETURN
bool IsExpanded(SvTreeListEntry *pEntry) const
ContentTypeId const m_nContentType
Definition: content.hxx:148
const SwNumFormat & Get(sal_uInt16 i) const
Definition: number.cxx:83
SvTreeListEntry * First() const
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed=false) const
Definition: edfmt.cxx:108
OBJ_FREELINE
bool OutlineUpDown(short nOffset=1)
Definition: ednumber.cxx:553
#define FN_FORMAT_FRAME_DLG
Definition: cmdid.h:300
size_t GetSectionFormatCount() const
Definition: edsect.cxx:114
bool m_bIsLastReadOnly
Definition: conttree.hxx:110
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE) override
virtual void Notify(SfxBroadcaster &rBC, const SfxHint &rHint)
bool HasChildren() const
void InsertItem(sal_uInt16 nItemId, const OUString &rStr, MenuItemBits nItemBits=MenuItemBits::NONE, const OString &rIdent=OString(), sal_uInt16 nPos=MENU_APPEND)
OBJ_CARC
void GotoMark(const ::sw::mark::IMark *const pMark)
Definition: wrtsh3.cxx:138
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
sal_uInt16 GetChildCount() const
const vcl::KeyCode & GetKeyCode() const
For querying the INet-attributes for Navigator.
Definition: editsh.hxx:119
bool m_bDelete
Definition: content.hxx:152
void AssureStdModeAtShell()
Definition: PostItMgr.cxx:2261
void SetSelectionMode(SelectionMode)
virtual sal_Int8 AcceptDrop(const AcceptDropEvent &rEvt) override
SwWrtShell * GetWrtShellPtr() const
Definition: view.hxx:401
SfxDispatcher * GetDispatcher()
AutoTimer m_aUpdTimer
Definition: conttree.hxx:77
void Stop()
OBJ_CCUT
bool FillTransferData(TransferDataContainer &rTransfer, sal_Int8 &rDragMode)
Definition: content.cxx:1845
static OUString RemoveNewline(const OUString &)
Definition: content.cxx:3234
const OUString & GetName() const
Definition: swcont.hxx:84
virtual void Notify(SfxBroadcaster &rBC, SfxHint const &rHint) override
Definition: content.cxx:2341
#define SAL_WARN_IF(condition, area, stream)
virtual Size GetOptimalSize() const override
Definition: content.cxx:921
void Copy(TransferDataContainer &rData) const
Definition: content.cxx:3592
unsigned char sal_uInt8
o3tl::enumarray< ContentTypeId, std::unique_ptr< SwContentType > > m_aActiveContentArr
Definition: conttree.hxx:79
bool IsNumbered(SwRootFrame const *pLayout=nullptr) const
Returns is this text node is numbered.
Definition: ndtxt.cxx:2889
void SetFont(const vcl::Font &rNewFont)
#define FN_OUTLINE_TO_CLIPBOARD
Definition: cmdid.h:64
SdrObject * GetDrawingObjectsByContent(const SwContent *pCnt)
Definition: content.cxx:1438
OUString const m_sPostItDelete
Definition: conttree.hxx:90
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
SwWrtShell * m_pActiveShell
Definition: conttree.hxx:93
bool IsVisible() const
void ReplaceItem(std::unique_ptr< SvLBoxItem > pNewItem, size_t nPos)
virtual ~SwTOXBaseContent() override
Definition: content.cxx:209
std::vector< std::unique_ptr< SwSidebarItem > >::const_iterator const_iterator
Definition: PostItMgr.hxx:181
void SetInvisible()
Definition: swcont.hxx:99
bool IsLeft() const
SvTreeListEntry * GetEntry(SvTreeListEntry *pParent, sal_uLong nPos) const
void ShowTree()
Definition: content.cxx:2584
static VclPtr< reference_type > Create(Arg &&...arg)
void EndListening(SfxBroadcaster &rBroadcaster, bool bRemoveAllDuplicates=false)
void InvalidateEntry(SvTreeListEntry *)
size_t m_nMemberCount
Definition: content.hxx:147
SwPostItMgr * GetPostItMgr()
Definition: view.hxx:621
void GotoOutline(SwOutlineNodes::size_type nIdx)
Definition: move.cxx:608
const INetURLObject & GetURLObject() const
virtual void GetFocus() override
Definition: content.cxx:2781
bool GotoRefMark(const OUString &rRefMark, sal_uInt16 nSubType=0, sal_uInt16 nSeqNo=0)
Definition: move.cxx:632
void SetInvokeHandler(const Link< Timer *, void > &rLink)
const Point & GetPosPixel() const
std::map< void *, bool > mOutLineNodeMap
Definition: conttree.hxx:96
void ClearMark()
Definition: crsrsh.cxx:927
const SvxPageUsage aArr[]
#define CTYPE_CTT
Definition: content.cxx:98
ContentTypeId m_nLastSelType
Definition: conttree.hxx:101
virtual bool GetInfo(SfxPoolItem &rInfo) const override
Definition: doctxm.cxx:2059
virtual void StartDrag(sal_Int8 nAction, const Point &rPosPixel) override
Definition: content.cxx:1086
static SwView * GetNextView(SwView const *)
Definition: swmodul1.cxx:136
SdrPageView * GetSdrPageView() const
bool m_bDataValid
Definition: content.hxx:150
virtual std::shared_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark)=0
Deletes a mark.
virtual void RequestingChildren(SvTreeListEntry *pParent) override
Definition: content.cxx:1370
virtual void dispose() override
bool m_bIsInternalDrag
Definition: conttree.hxx:107
virtual void dispose() override
Definition: content.cxx:911
WindowType GetType() const
sal_uInt16 GetItemId(ImplToolItems::size_type nPos) const
OUString const m_sPostItShow
Definition: conttree.hxx:88
SwWrtShell * GetWrtShell()
Definition: conttree.hxx:199
const sal_uInt16 CRSR_SKIP_CHARS
Definition: swcrsr.hxx:63
virtual bool IsProtect() const override
Definition: content.cxx:195
void ShowHiddenShell()
Definition: content.cxx:3175
#define SAL_WARN(area, stream)
void * pObject
Definition: hints.hxx:53
Reference< XModel > xModel
void Clear()
In the Clear the content types have to be deleted, also.
Definition: content.cxx:1838
STR_CONTEXT_IDX
Definition: content.cxx:819
bool MarkObj(const Point &rPnt, short nTol=-2, bool bToggle=false, bool bDeep=false)
void EnterSelFrameMode(const Point *pStartDrag=nullptr)
Definition: select.cxx:703
Point OutputToScreenPixel(const Point &rPos) const
void ExecCommand(const OUString &rCmd, bool bModifier)
Execute commands of the Navigator.
Definition: content.cxx:2378
virtual bool Select(SvTreeListEntry *pEntry, bool bSelect=true)
bool IsOutlineCopyable(SwOutlineNodes::size_type nIdx) const
Definition: ednumber.cxx:660
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
virtual bool GetInfo(SfxPoolItem &) const override
Definition: section.cxx:840
void SetConstantShell(SwWrtShell *pSh)
Set an open view as active.
Definition: content.cxx:2325
SectionType GetType() const
Definition: section.hxx:171
const SwFormatField * pField
Definition: content.hxx:93
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: content.cxx:2805
const SwContent * GetMember(size_t nIndex)
Deliver content, for that if necessary fill the list.
Definition: content.cxx:503
bool MoveOutlinePara(SwOutlineNodes::difference_type nOffset)
Definition: ednumber.cxx:576
void Display(bool bActiveView)
Show the file.
Definition: content.cxx:1647
SwSection * GetSection() const
Definition: section.cxx:675
std::pair< const_iterator, bool > insert(Value &&x)
std::vector< SwNode * >::size_type size_type
SwContentTree(vcl::Window *pParent, SwNavigationPI *pDialog)
Definition: content.cxx:853
bool IsInvisible() const
Definition: swcont.hxx:98