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#pragma once
21
22#include <sal/types.h>
23#include "IMark.hxx"
24#include <memory>
25#include <optional>
26
27class SwPaM;
28struct SwPosition;
29class SwTextNode;
30class SwCursorShell;
31
32namespace sw::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 {
44 UNO_BOOKMARK,
45 DDE_BOOKMARK,
47 CROSSREF_HEADING_BOOKMARK,
48 CROSSREF_NUMITEM_BOOKMARK,
49 ANNOTATIONMARK,
50 TEXT_FIELDMARK,
51 CHECKBOX_FIELDMARK,
52 DROPDOWN_FIELDMARK,
53 DATE_FIELDMARK,
54 NAVIGATOR_REMINDER
55 };
56
61 {
62 private:
63 std::optional<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;
71 typedef ::sw::mark::IMark* const* pointer;
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
82 // FIXME unfortunately there's a requirement on input iterator
83 // and forward iterator to return reference, which isn't
84 // possible because we have to return a temp value;
85 // let's try value_type instead, perhaps it's sufficient,
86 // for a const_iterator...
87 ::sw::mark::IMark* /*const&*/ operator*() const;
88 // nope can't do that :(
89 //::sw::mark::IMark* /* const* */ operator->() const;
92 bool operator==(iterator const& rOther) const;
93 bool operator!=(iterator const& rOther) const;
94 iterator& operator--();
95 iterator operator--(int);
100 difference_type operator-(iterator const&) const;
101 value_type operator[](difference_type) const;
102 bool operator<(iterator const& rOther) const;
103 bool operator>(iterator const& rOther) const;
104 bool operator<=(iterator const& rOther) const;
105 bool operator>=(iterator const& rOther) const;
106 };
107
109
113 struct ILazyDeleter { virtual ~ILazyDeleter() { } };
114
132 virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM,
133 const OUString& rProposedName,
134 MarkType eMark, ::sw::mark::InsertMode eMode,
135 SwPosition const* pSepPos = nullptr) = 0;
136
137 virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
138 const OUString& rName,
139 const OUString& rType,
140 SwPosition const* pSepPos = nullptr) = 0;
141 virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
142 const OUString& rName,
143 const OUString& rType) = 0;
144
146 const SwPaM& rPaM,
147 const OUString& rName ) = 0;
148
161 virtual ::sw::mark::IMark* getMarkForTextNode(const SwTextNode& rTextNode,
162 MarkType eMark) =0;
163
172 virtual void repositionMark(::sw::mark::IMark* io_pMark,
173 const SwPaM& rPaM) =0;
174
184 virtual bool renameMark(::sw::mark::IMark* io_pMark,
185 const OUString& rNewName) =0;
186
199 virtual void correctMarksAbsolute(const SwNode& rOldNode,
200 const SwPosition& rNewPos,
201 const sal_Int32 nOffset) =0;
202
217 virtual void correctMarksRelative(const SwNode& rOldNode,
218 const SwPosition& rNewPos,
219 const sal_Int32 nOffset) =0;
220
226 virtual void deleteMarks(
227 const SwNode& rStt,
228 const SwNode& rEnd,
229 std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, // Ugly: SaveBookmark is core-internal
230 std::optional<sal_Int32> oStartContentIdx,
231 std::optional<sal_Int32> oEndContentIdx) =0;
232
241 virtual std::unique_ptr<ILazyDeleter>
242 deleteMark(const IDocumentMarkAccess::const_iterator_t& ppMark, bool isMoveNodes) =0;
243
249 virtual void deleteMark(const ::sw::mark::IMark* const pMark) =0;
250
253 virtual void clearAllMarks() =0;
254
255 virtual void assureSortedMarkContainers() const = 0;
256
260
264
269 virtual sal_Int32 getAllMarksCount() const =0;
270
279 virtual const_iterator_t findMark(const OUString& rMark) const =0;
280
281 // interface IBookmarks (BOOKMARK, CROSSREF_NUMITEM_BOOKMARK, CROSSREF_HEADING_BOOKMARK )
282
284 virtual bool isBookmarkDeleted(SwPaM const& rPaM, bool isReplace) const =0;
285
289
293
296 virtual sal_Int32 getBookmarksCount() const =0;
297
306 virtual const_iterator_t findBookmark(const OUString& rMark) const =0;
307
314
317
318 // Fieldmarks
322
326
328 virtual sal_Int32 getFieldmarksCount() const = 0;
329
331 virtual ::sw::mark::IFieldmark* getFieldmarkAt(const SwPosition& rPos) const =0;
332 virtual sw::mark::IFieldmark* getInnerFieldmarkFor(const SwPosition& pos) const = 0;
333 virtual sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& pos, bool bLoop) const =0;
334 virtual sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& pos, bool bLoop) const =0;
335
336 virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition& pos) const=0;
337 virtual std::vector<::sw::mark::IFieldmark*> getNoTextFieldmarksIn(const SwPaM &rPaM) const=0;
338
339 virtual void deleteFieldmarkAt(const SwPosition& rPos) = 0;
340 virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) = 0;
341
342 virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) = 0;
343 virtual void ClearFieldActivation() = 0;
344
345 // Annotation Marks
348 virtual sal_Int32 getAnnotationMarksCount() const = 0;
349 virtual const_iterator_t findAnnotationMark( const OUString& rName ) const = 0;
350 virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPosition) const = 0;
351 // handle and restore text ranges of annotations of tracked deletions
352 // based on the helper bookmarks (which can survive I/O and hiding redlines)
353 virtual ::sw::mark::IMark* makeAnnotationBookmark(const SwPaM& rPaM,
354 const OUString& rProposedName,
355 MarkType eMark, ::sw::mark::InsertMode eMode,
356 SwPosition const* pSepPos = nullptr) = 0;
357 virtual const_iterator_t findAnnotationBookmark( const OUString& rName ) const = 0;
358 virtual void restoreAnnotationMarks(bool bDelete = true) = 0;
365
368 static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark& rMark);
369
372 static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const& rMark);
373
374 protected:
376};
377
378/* 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, bool bLoop) const =0
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 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 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 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 sw::mark::IFieldmark * getInnerFieldmarkFor(const SwPosition &pos) const =0
virtual const_iterator_t findMark(const OUString &rMark) const =0
Finds a mark by name.
virtual sw::mark::IFieldmark * getFieldmarkAfter(const SwPosition &pos, bool bLoop) const =0
virtual void correctMarksRelative(const SwNode &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.
virtual sal_Int32 getFieldmarksCount() const =0
returns the number of IFieldmarks.
static SW_DLLPUBLIC OUString GetCrossRefHeadingBookmarkNamePrefix()
Definition: docbm.cxx:536
virtual void restoreAnnotationMarks(bool bDelete=true)=0
virtual bool isBookmarkDeleted(SwPaM const &rPaM, bool isReplace) const =0
check if the selection would delete a BOOKMARK
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.
virtual void deleteMarks(const SwNode &rStt, const SwNode &rEnd, std::vector< ::sw::mark::SaveBookmark > *pSaveBkmk, std::optional< sal_Int32 > oStartContentIdx, std::optional< sal_Int32 > oEndContentIdx)=0
Deletes marks in a range.
static void DeleteFieldmarkCommand(::sw::mark::IFieldmark const &rMark)
Definition: docbm.cxx:550
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 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:541
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:502
virtual void correctMarksAbsolute(const SwNode &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 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
virtual sw::mark::IMark * getOneInnermostBookmarkFor(const SwPosition &rPos) const =0
Get the innermost bookmark that contains rPos.
Base class of the Writer document model elements.
Definition: node.hxx:98
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:188
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:112
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:38
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:885
bool operator!=(const XclExpString &rLeft, const XclExpString &rRight)
bool operator==(const XclFontData &rLeft, const XclFontData &rRight)