1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_SW_SOURCE_CORE_INC_MARKMANAGER_HXX
21 #define INCLUDED_SW_SOURCE_CORE_INC_MARKMANAGER_HXX
24 #include <IDocumentMarkAccess.hxx>
25 #include <unordered_map>
32 typedef std::unordered_map
<OUString
, sal_Int32
> MarkBasenameMapUniqueOffset_t
;
34 class FieldmarkWithDropDownButton
;
36 class MarkManager final
37 : virtual public IDocumentMarkAccess
40 MarkManager(/*[in/out]*/ SwDoc
& rDoc
);
41 // IDocumentMarkAccess
42 virtual ::sw::mark::IMark
* makeMark(const SwPaM
& rPaM
,
43 const OUString
& rName
, IDocumentMarkAccess::MarkType eMark
,
44 sw::mark::InsertMode eMode
,
45 SwPosition
const* pSepPos
= nullptr) override
;
47 virtual sw::mark::IFieldmark
* makeFieldBookmark( const SwPaM
& rPaM
,
48 const OUString
& rName
,
49 const OUString
& rType
,
50 SwPosition
const* pSepPos
= nullptr) override
;
51 virtual sw::mark::IFieldmark
* makeNoTextFieldBookmark( const SwPaM
& rPaM
,
52 const OUString
& rName
,
53 const OUString
& rType
) override
;
55 virtual ::sw::mark::IMark
* getMarkForTextNode(const SwTextNode
& rTextNode
, IDocumentMarkAccess::MarkType eMark
) override
;
57 virtual sw::mark::IMark
* makeAnnotationMark(
59 const OUString
& rName
) override
;
61 virtual void repositionMark(::sw::mark::IMark
* io_pMark
, const SwPaM
& rPaM
) override
;
62 virtual bool renameMark(::sw::mark::IMark
* io_pMark
, const OUString
& rNewName
) override
;
63 virtual void correctMarksAbsolute(const SwNode
& rOldNode
, const SwPosition
& rNewPos
, const sal_Int32 nOffset
) override
;
64 virtual void correctMarksRelative(const SwNode
& rOldNode
, const SwPosition
& rNewPos
, const sal_Int32 nOffset
) override
;
66 virtual void deleteMarks(const SwNode
& rStt
,
68 std::vector
< ::sw::mark::SaveBookmark
>* pSaveBkmk
,
69 std::optional
<sal_Int32
> oStartContentIdx
,
70 std::optional
<sal_Int32
> oEndContentIdx
) override
;
73 virtual std::unique_ptr
<ILazyDeleter
>
74 deleteMark(const const_iterator_t
& ppMark
, bool isMoveNodes
) override
;
75 virtual void deleteMark(const ::sw::mark::IMark
* const pMark
) override
;
76 virtual void clearAllMarks() override
;
79 virtual const_iterator_t
getAllMarksBegin() const override
;
80 virtual const_iterator_t
getAllMarksEnd() const override
;
81 virtual sal_Int32
getAllMarksCount() const override
;
82 virtual const_iterator_t
findMark(const OUString
& rName
) const override
;
85 virtual bool isBookmarkDeleted(SwPaM
const& rPaM
, bool isReplace
) const override
;
86 virtual const_iterator_t
getBookmarksBegin() const override
;
87 virtual const_iterator_t
getBookmarksEnd() const override
;
88 virtual sal_Int32
getBookmarksCount() const override
;
89 virtual const_iterator_t
findBookmark(const OUString
& rName
) const override
;
90 virtual const_iterator_t
findFirstBookmarkStartsAfter(const SwPosition
& rPos
) const override
;
91 virtual ::sw::mark::IMark
* getOneInnermostBookmarkFor(const SwPosition
& rPos
) const override
;
94 virtual const_iterator_t
getFieldmarksBegin() const override
;
95 virtual const_iterator_t
getFieldmarksEnd() const override
;
96 virtual sal_Int32
getFieldmarksCount() const override
;
97 virtual ::sw::mark::IFieldmark
* getFieldmarkAt(const SwPosition
& rPos
) const override
;
98 virtual sw::mark::IFieldmark
* getInnerFieldmarkFor(const SwPosition
& rPos
) const override
;
99 virtual sw::mark::IFieldmark
* getFieldmarkBefore(const SwPosition
& rPos
, bool bLoop
) const override
;
100 virtual sw::mark::IFieldmark
* getFieldmarkAfter(const SwPosition
& rPos
, bool bLoop
) const override
;
102 virtual ::sw::mark::IFieldmark
* getDropDownFor(const SwPosition
&rPos
) const override
;
103 virtual std::vector
<::sw::mark::IFieldmark
*> getNoTextFieldmarksIn(const SwPaM
&rPaM
) const override
;
105 virtual void deleteFieldmarkAt(const SwPosition
& rPos
) override
;
106 virtual ::sw::mark::IFieldmark
* changeFormFieldmarkType(::sw::mark::IFieldmark
* pFieldmark
, const OUString
& rNewType
) override
;
108 virtual void NotifyCursorUpdate(const SwCursorShell
& rCursorShell
) override
;
109 virtual void ClearFieldActivation() override
;
110 void LOKUpdateActiveField(const SfxViewShell
* pViewShell
);
112 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
115 virtual const_iterator_t
getAnnotationMarksBegin() const override
;
116 virtual const_iterator_t
getAnnotationMarksEnd() const override
;
117 virtual sal_Int32
getAnnotationMarksCount() const override
;
118 virtual const_iterator_t
findAnnotationMark( const OUString
& rName
) const override
;
119 virtual sw::mark::IMark
* getAnnotationMarkFor(const SwPosition
& rPos
) const override
;
120 virtual const_iterator_t
findFirstAnnotationStartsAfter(const SwPosition
& rPos
) const override
;
122 virtual void assureSortedMarkContainers() const override
;
124 typedef std::vector
<sw::mark::MarkBase
*> container_t
;
126 // helper bookmark to store annotation range of redlines
127 virtual ::sw::mark::IMark
* makeAnnotationBookmark(const SwPaM
& rPaM
,
128 const OUString
& rName
, IDocumentMarkAccess::MarkType eMark
,
129 sw::mark::InsertMode eMode
,
130 SwPosition
const* pSepPos
= nullptr) override
;
131 virtual const_iterator_t
findAnnotationBookmark( const OUString
& rName
) const override
;
132 virtual void restoreAnnotationMarks(bool bDelete
= true) override
;
136 MarkManager(MarkManager
const&) = delete;
137 MarkManager
& operator=(MarkManager
const&) = delete;
140 OUString
getUniqueMarkName(const OUString
& rName
) const;
142 void sortSubsetMarks();
145 // container for all marks, this container owns the objects it points to
146 container_t m_vAllMarks
;
148 // additional container for bookmarks
149 container_t m_vBookmarks
;
150 // additional container for fieldmarks
151 container_t m_vFieldmarks
;
153 mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset
;
155 // container for annotation marks
156 container_t m_vAnnotationMarks
;
160 sw::mark::FieldmarkWithDropDownButton
* m_pLastActiveFieldmark
;
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */