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