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 
27 class SwPaM;
28 struct SwPosition;
29 class SwTextNode;
30 class SwCursorShell;
31 
32 namespace sw { namespace mark {
33  class SaveBookmark; // FIXME: Ugly: SaveBookmark is a core-internal class, and should not be used in the interface
34  class MarkBase;
35 }}
36 
40 {
41  public:
42  enum class MarkType
43  {
46  BOOKMARK,
55  };
56 
61  {
62  private:
63  std::unique_ptr<std::vector<::sw::mark::MarkBase*>::const_iterator> m_pIter;
64 
65  public:
66  // MarkManager implementation needs to get the real iterator
67  std::vector<::sw::mark::MarkBase*>::const_iterator const& get() const;
68 
69  typedef std::ptrdiff_t difference_type;
70  typedef ::sw::mark::IMark* value_type;
71  typedef ::sw::mark::IMark* const* pointer;
72  typedef ::sw::mark::IMark* const& reference;
73  typedef std::random_access_iterator_tag iterator_category;
74 
75  iterator();
76  iterator(std::vector<::sw::mark::MarkBase*>::const_iterator const& rIter);
77  iterator(iterator const& rOther);
78  iterator& operator=(iterator const& rOther);
79  iterator(iterator && rOther) noexcept;
80  iterator& operator=(iterator && rOther) noexcept;
81  ~iterator();
82 
83  // FIXME unfortunately there's a requirement on input iterator
84  // and forward iterator to return reference, which isn't
85  // possible because we have to return a temp value;
86  // let's try value_type instead, perhaps it's sufficient,
87  // for a const_iterator...
88  ::sw::mark::IMark* /*const&*/ operator*() const;
89  // nope can't do that :(
90  //::sw::mark::IMark* /* const* */ operator->() const;
91  iterator& operator++();
92  iterator operator++(int);
93  bool operator==(iterator const& rOther) const;
94  bool operator!=(iterator const& rOther) const;
95  iterator& operator--();
96  iterator operator--(int);
97  iterator& operator+=(difference_type);
98  iterator operator+(difference_type) const;
99  iterator& operator-=(difference_type);
100  iterator operator-(difference_type) const;
101  difference_type operator-(iterator const&) const;
102  value_type operator[](difference_type) const;
103  bool operator<(iterator const& rOther) const;
104  bool operator>(iterator const& rOther) const;
105  bool operator<=(iterator const& rOther) const;
106  bool operator>=(iterator const& rOther) const;
107  };
108 
110 
114  struct ILazyDeleter { virtual ~ILazyDeleter() { } };
115 
133  virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
134  const OUString& rProposedName,
135  MarkType eMark, ::sw::mark::InsertMode eMode) = 0;
136 
137  virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
138  const OUString& rName,
139  const OUString& rType) = 0;
140  virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
141  const OUString& rName,
142  const OUString& rType) = 0;
143 
145  const SwPaM& rPaM,
146  const OUString& rName ) = 0;
147 
160  virtual ::sw::mark::IMark* getMarkForTextNode(const SwTextNode& rTextNode,
161  MarkType eMark) =0;
162 
171  virtual void repositionMark(::sw::mark::IMark* io_pMark,
172  const SwPaM& rPaM) =0;
173 
183  virtual bool renameMark(::sw::mark::IMark* io_pMark,
184  const OUString& rNewName) =0;
185 
198  virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
199  const SwPosition& rNewPos,
200  const sal_Int32 nOffset) =0;
201 
216  virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
217  const SwPosition& rNewPos,
218  const sal_Int32 nOffset) =0;
219 
225  virtual void deleteMarks(
226  const SwNodeIndex& rStt,
227  const SwNodeIndex& rEnd,
228  std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal
229  const SwIndex* pSttIdx,
230  const SwIndex* pEndIdx) =0;
231 
237  virtual std::unique_ptr<ILazyDeleter>
239 
245  virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
246 
249  virtual void clearAllMarks() =0;
250 
251  virtual void assureSortedMarkContainers() const = 0;
252 
255  virtual const_iterator_t getAllMarksBegin() const =0;
256 
259  virtual const_iterator_t getAllMarksEnd() const =0;
260 
265  virtual sal_Int32 getAllMarksCount() const =0;
266 
275  virtual const_iterator_t findMark(const OUString& rMark) const =0;
276 
277  // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
278 
281  virtual const_iterator_t getBookmarksBegin() const =0;
282 
285  virtual const_iterator_t getBookmarksEnd() const =0;
286 
289  virtual sal_Int32 getBookmarksCount() const =0;
290 
299  virtual const_iterator_t findBookmark(const OUString& rMark) const =0;
300 
306  virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition& rPos) const =0;
307 
308 
309  // Fieldmarks
311  virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0;
312  virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
313  virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
314  virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
315 
316  virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0;
317  virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const=0;
318 
319  virtual void deleteFieldmarkAt(const SwPosition& rPos) = 0;
320  virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) = 0;
321 
322  virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) = 0;
323  virtual void ClearFieldActivation() = 0;
324 
325  // Annotation Marks
326  virtual const_iterator_t getAnnotationMarksBegin() const = 0;
327  virtual const_iterator_t getAnnotationMarksEnd() const = 0;
328  virtual sal_Int32 getAnnotationMarksCount() const = 0;
329  virtual const_iterator_t findAnnotationMark( const OUString& rName ) const = 0;
330  virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPosition) const = 0;
336  virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition& rPos) const =0;
337 
340  static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark& rMark);
341 
343  static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark( const SwPaM& rPaM );
344  protected:
345  virtual ~IDocumentMarkAccess() {};
346 };
347 
348 #endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
349 
350 /* 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 ...
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:485
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 ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark,::sw::mark::InsertMode eMode)=0
Generates a new mark in the document for a certain selection.
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:519
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:524
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 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.
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::IFieldmark * changeFormFieldmarkType(::sw::mark::IFieldmark *pFieldmark, const OUString &rNewType)=0
Marks a character position inside a document model node.
Definition: index.hxx:37
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType)=0
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
#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
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...
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
::sw::mark::IMark *const * pointer