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
28class SwPaM;
29struct SwPosition;
30class SwTextNode;
31class SwCursorShell;
32
33namespace 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 {
45 UNO_BOOKMARK,
46 DDE_BOOKMARK,
48 CROSSREF_HEADING_BOOKMARK,
49 CROSSREF_NUMITEM_BOOKMARK,
50 ANNOTATIONMARK,
51 TEXT_FIELDMARK,
52 CHECKBOX_FIELDMARK,
53 DROPDOWN_FIELDMARK,
54 DATE_FIELDMARK,
55 NAVIGATOR_REMINDER
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;
72 typedef ::sw::mark::IMark* const* pointer;
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
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;
93 bool operator==(iterator const& rOther) const;
94 bool operator!=(iterator const& rOther) const;
95 iterator& operator--();
96 iterator operator--(int);
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,
136 SwPosition const* pSepPos = nullptr) = 0;
137
139 const OUString& rName,
140 const OUString& rType,
141 SwPosition const* pSepPos = nullptr) = 0;
143 const OUString& rName,
144 const OUString& rType) = 0;
145
147 const SwPaM& rPaM,
148 const OUString& rName ) = 0;
149
162 virtual ::sw::mark::IMark* getMarkForTextNode(const SwTextNode& rTextNode,
163 MarkType eMark) =0;
164
173 virtual void repositionMark(::sw::mark::IMark* io_pMark,
174 const SwPaM& rPaM) =0;
175
185 virtual bool renameMark(::sw::mark::IMark* io_pMark,
186 const OUString& rNewName) =0;
187
200 virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode,
201 const SwPosition& rNewPos,
202 const sal_Int32 nOffset) =0;
203
218 virtual void correctMarksRelative(const SwNodeIndex& rOldNode,
219 const SwPosition& rNewPos,
220 const sal_Int32 nOffset) =0;
221
227 virtual void deleteMarks(
228 const SwNodeIndex& rStt,
229 const SwNodeIndex& rEnd,
230 std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal
231 const SwIndex* pSttIdx,
232 const SwIndex* pEndIdx) =0;
233
242 virtual std::unique_ptr<ILazyDeleter>
243 deleteMark(const IDocumentMarkAccess::const_iterator_t& ppMark, bool isMoveNodes) =0;
244
250 virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
251
254 virtual void clearAllMarks() =0;
255
256 virtual void assureSortedMarkContainers() const = 0;
257
261
265
270 virtual sal_Int32 getAllMarksCount() const =0;
271
280 virtual const_iterator_t findMark(const OUString& rMark) const =0;
281
282 // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
283
285 virtual bool isBookmarkDeleted(SwPaM const& rPaM) const =0;
286
290
294
297 virtual sal_Int32 getBookmarksCount() const =0;
298
307 virtual const_iterator_t findBookmark(const OUString& rMark) const =0;
308
315
316
317 // Fieldmarks
321
325
327 virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0;
328 virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& pos) const =0;
329 virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos) const =0;
330 virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos) const =0;
331
332 virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0;
333 virtual std::vector<::sw::mark::IFieldmark*> getNoTextFieldmarksIn(const SwPaM &rPaM) const=0;
334
335 virtual void deleteFieldmarkAt(const SwPosition& rPos) = 0;
336 virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) = 0;
337
338 virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) = 0;
339 virtual void ClearFieldActivation() = 0;
340
341 // Annotation Marks
344 virtual sal_Int32 getAnnotationMarksCount() const = 0;
345 virtual const_iterator_t findAnnotationMark( const OUString& rName ) const = 0;
346 virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPosition) const = 0;
347 // handle and restore text ranges of annotations of tracked deletions
348 // based on the helper bookmarks (which can survive I/O and hiding redlines)
349 virtual ::sw::mark::IMark* makeAnnotationBookmark(const SwPaM& rPaM,
350 const OUString& rProposedName,
351 MarkType eMark, ::sw::mark::InsertMode eMode,
352 SwPosition const* pSepPos = nullptr) = 0;
353 virtual const_iterator_t findAnnotationBookmark( const OUString& rName ) const = 0;
354 virtual void restoreAnnotationMarks(bool bDelete = true) = 0;
361
364 static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark& rMark);
365
368 static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const& rMark);
369
370 protected:
372};
373
374#endif // IDOCUMENTBOOKMARKACCESS_HXX_INCLUDED
375
376/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool operator<=(const BigInt &rVal1, const BigInt &rVal2)
bool operator>=(const BigInt &rVal1, const BigInt &rVal2)
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
std::random_access_iterator_tag iterator_category
::sw::mark::IMark *const * pointer
::sw::mark::IMark *const & reference
std::optional< std::vector<::sw::mark::MarkBase * >::const_iterator > m_pIter
Provides access to the marks of a document.
virtual ::sw::mark::IFieldmark * getFieldmarkBefore(const SwPosition &pos) const =0
virtual bool isBookmarkDeleted(SwPaM const &rPaM) const =0
check if the selection would delete a BOOKMARK
virtual const_iterator_t getAnnotationMarksEnd() const =0
virtual const_iterator_t getFieldmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of fieldmarks.
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 * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType)=0
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType, SwPosition const *pSepPos=nullptr)=0
virtual std::vector<::sw::mark::IFieldmark * > getNoTextFieldmarksIn(const SwPaM &rPaM) const =0
virtual sw::mark::IMark * getAnnotationMarkFor(const SwPosition &rPosition) const =0
virtual void clearAllMarks()=0
Clear (deletes) all marks.
virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition &rPos) const =0
Finds the first mark that is starting after.
virtual ::sw::mark::IFieldmark * getFieldmarkAfter(const SwPosition &pos) const =0
virtual bool renameMark(::sw::mark::IMark *io_pMark, const OUString &rNewName)=0
Renames an existing Mark, if possible.
virtual const_iterator_t getAnnotationMarksBegin() 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 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 const_iterator_t getBookmarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
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 getAllMarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of marks.
virtual sal_Int32 getAnnotationMarksCount() 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.
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &pos) const =0
virtual const_iterator_t findAnnotationBookmark(const OUString &rName) const =0
virtual const_iterator_t findAnnotationMark(const OUString &rName) const =0
virtual ::sw::mark::IFieldmark * getDropDownFor(const SwPosition &pos) const =0
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
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...
virtual sal_Int32 getAllMarksCount() const =0
returns the number of marks.
virtual void NotifyCursorUpdate(const SwCursorShell &rCursorShell)=0
virtual void assureSortedMarkContainers() const =0
virtual void deleteMark(const ::sw::mark::IMark *const pMark)=0
Deletes a mark.
static SW_DLLPUBLIC OUString GetCrossRefHeadingBookmarkNamePrefix()
Definition: docbm.cxx:508
virtual void restoreAnnotationMarks(bool bDelete=true)=0
virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition &rPos) const =0
Finds the first mark that is starting after.
virtual void ClearFieldActivation()=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.
static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const &rMark)
Definition: docbm.cxx:522
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark, bool isMoveNodes)=0
Deletes a mark.
virtual const_iterator_t findBookmark(const OUString &rMark) const =0
Finds a bookmark by name.
virtual ::sw::mark::IFieldmark * changeFormFieldmarkType(::sw::mark::IFieldmark *pFieldmark, const OUString &rNewType)=0
virtual void deleteFieldmarkAt(const SwPosition &rPos)=0
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 const_iterator_t getAllMarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of marks.
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, MarkType eMark)=0
Returns a mark in the document for a paragraph.
static SW_DLLPUBLIC bool IsLegalPaMForCrossRefHeadingBookmark(const SwPaM &rPaM)
Definition: docbm.cxx:513
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:474
virtual const_iterator_t getBookmarksEnd() const =0
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
virtual sal_Int32 getBookmarksCount() const =0
returns the number of IBookmarks.
virtual sw::mark::IMark * makeAnnotationMark(const SwPaM &rPaM, const OUString &rName)=0
Marks a character position inside a document model node.
Definition: index.hxx:34
Marks a node in the document model.
Definition: ndindex.hxx:31
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:138
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:84
SotClipboardFormatId & operator++(SotClipboardFormatId &eFormat)
HSLColor operator*(double nFactor, const HSLColor &rRHS)
bool operator>(const Style &rL, const Style &rR)
InsertMode
Definition: IMark.hxx:32
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
std::enable_if< std::is_signed< T >::value, SwNodeOffset >::type operator-(SwNodeOffset a, T n)
Definition: nodeoffset.hxx:29
std::enable_if< std::is_signed< T >::value, SwNodeOffset >::type operator+(SwNodeOffset a, T n)
Definition: nodeoffset.hxx:21
timeval & operator-=(timeval &t1, const timeval &t2)
To avoid recursive calls of deleteMark, the removal of dummy characters of fieldmarks has to be delay...
Marks a position in the document model.
Definition: pam.hxx:37
TOOLS_DLLPUBLIC tools::Rectangle & operator+=(tools::Rectangle &rRect, const SvBorder &rBorder)
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
bool operator<(const wwFont &r1, const wwFont &r2)
Definition: wrtw8sty.cxx:841
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)