LibreOffice Module sw (master)  1
IDocumentMarkAccess.hxx
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 #ifndef INCLUDED_SW_INC_IDOCUMENTMARKACCESS_HXX
21 #define INCLUDED_SW_INC_IDOCUMENTMARKACCESS_HXX
22 
23 #include <sal/types.h>
24 #include "IMark.hxx"
25 #include <memory>
26 #include <optional>
27 
28 class SwPaM;
29 struct SwPosition;
30 class SwTextNode;
31 class SwCursorShell;
32 
33 namespace sw::mark {
34  class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
35  class MarkBase;
36 }
37 
41 {
42  public:
43  enum class MarkType
44  {
47  BOOKMARK,
56  };
57 
62  {
63  private:
64  std::optional<std::vector<::sw::mark::MarkBase*>::const_iterator> m_pIter;
65 
66  public:
67  // MarkManager implementation needs to get the real iterator
68  std::vector<::sw::mark::MarkBase*>::const_iterator const& get() const;
69 
70  typedef std::ptrdiff_t difference_type;
71  typedef ::sw::mark::IMark* value_type;
72  typedef ::sw::mark::IMark* const* pointer;
73  typedef ::sw::mark::IMark* const& reference;
74  typedef std::random_access_iterator_tag iterator_category;
75 
76  iterator();
77  iterator(std::vector<::sw::mark::MarkBase*>::const_iterator const& rIter);
78  iterator(iterator const& rOther);
79  iterator& operator=(iterator const& rOther);
80  iterator(iterator && rOther) noexcept;
81  iterator& operator=(iterator && rOther) noexcept;
82  ~iterator();
83 
84  // FIXME unfortunately there's a requirement on input iterator
85  // and forward iterator to return reference, which isn't
86  // possible because we have to return a temp value;
87  // let's try value_type instead, perhaps it's sufficient,
88  // for a const_iterator...
89  ::sw::mark::IMark* /*const&*/ operator*() const;
90  // nope can't do that :(
91  //::sw::mark::IMark* /* const* */ operator->() const;
92  iterator& operator++();
93  iterator operator++(int);
94  bool operator==(iterator const& rOther) const;
95  bool operator!=(iterator const& rOther) const;
96  iterator& operator--();
97  iterator operator--(int);
98  iterator& operator+=(difference_type);
99  iterator operator+(difference_type) const;
100  iterator& operator-=(difference_type);
101  iterator operator-(difference_type) const;
102  difference_type operator-(iterator const&) const;
103  value_type operator[](difference_type) const;
104  bool operator<(iterator const& rOther) const;
105  bool operator>(iterator const& rOther) const;
106  bool operator<=(iterator const& rOther) const;
107  bool operator>=(iterator const& rOther) const;
108  };
109 
111 
115  struct ILazyDeleter { virtual ~ILazyDeleter() { } };
116 
134  virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
135  const OUString& rProposedName,
136  MarkType eMark, ::sw::mark::InsertMode eMode,
137  SwPosition const* pSepPos = nullptr) = 0;
138 
139  virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
140  const OUString& rName,
141  const OUString& rType,
142  SwPosition const* pSepPos = nullptr) = 0;
143  virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
144  const OUString& rName,
145  const OUString& rType) = 0;
146 
148  const SwPaM& rPaM,
149  const OUString& rName ) = 0;
150 
163  virtual ::sw::mark::IMark* getMarkForTextNode(const SwTextNode& rTextNode,
164  MarkType eMark) =0;
165 
174  virtual void repositionMark(::sw::mark::IMark* io_pMark,
175  const SwPaM& rPaM) =0;
176 
186  virtual bool renameMark(::sw::mark::IMark* io_pMark,
187  const OUString& rNewName) =0;
188 
201  virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
202  const SwPosition& rNewPos,
203  const sal_Int32 nOffset) =0;
204 
219  virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
220  const SwPosition& rNewPos,
221  const sal_Int32 nOffset) =0;
222 
228  virtual void deleteMarks(
229  const SwNodeIndex& rStt,
230  const SwNodeIndex& rEnd,
231  std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal
232  const SwIndex* pSttIdx,
233  const SwIndex* pEndIdx) =0;
234 
240  virtual std::unique_ptr<ILazyDeleter>
242 
248  virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
249 
252  virtual void clearAllMarks() =0;
253 
254  virtual void assureSortedMarkContainers() const = 0;
255 
258  virtual const_iterator_t getAllMarksBegin() const =0;
259 
262  virtual const_iterator_t getAllMarksEnd() const =0;
263 
268  virtual sal_Int32 getAllMarksCount() const =0;
269 
278  virtual const_iterator_t findMark(const OUString& rMark) const =0;
279 
280  // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
281 
283  virtual bool isBookmarkDeleted(SwPaM const& rPaM) const =0;
284 
287  virtual const_iterator_t getBookmarksBegin() const =0;
288 
291  virtual const_iterator_t getBookmarksEnd() const =0;
292 
295  virtual sal_Int32 getBookmarksCount() const =0;
296 
305  virtual const_iterator_t findBookmark(const OUString& rMark) const =0;
306 
312  virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition& rPos) const =0;
313 
314 
315  // Fieldmarks
318  virtual const_iterator_t getFieldmarksBegin() const =0;
319 
322  virtual const_iterator_t getFieldmarksEnd() const =0;
323 
325  virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0;
326  virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
327  virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
328  virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
329 
330  virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0;
331  virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const=0;
332 
333  virtual void deleteFieldmarkAt(const SwPosition& rPos) = 0;
334  virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) = 0;
335 
336  virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) = 0;
337  virtual void ClearFieldActivation() = 0;
338 
339  // Annotation Marks
340  virtual const_iterator_t getAnnotationMarksBegin() const = 0;
341  virtual const_iterator_t getAnnotationMarksEnd() const = 0;
342  virtual sal_Int32 getAnnotationMarksCount() const = 0;
343  virtual const_iterator_t findAnnotationMark( const OUString& rName ) const = 0;
344  virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPosition) const = 0;
345  // handle and restore text ranges of annotations of tracked deletions
346  // based on the helper bookmarks (which can survive I/O and hiding redlines)
347  virtual ::sw::mark::IMark* makeAnnotationBookmark(const SwPaM& rPaM,
348  const OUString& rProposedName,
349  MarkType eMark, ::sw::mark::InsertMode eMode,
350  SwPosition const* pSepPos = nullptr) = 0;
351  virtual const_iterator_t findAnnotationBookmark( const OUString& rName ) const = 0;
352  virtual void restoreAnnotationMarks(bool bDelete = true) = 0;
358  virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition& rPos) const =0;
359 
362  static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark& rMark);
363 
365  static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM );
366  static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const& rMark);
367 
368  protected:
369  virtual ~IDocumentMarkAccess() {};
370 };
371 
372 #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
373 
374 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ::sw::mark::IFieldmark * getFieldmarkAfter(const SwPosition &pos) const =0
virtual ::sw::mark::IFieldmark * getFieldmarkAt(const SwPosition &rPos) const =0
get Fieldmark for CH_TXT_ATR_FIELDSTART/CH_TXT_ATR_FIELDEND at rPos
virtual void clearAllMarks()=0
Clear (deletes) all marks.
Marks a position in the document model.
Definition: pam.hxx:35
virtual const_iterator_t getAnnotationMarksEnd() const =0
To avoid recursive calls of deleteMark, the removal of dummy characters of fieldmarks has to be delay...
virtual sal_Int32 getBookmarksCount() const =0
returns the number of IBookmarks.
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:478
virtual void correctMarksRelative(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset)=0
Corrects marks (relative) This method uses the previous position of the mark in the paragraph as offs...
Provides access to the marks of a document.
virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition &rPos) const =0
Finds the first mark that is starting after.
virtual void restoreAnnotationMarks(bool bDelete=true)=0
virtual void assureSortedMarkContainers() const =0
Dialog to specify the properties of date form field.
virtual sal_Int32 getAnnotationMarksCount() const =0
virtual ::sw::mark::IFieldmark * getDropDownFor(const SwPosition &pos) const =0
static SW_DLLPUBLIC OUString GetCrossRefHeadingBookmarkNamePrefix()
Definition: docbm.cxx:512
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:517
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &pos) const =0
virtual sw::mark::IMark * makeAnnotationMark(const SwPaM &rPaM, const OUString &rName)=0
virtual std::vector< ::sw::mark::IFieldmark * > getDropDownsFor(const SwPaM &rPaM) const =0
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.
virtual const_iterator_t getFieldmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of fieldmarks.
virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition &rPos) const =0
Finds the first mark that is starting after.
virtual void NotifyCursorUpdate(const SwCursorShell &rCursorShell)=0
virtual const_iterator_t findAnnotationMark(const OUString &rName) const =0
virtual void repositionMark(::sw::mark::IMark *io_pMark, const SwPaM &rPaM)=0
Moves an existing mark to a new selection and performs needed updates.
std::random_access_iterator_tag iterator_category
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark)=0
Deletes a mark.
virtual const_iterator_t getAllMarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of marks.
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
virtual void ClearFieldActivation()=0
virtual const_iterator_t getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
std::optional< std::vector<::sw::mark::MarkBase * >::const_iterator > m_pIter
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.
virtual ::sw::mark::IMark * makeAnnotationBookmark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark,::sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr)=0
virtual ::sw::mark::IFieldmark * changeFormFieldmarkType(::sw::mark::IFieldmark *pFieldmark, const OUString &rNewType)=0
Marks a character position inside a document model node.
Definition: index.hxx:33
virtual const_iterator_t getAnnotationMarksBegin() const =0
virtual const_iterator_t findBookmark(const OUString &rMark) const =0
Finds a bookmark by name.
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType, SwPosition const *pSepPos=nullptr)=0
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
virtual void deleteFieldmarkAt(const SwPosition &rPos)=0
virtual sw::mark::IFieldmark * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType)=0
virtual bool isBookmarkDeleted(SwPaM const &rPaM) const =0
check if the selection would delete a BOOKMARK
virtual const_iterator_t getFieldmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of fieldmarks.
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual sw::mark::IMark * getAnnotationMarkFor(const SwPosition &rPosition) const =0
virtual sal_Int32 getAllMarksCount() const =0
returns the number of marks.
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, MarkType eMark)=0
Returns a mark in the document for a paragraph.
virtual const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
virtual void correctMarksAbsolute(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset)=0
Corrects marks (absolute) This method ignores the previous position of the mark in the paragraph...
static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const &rMark)
Definition: docbm.cxx:526
virtual bool renameMark(::sw::mark::IMark *io_pMark, const OUString &rNewName)=0
Renames an existing Mark, if possible.
virtual ::sw::mark::IFieldmark * getFieldmarkBefore(const SwPosition &pos) const =0
InsertMode
Definition: IMark.hxx:31
::sw::mark::IMark *const & reference
virtual const_iterator_t findAnnotationBookmark(const OUString &rName) const =0
::sw::mark::IMark *const * pointer