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