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