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