LibreOffice Module sw (master)  1
docbm.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 <memory>
21 #include <utility>
22 
23 #include <MarkManager.hxx>
24 #include <bookmrk.hxx>
25 #include <crossrefbookmark.hxx>
26 #include <crsrsh.hxx>
27 #include <annotationmark.hxx>
28 #include <doc.hxx>
30 #include <IDocumentState.hxx>
31 #include <IDocumentUndoRedo.hxx>
32 #include <docary.hxx>
33 #include <xmloff/odffields.hxx>
34 #include <mvsave.hxx>
35 #include <ndtxt.hxx>
36 #include <node.hxx>
37 #include <pam.hxx>
38 #include <redline.hxx>
39 #include <rolbck.hxx>
40 #include <rtl/ustring.hxx>
41 #include <sal/types.h>
42 #include <sal/log.hxx>
43 #include <UndoBookmark.hxx>
44 #include <tools/datetimeutils.hxx>
45 #include <view.hxx>
46 
47 #include <libxml/xmlstring.h>
48 #include <libxml/xmlwriter.h>
49 
50 using namespace ::sw::mark;
51 
52 std::vector<::sw::mark::MarkBase*>::const_iterator const&
54 {
55  return *m_pIter;
56 }
57 
58 IDocumentMarkAccess::iterator::iterator(std::vector<::sw::mark::MarkBase*>::const_iterator const& rIter)
59  : m_pIter(new std::vector<::sw::mark::MarkBase*>::const_iterator(rIter))
60 {
61 }
62 
64  : m_pIter(new std::vector<::sw::mark::MarkBase*>::const_iterator(*rOther.m_pIter))
65 {
66 }
67 
69 {
70  m_pIter.reset(new std::vector<::sw::mark::MarkBase*>::const_iterator(*rOther.m_pIter));
71  return *this;
72 }
73 
75  : m_pIter(std::move(rOther.m_pIter))
76 {
77 }
78 
80 {
81  m_pIter = std::move(rOther.m_pIter);
82  return *this;
83 }
84 
86 {
87 }
88 
89 // ARGH why does it *need* to return const& ?
90 ::sw::mark::IMark* /*const&*/
92 {
93  return static_cast<sw::mark::IMark*>(**m_pIter);
94 }
95 
97 {
98  ++(*m_pIter);
99  return *this;
100 }
102 {
103  iterator tmp(*this);
104  ++(*m_pIter);
105  return tmp;
106 }
107 
109 {
110  return *m_pIter == *rOther.m_pIter;
111 }
112 
114 {
115  return *m_pIter != *rOther.m_pIter;
116 }
117 
119  : m_pIter(new std::vector<::sw::mark::MarkBase*>::const_iterator())
120 {
121 }
122 
124 {
125  --(*m_pIter);
126  return *this;
127 }
128 
130 {
131  iterator tmp(*this);
132  --(*m_pIter);
133  return tmp;
134 }
135 
137 {
138  (*m_pIter) += n;
139  return *this;
140 }
141 
143 {
144  return iterator(*m_pIter + n);
145 }
146 
148 {
149  (*m_pIter) -= n;
150  return *this;
151 }
152 
154 {
155  return iterator(*m_pIter - n);
156 }
157 
159 {
160  return *m_pIter - *rOther.m_pIter;
161 }
162 
164 {
165  return static_cast<sw::mark::IMark*>((*m_pIter)[n]);
166 }
167 
169 {
170  return *m_pIter < *rOther.m_pIter;
171 }
173 {
174  return *m_pIter > *rOther.m_pIter;
175 }
177 {
178  return *m_pIter <= *rOther.m_pIter;
179 }
181 {
182  return *m_pIter >= *rOther.m_pIter;
183 }
184 
185 
186 namespace
187 {
188  bool lcl_GreaterThan( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const SwIndex* pIdx )
189  {
190  return pIdx != nullptr
191  ? ( rPos.nNode > rNdIdx
192  || ( rPos.nNode == rNdIdx
193  && rPos.nContent >= pIdx->GetIndex() ) )
194  : rPos.nNode >= rNdIdx;
195  }
196 
197  bool lcl_Lower( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const SwIndex* pIdx )
198  {
199  return rPos.nNode < rNdIdx
200  || ( pIdx != nullptr
201  && rPos.nNode == rNdIdx
202  && rPos.nContent < pIdx->GetIndex() );
203  }
204 
205  bool lcl_MarkOrderingByStart(const ::sw::mark::MarkBase *const pFirst,
206  const ::sw::mark::MarkBase *const pSecond)
207  {
208  auto const& rFirstStart(pFirst->GetMarkStart());
209  auto const& rSecondStart(pSecond->GetMarkStart());
210  if (rFirstStart.nNode != rSecondStart.nNode)
211  {
212  return rFirstStart.nNode < rSecondStart.nNode;
213  }
214  const sal_Int32 nFirstContent = rFirstStart.nContent.GetIndex();
215  const sal_Int32 nSecondContent = rSecondStart.nContent.GetIndex();
216  if (nFirstContent != 0 || nSecondContent != 0)
217  {
218  return nFirstContent < nSecondContent;
219  }
220  auto *const pCRFirst (dynamic_cast<::sw::mark::CrossRefBookmark const*>(pFirst));
221  auto *const pCRSecond(dynamic_cast<::sw::mark::CrossRefBookmark const*>(pSecond));
222  if ((pCRFirst == nullptr) == (pCRSecond == nullptr))
223  {
224  return false; // equal
225  }
226  return pCRFirst != nullptr; // cross-ref sorts *before*
227  }
228 
229  bool lcl_MarkOrderingByEnd(const ::sw::mark::MarkBase *const pFirst,
230  const ::sw::mark::MarkBase *const pSecond)
231  {
232  return pFirst->GetMarkEnd() < pSecond->GetMarkEnd();
233  }
234 
235  void lcl_InsertMarkSorted(MarkManager::container_t& io_vMarks,
236  ::sw::mark::MarkBase *const pMark)
237  {
238  io_vMarks.insert(
239  lower_bound(
240  io_vMarks.begin(),
241  io_vMarks.end(),
242  pMark,
243  &lcl_MarkOrderingByStart),
244  pMark);
245  }
246 
247  std::unique_ptr<SwPosition> lcl_PositionFromContentNode(
248  SwContentNode * const pContentNode,
249  const bool bAtEnd)
250  {
251  std::unique_ptr<SwPosition> pResult(new SwPosition(*pContentNode));
252  pResult->nContent.Assign(pContentNode, bAtEnd ? pContentNode->Len() : 0);
253  return pResult;
254  }
255 
256  // return a position at the begin of rEnd, if it is a ContentNode
257  // else set it to the begin of the Node after rEnd, if there is one
258  // else set it to the end of the node before rStt
259  // else set it to the ContentNode of the Pos outside the Range
260  std::unique_ptr<SwPosition> lcl_FindExpelPosition(
261  const SwNodeIndex& rStt,
262  const SwNodeIndex& rEnd,
263  const SwPosition& rOtherPosition)
264  {
265  SwContentNode * pNode = rEnd.GetNode().GetContentNode();
266  bool bPosAtEndOfNode = false;
267  if ( pNode == nullptr)
268  {
269  SwNodeIndex aEnd = rEnd;
270  pNode = rEnd.GetNodes().GoNext( &aEnd );
271  bPosAtEndOfNode = false;
272  }
273  if ( pNode == nullptr )
274  {
275  SwNodeIndex aStt = rStt;
276  pNode = SwNodes::GoPrevious(&aStt);
277  bPosAtEndOfNode = true;
278  }
279  if ( pNode != nullptr )
280  {
281  return lcl_PositionFromContentNode( pNode, bPosAtEndOfNode );
282  }
283 
284  return std::make_unique<SwPosition>(rOtherPosition);
285  }
286 
287  struct CompareIMarkStartsBefore
288  {
289  bool operator()(SwPosition const& rPos,
290  const sw::mark::IMark* pMark)
291  {
292  return rPos < pMark->GetMarkStart();
293  }
294  bool operator()(const sw::mark::IMark* pMark,
295  SwPosition const& rPos)
296  {
297  return pMark->GetMarkStart() < rPos;
298  }
299  };
300 
301  // Apple llvm-g++ 4.2.1 with _GLIBCXX_DEBUG won't eat boost::bind for this
302  // Neither will MSVC 2008 with _DEBUG
303  struct CompareIMarkStartsAfter
304  {
305  bool operator()(SwPosition const& rPos,
306  const sw::mark::IMark* pMark)
307  {
308  return pMark->GetMarkStart() > rPos;
309  }
310  };
311 
312 
313  IMark* lcl_getMarkAfter(const MarkManager::container_t& rMarks, const SwPosition& rPos)
314  {
315  auto const pMarkAfter = upper_bound(
316  rMarks.begin(),
317  rMarks.end(),
318  rPos,
319  CompareIMarkStartsAfter());
320  if(pMarkAfter == rMarks.end())
321  return nullptr;
322  return *pMarkAfter;
323  };
324 
325  IMark* lcl_getMarkBefore(const MarkManager::container_t& rMarks, const SwPosition& rPos)
326  {
327  // candidates from which to choose the mark before
328  MarkManager::container_t vCandidates;
329  // no need to consider marks starting after rPos
330  auto const pCandidatesEnd = upper_bound(
331  rMarks.begin(),
332  rMarks.end(),
333  rPos,
334  CompareIMarkStartsAfter());
335  vCandidates.reserve(pCandidatesEnd - rMarks.begin());
336  // only marks ending before are candidates
337  remove_copy_if(
338  rMarks.begin(),
339  pCandidatesEnd,
340  back_inserter(vCandidates),
341  [&rPos] (const ::sw::mark::MarkBase *const pMark) { return !(pMark->GetMarkEnd() < rPos); } );
342  // no candidate left => we are in front of the first mark or there are none
343  if(vCandidates.empty()) return nullptr;
344  // return the highest (last) candidate using mark end ordering
345  return *max_element(vCandidates.begin(), vCandidates.end(), &lcl_MarkOrderingByEnd);
346  }
347 
348  bool lcl_FixCorrectedMark(
349  const bool bChangedPos,
350  const bool bChangedOPos,
351  MarkBase* io_pMark )
352  {
354  {
355  // annotation marks are allowed to span a table cell range.
356  // but trigger sorting to be save
357  return true;
358  }
359 
360  if ( ( bChangedPos || bChangedOPos )
361  && io_pMark->IsExpanded()
362  && io_pMark->GetOtherMarkPos().nNode.GetNode().FindTableBoxStartNode() !=
363  io_pMark->GetMarkPos().nNode.GetNode().FindTableBoxStartNode() )
364  {
365  if ( !bChangedOPos )
366  {
367  io_pMark->SetMarkPos( io_pMark->GetOtherMarkPos() );
368  }
369  io_pMark->ClearOtherMarkPos();
370  DdeBookmark * const pDdeBkmk = dynamic_cast< DdeBookmark*>(io_pMark);
371  if ( pDdeBkmk != nullptr
372  && pDdeBkmk->IsServer() )
373  {
374  pDdeBkmk->SetRefObject(nullptr);
375  }
376  return true;
377  }
378  return false;
379  }
380 
381  bool lcl_MarkEqualByStart(const ::sw::mark::MarkBase *const pFirst,
382  const ::sw::mark::MarkBase *const pSecond)
383  {
384  return !lcl_MarkOrderingByStart(pFirst, pSecond) &&
385  !lcl_MarkOrderingByStart(pSecond, pFirst);
386  }
387 
388  MarkManager::container_t::const_iterator lcl_FindMark(
389  MarkManager::container_t& rMarks,
390  const ::sw::mark::MarkBase *const pMarkToFind)
391  {
392  auto ppCurrentMark = lower_bound(
393  rMarks.begin(), rMarks.end(),
394  pMarkToFind, &lcl_MarkOrderingByStart);
395  // since there are usually not too many marks on the same start
396  // position, we are not doing a bisect search for the upper bound
397  // but instead start to iterate from pMarkLow directly
398  while (ppCurrentMark != rMarks.end() && lcl_MarkEqualByStart(*ppCurrentMark, pMarkToFind))
399  {
400  if(*ppCurrentMark == pMarkToFind)
401  {
402  return MarkManager::container_t::const_iterator(std::move(ppCurrentMark));
403  }
404  ++ppCurrentMark;
405  }
406  // reached a mark starting on a later start pos or the end of the
407  // vector => not found
408  return rMarks.end();
409  };
410 
411  MarkManager::container_t::const_iterator lcl_FindMarkAtPos(
412  MarkManager::container_t& rMarks,
413  const SwPosition& rPos,
414  const IDocumentMarkAccess::MarkType eType)
415  {
416  for (auto ppCurrentMark = lower_bound(
417  rMarks.begin(), rMarks.end(),
418  rPos,
419  CompareIMarkStartsBefore());
420  ppCurrentMark != rMarks.end();
421  ++ppCurrentMark)
422  {
423  // Once we reach a mark starting after the target pos
424  // we do not need to continue
425  if((*ppCurrentMark)->GetMarkStart() > rPos)
426  break;
427  if(IDocumentMarkAccess::GetType(**ppCurrentMark) == eType)
428  {
429  return MarkManager::container_t::const_iterator(std::move(ppCurrentMark));
430  }
431  }
432  // reached a mark starting on a later start pos or the end of the
433  // vector => not found
434  return rMarks.end();
435  };
436 
437  MarkManager::container_t::const_iterator lcl_FindMarkByName(
438  const OUString& rName,
439  const MarkManager::container_t::const_iterator& ppMarksBegin,
440  const MarkManager::container_t::const_iterator& ppMarksEnd)
441  {
442  return find_if(
443  ppMarksBegin,
444  ppMarksEnd,
445  [&rName] (::sw::mark::MarkBase const*const pMark) { return pMark->GetName() == rName; } );
446  }
447 
448  void lcl_DebugMarks(MarkManager::container_t const& rMarks)
449  {
450 #if OSL_DEBUG_LEVEL > 0
451  SAL_INFO("sw.core", rMarks.size() << " Marks");
452  for (auto ppMark = rMarks.begin();
453  ppMark != rMarks.end();
454  ++ppMark)
455  {
456  IMark* pMark = *ppMark;
457  const SwPosition* const pStPos = &pMark->GetMarkStart();
458  const SwPosition* const pEndPos = &pMark->GetMarkEnd();
459  SAL_INFO("sw.core",
460  pStPos->nNode.GetIndex() << "," <<
461  pStPos->nContent.GetIndex() << " " <<
462  pEndPos->nNode.GetIndex() << "," <<
463  pEndPos->nContent.GetIndex() << " " <<
464  typeid(*pMark).name() << " " <<
465  pMark->GetName());
466  }
467 #else
468  (void) rMarks;
469 #endif
470  assert(std::is_sorted(rMarks.begin(), rMarks.end(), lcl_MarkOrderingByStart));
471  };
472 }
473 
475 {
476  const std::type_info* const pMarkTypeInfo = &typeid(rBkmk);
477  // not using dynamic_cast<> here for performance
478  if(*pMarkTypeInfo == typeid(UnoMark))
479  return MarkType::UNO_BOOKMARK;
480  else if(*pMarkTypeInfo == typeid(DdeBookmark))
481  return MarkType::DDE_BOOKMARK;
482  else if(*pMarkTypeInfo == typeid(Bookmark))
483  return MarkType::BOOKMARK;
484  else if(*pMarkTypeInfo == typeid(CrossRefHeadingBookmark))
486  else if(*pMarkTypeInfo == typeid(CrossRefNumItemBookmark))
488  else if(*pMarkTypeInfo == typeid(AnnotationMark))
490  else if(*pMarkTypeInfo == typeid(TextFieldmark))
492  else if(*pMarkTypeInfo == typeid(CheckboxFieldmark))
494  else if(*pMarkTypeInfo == typeid(DropDownFieldmark))
496  else if(*pMarkTypeInfo == typeid(DateFieldmark))
498  else if(*pMarkTypeInfo == typeid(NavigatorReminder))
500  else
501  {
502  assert(false && "IDocumentMarkAccess::GetType(..)"
503  " - unknown MarkType. This needs to be fixed!");
504  return MarkType::UNO_BOOKMARK;
505  }
506 }
507 
509 {
510  return "__RefHeading__";
511 }
512 
514 {
515  return rPaM.Start()->nNode.GetNode().IsTextNode() &&
516  rPaM.Start()->nContent.GetIndex() == 0 &&
517  ( !rPaM.HasMark() ||
518  ( rPaM.GetMark()->nNode == rPaM.GetPoint()->nNode &&
519  rPaM.End()->nContent.GetIndex() == rPaM.End()->nNode.GetNode().GetTextNode()->Len() ) );
520 }
521 
523 {
524  if (GetType(rMark) != MarkType::TEXT_FIELDMARK)
525  {
526  return; // TODO FORMDATE has no command?
527  }
528  SwPaM pam(sw::mark::FindFieldSep(rMark), rMark.GetMarkStart());
529  ++pam.GetPoint()->nContent; // skip CH_TXT_ATR_FIELDSTART
530  pam.GetDoc()->getIDocumentContentOperations().DeleteAndJoin(pam);
531 }
532 
533 namespace sw { namespace mark
534 {
535  MarkManager::MarkManager(SwDoc& rDoc)
536  : m_vAllMarks()
537  , m_vBookmarks()
538  , m_vFieldmarks()
539  , m_vAnnotationMarks()
540  , m_pDoc(&rDoc)
541  , m_pLastActiveFieldmark(nullptr)
542  { }
543 
545  const OUString& rName,
546  const IDocumentMarkAccess::MarkType eType,
547  sw::mark::InsertMode const eMode,
548  SwPosition const*const pSepPos)
549  {
550 #if OSL_DEBUG_LEVEL > 0
551  {
552  const SwPosition* const pPos1 = rPaM.GetPoint();
553  const SwPosition* pPos2 = pPos1;
554  if(rPaM.HasMark())
555  pPos2 = rPaM.GetMark();
556  SAL_INFO("sw.core",
557  rName << " " <<
558  pPos1->nNode.GetIndex() << "," <<
559  pPos1->nContent.GetIndex() << " " <<
560  pPos2->nNode.GetIndex() << "," <<
561  pPos2->nContent.GetIndex());
562  }
563 #endif
564  // There should only be one CrossRefBookmark per Textnode per Type
566  && (lcl_FindMarkAtPos(m_vBookmarks, *rPaM.Start(), eType) != m_vBookmarks.end()))
567  { // this can happen via UNO API
568  SAL_WARN("sw.core", "MarkManager::makeMark(..)"
569  " - refusing to create duplicate CrossRefBookmark");
570  return nullptr;
571  }
572 
574  && (eMode == InsertMode::New
575  ? *rPaM.GetPoint() != *rPaM.GetMark()
576  // CopyText: pam covers CH_TXT_ATR_FORMELEMENT
577  : (rPaM.GetPoint()->nNode != rPaM.GetMark()->nNode
578  || rPaM.Start()->nContent.GetIndex() + 1 != rPaM.End()->nContent.GetIndex())))
579  {
580  SAL_WARN("sw.core", "MarkManager::makeMark(..)"
581  " - invalid range on point fieldmark");
582  return nullptr;
583  }
584 
585  // create mark
586  std::unique_ptr<::sw::mark::MarkBase> pMark;
587  switch(eType)
588  {
590  pMark = std::make_unique<TextFieldmark>(rPaM, rName);
591  break;
593  pMark = std::make_unique<CheckboxFieldmark>(rPaM);
594  break;
596  pMark = std::make_unique<DropDownFieldmark>(rPaM);
597  break;
599  pMark = std::make_unique<DateFieldmark>(rPaM);
600  break;
602  pMark = std::make_unique<NavigatorReminder>(rPaM);
603  break;
605  pMark = std::make_unique<Bookmark>(rPaM, vcl::KeyCode(), rName);
606  break;
608  pMark = std::make_unique<DdeBookmark>(rPaM);
609  break;
611  pMark = std::make_unique<CrossRefHeadingBookmark>(rPaM, vcl::KeyCode(), rName);
612  break;
614  pMark = std::make_unique<CrossRefNumItemBookmark>(rPaM, vcl::KeyCode(), rName);
615  break;
617  pMark = std::make_unique<UnoMark>(rPaM);
618  break;
620  pMark = std::make_unique<AnnotationMark>( rPaM, rName );
621  break;
622  }
623  assert(pMark.get() &&
624  "MarkManager::makeMark(..)"
625  " - Mark was not created.");
626 
627  if(pMark->GetMarkPos() != pMark->GetMarkStart())
628  pMark->Swap();
629 
630  // for performance reasons, we trust UnoMarks to have a (generated) unique name
632  pMark->SetName( getUniqueMarkName( pMark->GetName() ) );
633 
634  // insert any dummy chars before inserting into sorted vectors
635  pMark->InitDoc(m_pDoc, eMode, pSepPos);
636 
637  // register mark
638  lcl_InsertMarkSorted(m_vAllMarks, pMark.get());
639  switch(eType)
640  {
644  lcl_InsertMarkSorted(m_vBookmarks, pMark.get());
645  break;
650  lcl_InsertMarkSorted(m_vFieldmarks, pMark.get());
651  break;
653  lcl_InsertMarkSorted( m_vAnnotationMarks, pMark.get() );
654  break;
658  // no special array for these
659  break;
660  }
661  SAL_INFO("sw.core", "--- makeType ---");
662  SAL_INFO("sw.core", "Marks");
663  lcl_DebugMarks(m_vAllMarks);
664  SAL_INFO("sw.core", "Bookmarks");
665  lcl_DebugMarks(m_vBookmarks);
666  SAL_INFO("sw.core", "Fieldmarks");
667  lcl_DebugMarks(m_vFieldmarks);
668 
669  return pMark.release();
670  }
671 
673  const SwPaM& rPaM,
674  const OUString& rName,
675  const OUString& rType,
676  SwPosition const*const pSepPos)
677  {
678 
679  // Disable undo, because we handle it using SwUndoInsTextFieldmark
680  bool bUndoIsEnabled = m_pDoc->GetIDocumentUndoRedo().DoesUndo();
682 
683  sw::mark::IMark* pMark = nullptr;
684  if(rType == ODF_FORMDATE)
685  {
686  pMark = makeMark(rPaM, rName,
689  pSepPos);
690  }
691  else
692  {
693  pMark = makeMark(rPaM, rName,
696  pSepPos);
697  }
698  sw::mark::IFieldmark* pFieldMark = dynamic_cast<sw::mark::IFieldmark*>( pMark );
699  if (pFieldMark)
700  pFieldMark->SetFieldname( rType );
701 
702  if (bUndoIsEnabled)
703  {
704  m_pDoc->GetIDocumentUndoRedo().DoUndo(bUndoIsEnabled);
705  if (pFieldMark)
706  m_pDoc->GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoInsTextFieldmark>(*pFieldMark));
707  }
708 
709  return pFieldMark;
710  }
711 
713  const SwPaM& rPaM,
714  const OUString& rName,
715  const OUString& rType)
716  {
717  // Disable undo, because we handle it using SwUndoInsNoTextFieldmark
718  bool bUndoIsEnabled = m_pDoc->GetIDocumentUndoRedo().DoesUndo();
720 
721  bool bEnableSetModified = m_pDoc->getIDocumentState().IsEnableSetModified();
723 
724  sw::mark::IMark* pMark = nullptr;
725  if(rType == ODF_FORMCHECKBOX)
726  {
727  pMark = makeMark( rPaM, rName,
730  }
731  else if(rType == ODF_FORMDROPDOWN)
732  {
733  pMark = makeMark( rPaM, rName,
736  }
737  else if(rType == ODF_FORMDATE)
738  {
739  pMark = makeMark( rPaM, rName,
742  }
743 
744  sw::mark::IFieldmark* pFieldMark = dynamic_cast<sw::mark::IFieldmark*>( pMark );
745  if (pFieldMark)
746  pFieldMark->SetFieldname( rType );
747 
748  if (bUndoIsEnabled)
749  {
750  m_pDoc->GetIDocumentUndoRedo().DoUndo(bUndoIsEnabled);
751  if (pFieldMark)
752  m_pDoc->GetIDocumentUndoRedo().AppendUndo(std::make_unique<SwUndoInsNoTextFieldmark>(*pFieldMark));
753  }
754 
755  m_pDoc->getIDocumentState().SetEnableSetModified(bEnableSetModified);
757 
758  return pFieldMark;
759  }
760 
762  const SwTextNode& rTextNode,
763  const IDocumentMarkAccess::MarkType eType )
764  {
765  SwPosition aPos(rTextNode);
766  aPos.nContent.Assign(&const_cast<SwTextNode&>(rTextNode), 0);
767  auto const ppExistingMark = lcl_FindMarkAtPos(m_vBookmarks, aPos, eType);
768  if(ppExistingMark != m_vBookmarks.end())
769  return *ppExistingMark;
770  const SwPaM aPaM(aPos);
771  return makeMark(aPaM, OUString(), eType, sw::mark::InsertMode::New);
772  }
773 
775  const SwPaM& rPaM,
776  const OUString& rName )
777  {
780  }
781 
783  ::sw::mark::IMark* const io_pMark,
784  const SwPaM& rPaM)
785  {
786  assert(io_pMark->GetMarkPos().GetDoc() == m_pDoc &&
787  "<MarkManager::repositionMark(..)>"
788  " - Mark is not in my doc.");
789  MarkBase* const pMarkBase = dynamic_cast< MarkBase* >(io_pMark);
790  if (!pMarkBase)
791  return;
792 
793  pMarkBase->SetMarkPos(*(rPaM.GetPoint()));
794  if(rPaM.HasMark())
795  pMarkBase->SetOtherMarkPos(*(rPaM.GetMark()));
796  else
797  pMarkBase->ClearOtherMarkPos();
798 
799  if(pMarkBase->GetMarkPos() != pMarkBase->GetMarkStart())
800  pMarkBase->Swap();
801 
802  sortMarks();
803  }
804 
806  ::sw::mark::IMark* io_pMark,
807  const OUString& rNewName )
808  {
809  assert(io_pMark->GetMarkPos().GetDoc() == m_pDoc &&
810  "<MarkManager::renameMark(..)>"
811  " - Mark is not in my doc.");
812  if ( io_pMark->GetName() == rNewName )
813  return true;
814  if (lcl_FindMarkByName(rNewName, m_vAllMarks.begin(), m_vAllMarks.end()) != m_vAllMarks.end())
815  return false;
816  if (::sw::mark::MarkBase* pMarkBase = dynamic_cast< ::sw::mark::MarkBase* >(io_pMark))
817  {
818  const OUString sOldName(pMarkBase->GetName());
819  pMarkBase->SetName(rNewName);
820 
821  if (dynamic_cast< ::sw::mark::Bookmark* >(io_pMark))
822  {
824  {
826  std::make_unique<SwUndoRenameBookmark>(sOldName, rNewName, m_pDoc));
827  }
829  }
830  }
831  return true;
832  }
833 
835  const SwNodeIndex& rOldNode,
836  const SwPosition& rNewPos,
837  const sal_Int32 nOffset)
838  {
839  const SwNode* const pOldNode = &rOldNode.GetNode();
840  SwPosition aNewPos(rNewPos);
841  aNewPos.nContent += nOffset;
842  bool isSortingNeeded = false;
843 
844  for (auto ppMark = m_vAllMarks.begin();
845  ppMark != m_vAllMarks.end();
846  ++ppMark)
847  {
848  ::sw::mark::MarkBase *const pMark = *ppMark;
849  // correction of non-existent non-MarkBase instances cannot be done
850  assert(pMark);
851  // is on position ??
852  bool bChangedPos = false;
853  if(&pMark->GetMarkPos().nNode.GetNode() == pOldNode)
854  {
855  pMark->SetMarkPos(aNewPos);
856  bChangedPos = true;
857  isSortingNeeded = true;
858  }
859  bool bChangedOPos = false;
860  if (pMark->IsExpanded() &&
861  &pMark->GetOtherMarkPos().nNode.GetNode() == pOldNode)
862  {
863  // shift the OtherMark to aNewPos
864  pMark->SetOtherMarkPos(aNewPos);
865  bChangedOPos= true;
866  isSortingNeeded = true;
867  }
868  // illegal selection? collapse the mark and restore sorting later
869  isSortingNeeded |= lcl_FixCorrectedMark(bChangedPos, bChangedOPos, pMark);
870  }
871 
872  // restore sorting if needed
873  if(isSortingNeeded)
874  sortMarks();
875 
876  SAL_INFO("sw.core", "correctMarksAbsolute");
877  lcl_DebugMarks(m_vAllMarks);
878  }
879 
880  void MarkManager::correctMarksRelative(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset)
881  {
882  const SwNode* const pOldNode = &rOldNode.GetNode();
883  SwPosition aNewPos(rNewPos);
884  aNewPos.nContent += nOffset;
885  bool isSortingNeeded = false;
886 
887  for (auto ppMark = m_vAllMarks.begin();
888  ppMark != m_vAllMarks.end();
889  ++ppMark)
890  {
891  // is on position ??
892  bool bChangedPos = false, bChangedOPos = false;
893  ::sw::mark::MarkBase* const pMark = *ppMark;
894  // correction of non-existent non-MarkBase instances cannot be done
895  assert(pMark);
896  if(&pMark->GetMarkPos().nNode.GetNode() == pOldNode)
897  {
898  SwPosition aNewPosRel(aNewPos);
899  if (dynamic_cast< ::sw::mark::CrossRefBookmark *>(pMark))
900  {
901  // ensure that cross ref bookmark always starts at 0
902  aNewPosRel.nContent = 0; // HACK for WW8 import
903  isSortingNeeded = true; // and sort them to be safe...
904  }
905  aNewPosRel.nContent += pMark->GetMarkPos().nContent.GetIndex();
906  pMark->SetMarkPos(aNewPosRel);
907  bChangedPos = true;
908  }
909  if(pMark->IsExpanded() &&
910  &pMark->GetOtherMarkPos().nNode.GetNode() == pOldNode)
911  {
912  SwPosition aNewPosRel(aNewPos);
913  aNewPosRel.nContent += pMark->GetOtherMarkPos().nContent.GetIndex();
914  pMark->SetOtherMarkPos(aNewPosRel);
915  bChangedOPos = true;
916  }
917  // illegal selection? collapse the mark and restore sorting later
918  isSortingNeeded |= lcl_FixCorrectedMark(bChangedPos, bChangedOPos, pMark);
919  }
920 
921  // restore sorting if needed
922  if(isSortingNeeded)
923  sortMarks();
924 
925  SAL_INFO("sw.core", "correctMarksRelative");
926  lcl_DebugMarks(m_vAllMarks);
927  }
928 
930  const SwNodeIndex& rStt,
931  const SwNodeIndex& rEnd,
932  std::vector<SaveBookmark>* pSaveBkmk,
933  const SwIndex* pSttIdx,
934  const SwIndex* pEndIdx )
935  {
936  std::vector<const_iterator_t> vMarksToDelete;
937  bool bIsSortingNeeded = false;
938 
939  // boolean indicating, if at least one mark has been moved while collecting marks for deletion
940  bool bMarksMoved = false;
941  // have marks in the range been skipped instead of deleted
942  bool bMarksSkipDeletion = false;
943 
944  // copy all bookmarks in the move area to a vector storing all position data as offset
945  // reassignment is performed after the move
946  for (auto ppMark = m_vAllMarks.begin();
947  ppMark != m_vAllMarks.end();
948  ++ppMark)
949  {
950  // navigator marks should not be moved
951  // TODO: Check if this might make them invalid
953  continue;
954 
955  ::sw::mark::MarkBase *const pMark = *ppMark;
956 
957  if (!pMark)
958  continue;
959 
960  // on position ??
961  bool bIsPosInRange = lcl_GreaterThan(pMark->GetMarkPos(), rStt, pSttIdx)
962  && lcl_Lower(pMark->GetMarkPos(), rEnd, pEndIdx);
963  bool bIsOtherPosInRange = pMark->IsExpanded()
964  && lcl_GreaterThan(pMark->GetOtherMarkPos(), rStt, pSttIdx)
965  && lcl_Lower(pMark->GetOtherMarkPos(), rEnd, pEndIdx);
966  // special case: completely in range, touching the end?
967  if ( pEndIdx != nullptr
968  && ( ( bIsOtherPosInRange
969  && pMark->GetMarkPos().nNode == rEnd
970  && pMark->GetMarkPos().nContent == *pEndIdx )
971  || ( bIsPosInRange
972  && pMark->IsExpanded()
973  && pMark->GetOtherMarkPos().nNode == rEnd
974  && pMark->GetOtherMarkPos().nContent == *pEndIdx ) ) )
975  {
976  bIsPosInRange = true;
977  bIsOtherPosInRange = true;
978  }
979 
980  if ( bIsPosInRange
981  && ( bIsOtherPosInRange
982  || !pMark->IsExpanded() ) )
983  {
984  // completely in range
985 
986  bool bDeleteMark = true;
987  {
988  switch ( IDocumentMarkAccess::GetType( *pMark ) )
989  {
992  // no delete of cross-reference bookmarks, if range is inside one paragraph
993  bDeleteMark = rStt != rEnd;
994  break;
996  // no delete of UNO mark, if it is not expanded and only touches the start of the range
997  bDeleteMark = bIsOtherPosInRange
998  || pMark->IsExpanded()
999  || pSttIdx == nullptr
1000  || !( pMark->GetMarkPos().nNode == rStt
1001  && pMark->GetMarkPos().nContent == *pSttIdx );
1002  break;
1003  default:
1004  bDeleteMark = true;
1005  break;
1006  }
1007  }
1008 
1009  if ( bDeleteMark )
1010  {
1011  if ( pSaveBkmk )
1012  {
1013  pSaveBkmk->push_back( SaveBookmark( *pMark, rStt, pSttIdx ) );
1014  }
1015  vMarksToDelete.emplace_back(ppMark);
1016  }
1017  else
1018  {
1019  bMarksSkipDeletion = true;
1020  }
1021  }
1022  else if ( bIsPosInRange != bIsOtherPosInRange )
1023  {
1024  // the bookmark is partially in the range
1025  // move position of that is in the range out of it
1026 
1027  std::unique_ptr< SwPosition > pNewPos;
1028  {
1029  if ( pEndIdx != nullptr )
1030  {
1031  pNewPos = std::make_unique< SwPosition >( rEnd, *pEndIdx );
1032  }
1033  else
1034  {
1035  pNewPos =
1036  lcl_FindExpelPosition( rStt, rEnd, bIsPosInRange ? pMark->GetOtherMarkPos() : pMark->GetMarkPos() );
1037  }
1038  }
1039 
1040  bool bMoveMark = true;
1041  {
1042  switch ( IDocumentMarkAccess::GetType( *pMark ) )
1043  {
1046  // no move of cross-reference bookmarks, if move occurs inside a certain node
1047  bMoveMark = pMark->GetMarkPos().nNode != pNewPos->nNode;
1048  break;
1050  // no move of annotation marks, if method is called to collect deleted marks
1051  bMoveMark = pSaveBkmk == nullptr;
1052  break;
1053  default:
1054  bMoveMark = true;
1055  break;
1056  }
1057  }
1058  if ( bMoveMark )
1059  {
1060  if ( bIsPosInRange )
1061  pMark->SetMarkPos(*pNewPos);
1062  else
1063  pMark->SetOtherMarkPos(*pNewPos);
1064  bMarksMoved = true;
1065 
1066  // illegal selection? collapse the mark and restore sorting later
1067  bIsSortingNeeded |= lcl_FixCorrectedMark( bIsPosInRange, bIsOtherPosInRange, pMark );
1068  }
1069  }
1070  }
1071 
1072  {
1073  // fdo#61016 delay the deletion of the fieldmark characters
1074  // to prevent that from deleting the marks on that position
1075  // which would invalidate the iterators in vMarksToDelete
1076  std::vector< std::unique_ptr<ILazyDeleter> > vDelay;
1077  vDelay.reserve(vMarksToDelete.size());
1078 
1079  // If needed, sort mark containers containing subsets of the marks
1080  // in order to assure sorting. The sorting is critical for the
1081  // deletion of a mark as it is searched in these container for
1082  // deletion.
1083  if ( !vMarksToDelete.empty() && bMarksMoved )
1084  {
1085  sortSubsetMarks();
1086  }
1087  // we just remembered the iterators to delete, so we do not need to search
1088  // for the shared_ptr<> (the entry in m_vAllMarks) again
1089  // reverse iteration, since erasing an entry invalidates iterators
1090  // behind it (the iterators in vMarksToDelete are sorted)
1091  for ( std::vector< const_iterator_t >::reverse_iterator pppMark = vMarksToDelete.rbegin();
1092  pppMark != vMarksToDelete.rend();
1093  ++pppMark )
1094  {
1095  vDelay.push_back(deleteMark(*pppMark));
1096  }
1097  } // scope to kill vDelay
1098 
1099  // also need to sort if both marks were moved and not-deleted because
1100  // the not-deleted marks could be in wrong order vs. the moved ones
1101  if (bIsSortingNeeded || (bMarksMoved && bMarksSkipDeletion))
1102  {
1103  sortMarks();
1104  }
1105 
1106  SAL_INFO("sw.core", "deleteMarks");
1107  lcl_DebugMarks(m_vAllMarks);
1108  }
1109 
1111  {
1112  std::unique_ptr<Fieldmark> m_pFieldmark;
1114  LazyFieldmarkDeleter(Fieldmark* pMark, SwDoc *const pDoc)
1115  : m_pFieldmark(pMark), m_pDoc(pDoc)
1116  {
1117  assert(m_pFieldmark);
1118  }
1119  virtual ~LazyFieldmarkDeleter() override
1120  {
1121  // note: because of the call chain from SwUndoDelete, the field
1122  // command *cannot* be deleted here as it would create a separate
1123  // SwUndoDelete that's interleaved with the SwHistory of the outer
1124  // one - only delete the CH_TXT_ATR_FIELD*!
1125  m_pFieldmark->ReleaseDoc(m_pDoc);
1126  }
1127  };
1128 
1129  std::unique_ptr<IDocumentMarkAccess::ILazyDeleter>
1131  {
1132  std::unique_ptr<ILazyDeleter> ret;
1133  if (ppMark.get() == m_vAllMarks.end())
1134  return ret;
1135  IMark* pMark = *ppMark;
1136 
1137  switch(IDocumentMarkAccess::GetType(*pMark))
1138  {
1142  {
1143  auto const ppBookmark = lcl_FindMark(m_vBookmarks, *ppMark.get());
1144  if ( ppBookmark != m_vBookmarks.end() )
1145  {
1146  m_vBookmarks.erase(ppBookmark);
1147  }
1148  else
1149  {
1150  assert(false &&
1151  "<MarkManager::deleteMark(..)> - Bookmark not found in Bookmark container.");
1152  }
1153  }
1154  break;
1155 
1160  {
1161  auto const ppFieldmark = lcl_FindMark(m_vFieldmarks, *ppMark.get());
1162  if ( ppFieldmark != m_vFieldmarks.end() )
1163  {
1164  if(m_pLastActiveFieldmark == *ppFieldmark)
1166 
1167  m_vFieldmarks.erase(ppFieldmark);
1168  ret.reset(new LazyFieldmarkDeleter(dynamic_cast<Fieldmark*>(pMark), m_pDoc));
1169  }
1170  else
1171  {
1172  assert(false &&
1173  "<MarkManager::deleteMark(..)> - Fieldmark not found in Fieldmark container.");
1174  }
1175  }
1176  break;
1177 
1179  {
1180  auto const ppAnnotationMark = lcl_FindMark(m_vAnnotationMarks, *ppMark.get());
1181  assert(ppAnnotationMark != m_vAnnotationMarks.end() &&
1182  "<MarkManager::deleteMark(..)> - Annotation Mark not found in Annotation Mark container.");
1183  m_vAnnotationMarks.erase(ppAnnotationMark);
1184  }
1185  break;
1186 
1190  // no special marks container
1191  break;
1192  }
1193  DdeBookmark* const pDdeBookmark = dynamic_cast<DdeBookmark*>(pMark);
1194  if (pDdeBookmark)
1195  pDdeBookmark->DeregisterFromDoc(m_pDoc);
1196  //Effective STL Item 27, get a non-const iterator aI at the same
1197  //position as const iterator ppMark was
1198  auto aI = m_vAllMarks.begin();
1199  std::advance(aI, std::distance<container_t::const_iterator>(aI, ppMark.get()));
1200 
1201  m_vAllMarks.erase(aI);
1202  // If we don't have a lazy deleter
1203  if (!ret)
1204  // delete after we remove from the list, because the destructor can
1205  // recursively call into this method.
1206  delete pMark;
1207  return ret;
1208  }
1209 
1210  void MarkManager::deleteMark(const IMark* const pMark)
1211  {
1212  assert(pMark->GetMarkPos().GetDoc() == m_pDoc &&
1213  "<MarkManager::deleteMark(..)>"
1214  " - Mark is not in my doc.");
1215  // finds the last Mark that is starting before pMark
1216  // (pMarkLow < pMark)
1217  auto [it, endIt] = equal_range(
1218  m_vAllMarks.begin(),
1219  m_vAllMarks.end(),
1220  pMark->GetMarkStart(),
1221  CompareIMarkStartsBefore());
1222  for ( ; it != endIt; ++it)
1223  if (*it == pMark)
1224  {
1225  deleteMark(iterator(it));
1226  break;
1227  }
1228  }
1229 
1231  {
1233  m_vFieldmarks.clear();
1234  m_vBookmarks.clear();
1235  m_vAnnotationMarks.clear();
1236  for (const auto & p : m_vAllMarks)
1237  delete p;
1238  m_vAllMarks.clear();
1239  }
1240 
1242  {
1243  auto const ret = lcl_FindMarkByName(rName, m_vAllMarks.begin(), m_vAllMarks.end());
1244  return IDocumentMarkAccess::iterator(ret);
1245  }
1246 
1248  {
1249  auto const ret = lcl_FindMarkByName(rName, m_vBookmarks.begin(), m_vBookmarks.end());
1250  return IDocumentMarkAccess::iterator(ret);
1251  }
1252 
1254  { return m_vAllMarks.begin(); }
1255 
1257  { return m_vAllMarks.end(); }
1258 
1260  { return m_vAllMarks.size(); }
1261 
1263  { return m_vBookmarks.begin(); }
1264 
1266  { return m_vBookmarks.end(); }
1267 
1269  { return m_vBookmarks.size(); }
1270 
1271  // finds the first that is starting after
1273  {
1274  return std::upper_bound(
1275  m_vBookmarks.begin(),
1276  m_vBookmarks.end(),
1277  rPos,
1278  CompareIMarkStartsAfter());
1279  }
1280 
1282  {
1283  auto const pFieldmark = find_if(
1284  m_vFieldmarks.begin(),
1285  m_vFieldmarks.end(),
1286  [&rPos] (::sw::mark::MarkBase const*const pMark) {
1287  return pMark->GetMarkStart() == rPos
1288  // end position includes the CH_TXT_ATR_FIELDEND
1289  || (pMark->GetMarkEnd().nContent.GetIndex() == rPos.nContent.GetIndex() + 1
1290  && pMark->GetMarkEnd().nNode == rPos.nNode);
1291  } );
1292  return (pFieldmark == m_vFieldmarks.end())
1293  ? nullptr
1294  : dynamic_cast<IFieldmark*>(*pFieldmark);
1295  }
1296 
1298  {
1299  auto itFieldmark = find_if(
1300  m_vFieldmarks.begin(),
1301  m_vFieldmarks.end(),
1302  [&rPos] (const ::sw::mark::MarkBase *const pMark) { return pMark->IsCoveringPosition(rPos); } );
1303  if (itFieldmark == m_vFieldmarks.end())
1304  return nullptr;
1305  auto pFieldmark(*itFieldmark);
1306  for ( ; itFieldmark != m_vFieldmarks.end()
1307  && (**itFieldmark).IsCoveringPosition(rPos); ++itFieldmark)
1308  { // find the innermost fieldmark
1309  if (pFieldmark->GetMarkStart() < (**itFieldmark).GetMarkStart()
1310  || (**itFieldmark).GetMarkEnd() < pFieldmark->GetMarkEnd())
1311  {
1312  pFieldmark = *itFieldmark;
1313  }
1314  }
1315  return dynamic_cast<IFieldmark*>(pFieldmark);
1316  }
1317 
1319  {
1320  auto const pFieldmark = dynamic_cast<Fieldmark*>(getFieldmarkAt(rPos));
1321  if (!pFieldmark)
1322  return;
1323 
1324  deleteMark(lcl_FindMark(m_vAllMarks, pFieldmark));
1325  }
1326 
1328  {
1329  bool bActualChange = false;
1330  if(rNewType == ODF_FORMDROPDOWN)
1331  {
1332  if (!dynamic_cast<::sw::mark::DropDownFieldmark*>(pFieldmark))
1333  bActualChange = true;
1334  if (!dynamic_cast<::sw::mark::CheckboxFieldmark*>(pFieldmark)) // only allowed converting between checkbox <-> dropdown
1335  return nullptr;
1336  }
1337  else if(rNewType == ODF_FORMCHECKBOX)
1338  {
1339  if (!dynamic_cast<::sw::mark::CheckboxFieldmark*>(pFieldmark))
1340  bActualChange = true;
1341  if (!dynamic_cast<::sw::mark::DropDownFieldmark*>(pFieldmark)) // only allowed converting between checkbox <-> dropdown
1342  return nullptr;
1343  }
1344  else if(rNewType == ODF_FORMDATE)
1345  {
1346  if (!dynamic_cast<::sw::mark::DateFieldmark*>(pFieldmark))
1347  bActualChange = true;
1348  if (!dynamic_cast<::sw::mark::TextFieldmark*>(pFieldmark)) // only allowed converting between date field <-> text field
1349  return nullptr;
1350  }
1351 
1352  if (!bActualChange)
1353  return nullptr;
1354 
1355  // Store attributes needed to create the new fieldmark
1356  OUString sName = pFieldmark->GetName();
1357  SwPaM aPaM(pFieldmark->GetMarkPos());
1358 
1359  // Remove the old fieldmark and create a new one with the new type
1360  if(aPaM.GetPoint()->nContent > 0 && (rNewType == ODF_FORMDROPDOWN || rNewType == ODF_FORMCHECKBOX))
1361  {
1362  --aPaM.GetPoint()->nContent;
1363  SwPosition aNewPos (aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent);
1364  deleteFieldmarkAt(aNewPos);
1365  return makeNoTextFieldBookmark(aPaM, sName, rNewType);
1366  }
1367  else if(rNewType == ODF_FORMDATE)
1368  {
1369  SwPosition aPos (aPaM.GetPoint()->nNode, aPaM.GetPoint()->nContent);
1370  SwPaM aNewPaM(pFieldmark->GetMarkStart(), pFieldmark->GetMarkEnd());
1371  deleteFieldmarkAt(aPos);
1372  // HACK: hard-code the separator position here at the start because
1373  // writerfilter put it in the wrong place (at the end) on attach()
1374  SwPosition const sepPos(*aNewPaM.Start());
1375  return makeFieldBookmark(aNewPaM, sName, rNewType, &sepPos);
1376  }
1377  return nullptr;
1378  }
1379 
1381  {
1382  SwView* pSwView = dynamic_cast<SwView *>(rCursorShell.GetSfxViewShell());
1383  if(!pSwView)
1384  return;
1385 
1386  SwEditWin& rEditWin = pSwView->GetEditWin();
1387  SwPosition aPos(*rCursorShell.GetCursor()->GetPoint());
1388  IFieldmark* pFieldBM = getFieldmarkFor(aPos);
1389  FieldmarkWithDropDownButton* pNewActiveFieldmark = nullptr;
1390  if ((!pFieldBM || (pFieldBM->GetFieldname() != ODF_FORMDROPDOWN && pFieldBM->GetFieldname() != ODF_FORMDATE))
1391  && aPos.nContent.GetIndex() > 0 )
1392  {
1393  --aPos.nContent;
1394  pFieldBM = getFieldmarkFor(aPos);
1395  }
1396 
1397  if ( pFieldBM && (pFieldBM->GetFieldname() == ODF_FORMDROPDOWN ||
1398  pFieldBM->GetFieldname() == ODF_FORMDATE))
1399  {
1400  if (m_pLastActiveFieldmark != pFieldBM)
1401  {
1402  FieldmarkWithDropDownButton& rFormField = dynamic_cast<FieldmarkWithDropDownButton&>(*pFieldBM);
1403  rFormField.ShowButton(&rEditWin);
1404  pNewActiveFieldmark = &rFormField;
1405  }
1406  else
1407  {
1408  pNewActiveFieldmark = m_pLastActiveFieldmark;
1409  }
1410  }
1411 
1412  if(pNewActiveFieldmark != m_pLastActiveFieldmark)
1413  {
1415  m_pLastActiveFieldmark = pNewActiveFieldmark;
1416  }
1417  }
1418 
1420  {
1423 
1424  m_pLastActiveFieldmark = nullptr;
1425  }
1426 
1428  {
1429  IFieldmark *pMark = getFieldmarkAt(rPos);
1430  if (!pMark || pMark->GetFieldname() != ODF_FORMDROPDOWN)
1431  return nullptr;
1432  return pMark;
1433  }
1434 
1435  std::vector<IFieldmark*> MarkManager::getDropDownsFor(const SwPaM &rPaM) const
1436  {
1437  std::vector<IFieldmark*> aRet;
1438 
1439  for (auto aI = m_vFieldmarks.begin(),
1440  aEnd = m_vFieldmarks.end(); aI != aEnd; ++aI)
1441  {
1442  ::sw::mark::IMark* pI = *aI;
1443  const SwPosition &rStart = pI->GetMarkPos();
1444  if (!rPaM.ContainsPosition(rStart))
1445  continue;
1446 
1447  IFieldmark *pMark = dynamic_cast<IFieldmark*>(pI);
1448  if (!pMark || pMark->GetFieldname() != ODF_FORMDROPDOWN)
1449  continue;
1450 
1451  aRet.push_back(pMark);
1452  }
1453 
1454  return aRet;
1455  }
1456 
1458  { return dynamic_cast<IFieldmark*>(lcl_getMarkAfter(m_vFieldmarks, rPos)); }
1459 
1461  { return dynamic_cast<IFieldmark*>(lcl_getMarkBefore(m_vFieldmarks, rPos)); }
1462 
1464  {
1465  return m_vAnnotationMarks.begin();
1466  }
1467 
1469  {
1470  return m_vAnnotationMarks.end();
1471  }
1472 
1474  {
1475  return m_vAnnotationMarks.size();
1476  }
1477 
1479  {
1480  auto const ret = lcl_FindMarkByName( rName, m_vAnnotationMarks.begin(), m_vAnnotationMarks.end() );
1481  return IDocumentMarkAccess::iterator(ret);
1482  }
1483 
1485  {
1486  auto const pAnnotationMark = find_if(
1487  m_vAnnotationMarks.begin(),
1488  m_vAnnotationMarks.end(),
1489  [&rPos] (const ::sw::mark::MarkBase *const pMark) { return pMark->IsCoveringPosition(rPos); } );
1490  if (pAnnotationMark == m_vAnnotationMarks.end())
1491  return nullptr;
1492  return *pAnnotationMark;
1493  }
1494 
1495  // finds the first that is starting after
1497  {
1498  return std::upper_bound(
1499  m_vAnnotationMarks.begin(),
1500  m_vAnnotationMarks.end(),
1501  rPos,
1502  CompareIMarkStartsAfter());
1503  }
1504 
1505  OUString MarkManager::getUniqueMarkName(const OUString& rName) const
1506  {
1507  OSL_ENSURE(rName.getLength(),
1508  "<MarkManager::getUniqueMarkName(..)> - a name should be proposed");
1509  if( m_pDoc->IsInMailMerge())
1510  {
1511  OUString newName = rName + "MailMergeMark"
1512  + OStringToOUString( DateTimeToOString( DateTime( DateTime::SYSTEM )), RTL_TEXTENCODING_ASCII_US )
1513  + OUString::number( m_vAllMarks.size() + 1 );
1514  return newName;
1515  }
1516 
1517  if (lcl_FindMarkByName(rName, m_vAllMarks.begin(), m_vAllMarks.end()) == m_vAllMarks.end())
1518  {
1519  return rName;
1520  }
1521  OUString sTmp;
1522 
1523  // try the name "<rName>XXX" (where XXX is a number starting from 1) unless there is
1524  // an unused name. Due to performance-reasons (especially in mailmerge-scenarios) there
1525  // is a map m_aMarkBasenameMapUniqueOffset which holds the next possible offset (XXX) for
1526  // rName (so there is no need to test for nCnt-values smaller than the offset).
1527  sal_Int32 nCnt = 1;
1528  MarkBasenameMapUniqueOffset_t::const_iterator aIter = m_aMarkBasenameMapUniqueOffset.find(rName);
1529  if(aIter != m_aMarkBasenameMapUniqueOffset.end()) nCnt = aIter->second;
1530  while(nCnt < SAL_MAX_INT32)
1531  {
1532  sTmp = rName + OUString::number(nCnt);
1533  nCnt++;
1534  if (lcl_FindMarkByName(sTmp, m_vAllMarks.begin(), m_vAllMarks.end()) == m_vAllMarks.end())
1535  {
1536  break;
1537  }
1538  }
1539  m_aMarkBasenameMapUniqueOffset[rName] = nCnt;
1540 
1541  return sTmp;
1542  }
1543 
1545  {
1546  const_cast< MarkManager* >(this)->sortMarks();
1547  }
1548 
1550  {
1551  sort(m_vBookmarks.begin(), m_vBookmarks.end(), &lcl_MarkOrderingByStart);
1552  sort(m_vFieldmarks.begin(), m_vFieldmarks.end(), &lcl_MarkOrderingByStart);
1553  sort(m_vAnnotationMarks.begin(), m_vAnnotationMarks.end(), &lcl_MarkOrderingByStart);
1554  }
1555 
1557  {
1558  sort(m_vAllMarks.begin(), m_vAllMarks.end(), &lcl_MarkOrderingByStart);
1559  sortSubsetMarks();
1560  }
1561 
1563 {
1564  struct
1565  {
1566  const char* pName;
1567  const container_t* pContainer;
1568  } aContainers[] =
1569  {
1570  // UNO marks are only part of all marks.
1571  {"allmarks", &m_vAllMarks},
1572  {"bookmarks", &m_vBookmarks},
1573  {"fieldmarks", &m_vFieldmarks},
1574  {"annotationmarks", &m_vAnnotationMarks}
1575  };
1576 
1577  xmlTextWriterStartElement(pWriter, BAD_CAST("MarkManager"));
1578  for (const auto & rContainer : aContainers)
1579  {
1580  if (!rContainer.pContainer->empty())
1581  {
1582  xmlTextWriterStartElement(pWriter, BAD_CAST(rContainer.pName));
1583  for (auto it = rContainer.pContainer->begin(); it != rContainer.pContainer->end(); ++it)
1584  (*it)->dumpAsXml(pWriter);
1585  xmlTextWriterEndElement(pWriter);
1586  }
1587  }
1588  xmlTextWriterEndElement(pWriter);
1589 }
1590 
1591 }} // namespace ::sw::mark
1592 
1593 namespace
1594 {
1595  bool lcl_Greater( const SwPosition& rPos, const SwNodeIndex& rNdIdx, const SwIndex* pIdx )
1596  {
1597  return rPos.nNode > rNdIdx || ( pIdx && rPos.nNode == rNdIdx && rPos.nContent > pIdx->GetIndex() );
1598  }
1599 }
1600 
1601 // IDocumentMarkAccess for SwDoc
1603  { return static_cast< IDocumentMarkAccess* >(mpMarkManager.get()); }
1604 
1606  { return static_cast< IDocumentMarkAccess* >(mpMarkManager.get()); }
1607 
1608 SaveBookmark::SaveBookmark(
1609  const IMark& rBkmk,
1610  const SwNodeIndex & rMvPos,
1611  const SwIndex* pIdx)
1612  : m_aName(rBkmk.GetName())
1613  , m_aShortName()
1614  , m_aCode()
1615  , m_eOrigBkmType(IDocumentMarkAccess::GetType(rBkmk))
1616 {
1617  const IBookmark* const pBookmark = dynamic_cast< const IBookmark* >(&rBkmk);
1618  if(pBookmark)
1619  {
1620  m_aShortName = pBookmark->GetShortName();
1621  m_aCode = pBookmark->GetKeyCode();
1622 
1623  ::sfx2::Metadatable const*const pMetadatable(
1624  dynamic_cast< ::sfx2::Metadatable const* >(pBookmark));
1625  if (pMetadatable)
1626  {
1627  m_pMetadataUndo = pMetadatable->CreateUndo();
1628  }
1629  }
1630  m_nNode1 = rBkmk.GetMarkPos().nNode.GetIndex();
1632 
1633  m_nNode1 -= rMvPos.GetIndex();
1634  if(pIdx && !m_nNode1)
1635  m_nContent1 -= pIdx->GetIndex();
1636 
1637  if(rBkmk.IsExpanded())
1638  {
1639  m_nNode2 = rBkmk.GetOtherMarkPos().nNode.GetIndex();
1641 
1642  m_nNode2 -= rMvPos.GetIndex();
1643  if(pIdx && !m_nNode2)
1644  m_nContent2 -= pIdx->GetIndex();
1645  }
1646  else
1647  {
1648  m_nNode2 = ULONG_MAX;
1649  m_nContent2 = -1;
1650  }
1651 }
1652 
1654  SwDoc* pDoc,
1655  const SwNodeIndex& rNewPos,
1656  const SwIndex* pIdx)
1657 {
1658  SwPaM aPam(rNewPos.GetNode());
1659  if(pIdx)
1660  aPam.GetPoint()->nContent = *pIdx;
1661 
1662  if(ULONG_MAX != m_nNode2)
1663  {
1664  aPam.SetMark();
1665 
1666  aPam.GetMark()->nNode += m_nNode2;
1667  if(pIdx && !m_nNode2)
1668  aPam.GetMark()->nContent += m_nContent2;
1669  else
1670  aPam.GetMark()->nContent.Assign(aPam.GetContentNode(false), m_nContent2);
1671  }
1672 
1673  aPam.GetPoint()->nNode += m_nNode1;
1674 
1675  if(pIdx && !m_nNode1)
1676  aPam.GetPoint()->nContent += m_nContent1;
1677  else
1678  aPam.GetPoint()->nContent.Assign(aPam.GetContentNode(), m_nContent1);
1679 
1680  if(!aPam.HasMark()
1681  || CheckNodesRange(aPam.GetPoint()->nNode, aPam.GetMark()->nNode, true))
1682  {
1683  ::sw::mark::IBookmark* const pBookmark = dynamic_cast<::sw::mark::IBookmark*>(
1684  pDoc->getIDocumentMarkAccess()->makeMark(aPam, m_aName,
1686  if(pBookmark)
1687  {
1688  pBookmark->SetKeyCode(m_aCode);
1689  pBookmark->SetShortName(m_aShortName);
1690  if (m_pMetadataUndo)
1691  {
1692  ::sfx2::Metadatable * const pMeta(
1693  dynamic_cast< ::sfx2::Metadatable* >(pBookmark));
1694  assert(pMeta && "metadata undo, but not metadatable?");
1695  if (pMeta)
1696  {
1698  }
1699  }
1700  }
1701  }
1702 }
1703 
1704 // DelBookmarks
1705 
1707  const SwNodeIndex& rStt,
1708  const SwNodeIndex& rEnd,
1709  std::vector<SaveBookmark> * pSaveBkmk,
1710  const SwIndex* pSttIdx,
1711  const SwIndex* pEndIdx)
1712 {
1713  // illegal range ??
1714  if(rStt.GetIndex() > rEnd.GetIndex()
1715  || (rStt == rEnd && (!pSttIdx || !pEndIdx || pSttIdx->GetIndex() >= pEndIdx->GetIndex())))
1716  return;
1717  SwDoc* const pDoc = rStt.GetNode().GetDoc();
1718 
1719  pDoc->getIDocumentMarkAccess()->deleteMarks(rStt, rEnd, pSaveBkmk, pSttIdx, pEndIdx);
1720 
1721  // Copy all Redlines which are in the move area into an array
1722  // which holds all position information as offset.
1723  // Assignment happens after moving.
1725  for(SwRangeRedline* pRedl : rTable)
1726  {
1727  // Is at position?
1728  SwPosition *const pRStt = pRedl->Start();
1729  SwPosition *const pREnd = pRedl->End();
1730 
1731  if( lcl_Greater( *pRStt, rStt, pSttIdx ) && lcl_Lower( *pRStt, rEnd, pEndIdx ))
1732  {
1733  pRStt->nNode = rEnd;
1734  if( pEndIdx )
1735  pRStt->nContent = *pEndIdx;
1736  else
1737  {
1738  bool bStt = true;
1739  SwContentNode* pCNd = pRStt->nNode.GetNode().GetContentNode();
1740  if( !pCNd && nullptr == ( pCNd = pDoc->GetNodes().GoNext( &pRStt->nNode )) )
1741  {
1742  bStt = false;
1743  pRStt->nNode = rStt;
1744  if( nullptr == ( pCNd = SwNodes::GoPrevious( &pRStt->nNode )) )
1745  {
1746  pRStt->nNode = pREnd->nNode;
1747  pCNd = pRStt->nNode.GetNode().GetContentNode();
1748  }
1749  }
1750  pRStt->nContent.Assign( pCNd, bStt ? 0 : pCNd->Len() );
1751  }
1752  }
1753  if( lcl_Greater( *pREnd, rStt, pSttIdx ) && lcl_Lower( *pREnd, rEnd, pEndIdx ))
1754  {
1755  pREnd->nNode = rStt;
1756  if( pSttIdx )
1757  pREnd->nContent = *pSttIdx;
1758  else
1759  {
1760  bool bStt = false;
1761  SwContentNode* pCNd = pREnd->nNode.GetNode().GetContentNode();
1762  if( !pCNd && nullptr == ( pCNd = SwNodes::GoPrevious( &pREnd->nNode )) )
1763  {
1764  bStt = true;
1765  pREnd->nNode = rEnd;
1766  if( nullptr == ( pCNd = pDoc->GetNodes().GoNext( &pREnd->nNode )) )
1767  {
1768  pREnd->nNode = pRStt->nNode;
1769  pCNd = pREnd->nNode.GetNode().GetContentNode();
1770  }
1771  }
1772  pREnd->nContent.Assign( pCNd, bStt ? 0 : pCNd->Len() );
1773  }
1774  }
1775  }
1776 }
1777 
1778 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sw::mark::IMark * getAnnotationMarkFor(const SwPosition &rPos) const override
Definition: docbm.cxx:1484
virtual sal_Int32 Len() const
Definition: node.cxx:1180
virtual void ShowButton(SwEditWin *pEditWin)=0
bool IsInMailMerge() const
Definition: doc.hxx:953
virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition &rPos) const override
Finds the first mark that is starting after.
Definition: docbm.cxx:1496
virtual sal_Int32 getAllMarksCount() const override
returns the number of marks.
Definition: docbm.cxx:1259
virtual const OUString & GetName() const =0
Marks a position in the document model.
Definition: pam.hxx:35
void DelBookmarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< SaveBookmark > *pSaveBkmk, const SwIndex *pSttIdx, const SwIndex *pEndIdx)
Definition: docbm.cxx:1706
sw::mark::FieldmarkWithDropDownButton * m_pLastActiveFieldmark
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:184
virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition &rPos) const override
Finds the first mark that is starting after.
Definition: docbm.cxx:1272
sal_uLong m_nNode2
Definition: mvsave.hxx:64
virtual void SetFieldname(const OUString &rFieldname)=0
To avoid recursive calls of deleteMark, the removal of dummy characters of fieldmarks has to be delay...
SwNodeIndex nNode
Definition: pam.hxx:37
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:284
virtual void SetModified()=0
Must be called manually at changes of format.
std::unique_ptr< std::vector<::sw::mark::MarkBase * >::const_iterator > m_pIter
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:474
container_t m_vFieldmarks
const SwPosition * GetMark() const
Definition: pam.hxx:209
OUString getUniqueMarkName(const OUString &rName) const
Definition: docbm.cxx:1505
Provides access to the marks of a document.
Definition: doc.hxx:185
#define ODF_FORMCHECKBOX
void SetInDoc(SwDoc *pDoc, const SwNodeIndex &, const SwIndex *pIdx=nullptr)
Definition: docbm.cxx:1653
virtual const SwPosition & GetMarkPos() const =0
SwPosition FindFieldSep(IFieldmark const &rMark)
return position of the CH_TXT_ATR_FIELDSEP for rMark
Definition: bookmrk.cxx:50
virtual ::sw::mark::IFieldmark * getFieldmarkAfter(const SwPosition &rPos) const override
Definition: docbm.cxx:1457
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1288
SwNode & GetNode() const
Definition: ndindex.hxx:119
SwEditWin & GetEditWin()
Definition: view.hxx:403
virtual const_iterator_t getAllMarksBegin() const override
returns a STL-like random access iterator to the begin of the sequence of marks.
Definition: docbm.cxx:1253
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1602
Dialog to specify the properties of date form field.
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:143
virtual const_iterator_t getAnnotationMarksBegin() const override
Definition: docbm.cxx:1463
IDocumentMarkAccess::MarkType const m_eOrigBkmType
Definition: mvsave.hxx:62
SfxViewShell * GetSfxViewShell() const
Definition: viewsh.hxx:444
virtual ~LazyFieldmarkDeleter() override
Definition: docbm.cxx:1119
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &rPos) const override
Definition: docbm.cxx:1297
Fieldmark with a drop down button (e.g. this button opens the date picker for a date field) ...
Definition: bookmrk.hxx:273
virtual sw::mark::IFieldmark * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType) override
Definition: docbm.cxx:712
virtual bool IsExpanded() const override
Definition: bookmrk.hxx:83
virtual const_iterator_t getBookmarksEnd() const override
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
Definition: docbm.cxx:1265
virtual const OUString & GetName() const override
Definition: bookmrk.hxx:58
virtual void clearAllMarks() override
Clear (deletes) all marks.
Definition: docbm.cxx:1230
static SW_DLLPUBLIC OUString GetCrossRefHeadingBookmarkNamePrefix()
Definition: docbm.cxx:508
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:513
bool operator==(iterator const &rOther) const
Definition: docbm.cxx:108
SwIndex nContent
Definition: pam.hxx:38
container_t m_vBookmarks
SwDoc * GetDoc() const
Returns the document this position is in.
Definition: pam.cxx:176
virtual ::sw::mark::IFieldmark * getFieldmarkAt(const SwPosition &rPos) const override
get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
Definition: docbm.cxx:1281
sal_Int32 m_nContent1
Definition: mvsave.hxx:65
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark,::sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr)=0
Generates a new mark in the document for a certain selection.
iterator & operator-=(difference_type)
Definition: docbm.cxx:147
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
virtual void DoUndo(bool const bDoUndo)=0
Enable/Disable Undo.
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docbm.cxx:1562
sal_uLong m_nNode1
Definition: mvsave.hxx:63
bool CheckNodesRange(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, bool bChkSection)
Definition: pam.cxx:240
virtual bool IsEnableSetModified() const =0
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, IDocumentMarkAccess::MarkType eMark) override
Returns a mark in the document for a paragraph.
Definition: docbm.cxx:761
bool operator!=(iterator const &rOther) const
Definition: docbm.cxx:113
virtual void deleteMarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< ::sw::mark::SaveBookmark > *pSaveBkmk, const SwIndex *pSttIdx, const SwIndex *pEndIdx) override
Deletes marks in a range.
Definition: docbm.cxx:929
virtual bool DoesUndo() const =0
Is Undo enabled?
virtual void SetKeyCode(const vcl::KeyCode &)=0
virtual void SetShortName(const OUString &)=0
bool ContainsPosition(const SwPosition &rPos) const
Definition: pam.hxx:257
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
struct _xmlTextWriter * xmlTextWriterPtr
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo)=0
Add new Undo action.
virtual sal_Int32 getAnnotationMarksCount() const override
Definition: docbm.cxx:1473
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rName, IDocumentMarkAccess::MarkType eMark, sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr) override
Definition: docbm.cxx:544
container_t m_vAnnotationMarks
#define SAL_MAX_INT32
OUString m_aShortName
Definition: mvsave.hxx:60
virtual void deleteMarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< ::sw::mark::SaveBookmark > *pSaveBkmk, const SwIndex *pSttIdx, const SwIndex *pEndIdx)=0
Deletes marks in a range.
OUString const m_aName
Definition: mvsave.hxx:59
virtual const_iterator_t getAnnotationMarksEnd() const override
Definition: docbm.cxx:1468
const SwPosition * GetPoint() const
Definition: pam.hxx:207
Window class for the Writer edit area, this is the one handling mouse and keyboard events and doing t...
Definition: edtwin.hxx:58
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
const std::unique_ptr< ::sw::mark::MarkManager > mpMarkManager
Definition: doc.hxx:208
std::vector< sw::mark::MarkBase * > container_t
std::unique_ptr< Fieldmark > m_pFieldmark
Definition: docbm.cxx:1112
OUString sName
virtual void assureSortedMarkContainers() const override
Definition: docbm.cxx:1544
MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset
SwContentNode * GetContentNode()
Definition: node.hxx:615
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
virtual const_iterator_t findMark(const OUString &rName) const override
Finds a mark by name.
Definition: docbm.cxx:1241
SwDoc * GetDoc()
Definition: node.hxx:702
virtual std::unique_ptr< ILazyDeleter > deleteMark(const const_iterator_t &ppMark) override
Deletes a mark.
Definition: docbm.cxx:1130
virtual const OUString & GetShortName() const =0
virtual bool renameMark(::sw::mark::IMark *io_pMark, const OUString &rNewName) override
Renames an existing Mark, if possible.
Definition: docbm.cxx:805
iterator operator-(difference_type) const
Definition: docbm.cxx:153
iterator operator+(difference_type) const
Definition: docbm.cxx:142
Marks a character position inside a document model node.
Definition: index.hxx:37
virtual bool IsCoveringPosition(const SwPosition &rPos) const =0
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:393
std::shared_ptr< MetadatableUndo > CreateUndo() const
std::shared_ptr< ::sfx2::MetadatableUndo > m_pMetadataUndo
Definition: mvsave.hxx:67
Marks a node in the document model.
Definition: ndindex.hxx:31
sal_uInt16 sal_Char * pName
virtual const vcl::KeyCode & GetKeyCode() const =0
OUString newName(const OUString &aNewPrefix, const OUString &aOldPrefix, const OUString &old_Name)
iterator & operator=(iterator const &rOther)
Definition: docbm.cxx:68
virtual const_iterator_t getAllMarksEnd() const override
returns a STL-like random access iterator to the end of the sequence of marks.
Definition: docbm.cxx:1256
virtual const_iterator_t findAnnotationMark(const OUString &rName) const override
Definition: docbm.cxx:1478
const SwPosition * Start() const
Definition: pam.hxx:212
void SetMark(const sw::mark::IMark *pMark)
Definition: index.cxx:214
virtual sw::mark::IMark * makeAnnotationMark(const SwPaM &rPaM, const OUString &rName) override
Definition: docbm.cxx:774
virtual SwPosition & GetOtherMarkPos() const override
Definition: bookmrk.hxx:60
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:334
virtual sal_Int32 getBookmarksCount() const override
returns the number of IBookmarks.
Definition: docbm.cxx:1268
bool operator<=(iterator const &rOther) const
Definition: docbm.cxx:176
virtual void correctMarksAbsolute(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset) override
Corrects marks (absolute) This method ignores the previous position of the mark in the paragraph...
Definition: docbm.cxx:834
virtual void NotifyCursorUpdate(const SwCursorShell &rCursorShell) override
Definition: docbm.cxx:1380
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType, SwPosition const *pSepPos=nullptr) override
Definition: docbm.cxx:672
#define SAL_INFO(area, stream)
sal_Int32 GetIndex() const
Definition: index.hxx:95
OString DateTimeToOString(const DateTime &rDateTime)
virtual SwPosition & GetMarkPos() const override
Definition: bookmrk.hxx:56
SwNodes & GetNodes()
Definition: doc.hxx:402
bool operator>(iterator const &rOther) const
Definition: docbm.cxx:172
virtual const_iterator_t findBookmark(const OUString &rName) const override
Finds a bookmark by name.
Definition: docbm.cxx:1247
const SwPosition * End() const
Definition: pam.hxx:217
virtual void correctMarksRelative(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset) override
Corrects marks (relative) This method uses the previous position of the mark in the paragraph as offs...
Definition: docbm.cxx:880
virtual void SetMarkPos(const SwPosition &rNewPos)
Definition: bookmrk.cxx:267
iterator & operator+=(difference_type)
Definition: docbm.cxx:136
virtual ::sw::mark::IFieldmark * getFieldmarkBefore(const SwPosition &rPos) const override
Definition: docbm.cxx:1460
virtual ::sw::mark::IFieldmark * getDropDownFor(const SwPosition &rPos) const override
Definition: docbm.cxx:1427
virtual const SwPosition & GetMarkEnd() const =0
static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const &rMark)
Definition: docbm.cxx:522
virtual void deleteFieldmarkAt(const SwPosition &rPos) override
Definition: docbm.cxx:1318
virtual std::vector< ::sw::mark::IFieldmark * > getDropDownsFor(const SwPaM &rPaM) const override
Definition: docbm.cxx:1435
#define ODF_FORMDATE
virtual void SetEnableSetModified(bool bEnableSetModified)=0
virtual OUString GetFieldname() const =0
virtual ::sw::mark::IFieldmark * changeFormFieldmarkType(::sw::mark::IFieldmark *pFieldmark, const OUString &rNewType) override
Definition: docbm.cxx:1327
#define SAL_WARN(area, stream)
virtual void ClearFieldActivation() override
Definition: docbm.cxx:1419
vcl::KeyCode m_aCode
Definition: mvsave.hxx:61
virtual void DeregisterFromDoc(SwDoc *const pDoc)
Definition: bookmrk.cxx:357
virtual const SwPosition & GetMarkStart() const =0
::sw::mark::IMark * operator*() const
Definition: docbm.cxx:91
sal_Int32 m_nContent2
Definition: mvsave.hxx:66
InsertMode
Definition: IMark.hxx:31
virtual void SetOtherMarkPos(const SwPosition &rNewPos)
Definition: bookmrk.cxx:273
virtual const SwRedlineTable & GetRedlineTable() const =0
virtual const_iterator_t getBookmarksBegin() const override
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
Definition: docbm.cxx:1262
bool operator<(iterator const &rOther) const
Definition: docbm.cxx:168
bool operator>=(iterator const &rOther) const
Definition: docbm.cxx:180
virtual bool IsExpanded() const =0
std::vector<::sw::mark::MarkBase * >::const_iterator const & get() const
Definition: docbm.cxx:53
bool IsTextNode() const
Definition: node.hxx:636
value_type operator[](difference_type) const
Definition: docbm.cxx:163
virtual void repositionMark(::sw::mark::IMark *io_pMark, const SwPaM &rPaM) override
Moves an existing mark to a new selection and performs needed updates.
Definition: docbm.cxx:782
void RestoreMetadata(std::shared_ptr< MetadatableUndo > const &i_pUndo)
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1271
LazyFieldmarkDeleter(Fieldmark *pMark, SwDoc *const pDoc)
Definition: docbm.cxx:1114
Definition: view.hxx:146
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:842
#define ODF_FORMDROPDOWN
virtual const SwPosition & GetOtherMarkPos() const =0
Base class of the Writer document model elements.
Definition: node.hxx:79
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo