LibreOffice Module sw (master)  1
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
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 .
18  */
23 #include <IMark.hxx>
24 #include <IDocumentMarkAccess.hxx>
25 #include <unordered_map>
26 #include <memory>
28 class SwCursorShell;
30 namespace sw {
31  namespace mark {
32  typedef std::unordered_map<OUString, sal_Int32> MarkBasenameMapUniqueOffset_t;
37  : virtual public IDocumentMarkAccess
38  {
39  public:
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) override;
46  virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
47  const OUString& rName,
48  const OUString& rType) override;
50  const OUString& rName,
51  const OUString& rType) override;
53  virtual ::sw::mark::IMark* getMarkForTextNode(const SwTextNode& rTextNode, IDocumentMarkAccess::MarkType eMark) override;
56  const SwPaM& rPaM,
57  const OUString& rName ) override;
59  virtual void repositionMark(::sw::mark::IMark* io_pMark, const SwPaM& rPaM) override;
60  virtual bool renameMark(::sw::mark::IMark* io_pMark, const OUString& rNewName) override;
61  virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset) override;
62  virtual void correctMarksRelative(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset) override;
64  virtual void deleteMarks(const SwNodeIndex& rStt, const SwNodeIndex& rEnd, std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, const SwIndex* pSttIdx, const SwIndex* pEndIdx) override;
66  // deleters
67  virtual std::unique_ptr<ILazyDeleter>
68  deleteMark(const const_iterator_t& ppMark) override;
69  virtual void deleteMark(const ::sw::mark::IMark* const pMark) override;
70  virtual void clearAllMarks() override;
72  // marks
73  virtual const_iterator_t getAllMarksBegin() const override;
74  virtual const_iterator_t getAllMarksEnd() const override;
75  virtual sal_Int32 getAllMarksCount() const override;
76  virtual const_iterator_t findMark(const OUString& rName) const override;
77  virtual const_iterator_t findFirstMarkStartsBefore(const SwPosition& rPos) const override;
79  // bookmarks
80  virtual const_iterator_t getBookmarksBegin() const override;
81  virtual const_iterator_t getBookmarksEnd() const override;
82  virtual sal_Int32 getBookmarksCount() const override;
83  virtual const_iterator_t findBookmark(const OUString& rName) const override;
84  virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition& rPos) const override;
86  // Fieldmarks
87  virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& rPos) const override;
88  virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& rPos) const override;
89  virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos) const override;
91  virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition &rPos) const override;
92  virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const override;
94  virtual void deleteFieldmarkAt(const SwPosition& rPos) override;
95  virtual ::sw::mark::IFieldmark* changeFormFieldmarkType(::sw::mark::IFieldmark* pFieldmark, const OUString& rNewType) override;
97  virtual void NotifyCursorUpdate(const SwCursorShell& rCursorShell) override;
98  virtual void ClearFieldActivation() override;
100  void dumpAsXml(xmlTextWriterPtr pWriter) const;
102  // Annotation Marks
103  virtual const_iterator_t getAnnotationMarksBegin() const override;
104  virtual const_iterator_t getAnnotationMarksEnd() const override;
105  virtual sal_Int32 getAnnotationMarksCount() const override;
106  virtual const_iterator_t findAnnotationMark( const OUString& rName ) const override;
107  virtual sw::mark::IMark* getAnnotationMarkFor(const SwPosition& rPos) const override;
108  virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition& rPos) const override;
110  virtual void assureSortedMarkContainers() const override;
112  typedef std::vector<sw::mark::MarkBase*> container_t;
114  private:
116  MarkManager(MarkManager const&) = delete;
117  MarkManager& operator=(MarkManager const&) = delete;
119  // make names
120  OUString getUniqueMarkName(const OUString& rName) const;
121  public: // FIXME should be private, needs refactor
122  void sortMarks();
123  private:
124  void sortSubsetMarks();
126  // container for all marks, this container owns the objects it points to
127  container_t m_vAllMarks;
129  // additional container for bookmarks
130  container_t m_vBookmarks;
131  // additional container for fieldmarks
132  container_t m_vFieldmarks;
134  mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset;
136  // container for annotation marks
137  container_t m_vAnnotationMarks;
139  SwDoc * const m_pDoc;
142  };
143  } // namespace mark
144 }
146 #endif
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual sw::mark::IMark * getAnnotationMarkFor(const SwPosition &rPos) const override
Definition: docbm.cxx:1441
virtual const_iterator_t findFirstAnnotationStartsAfter(const SwPosition &rPos) const override
Finds the first mark that is starting after.
Definition: docbm.cxx:1453
virtual sal_Int32 getAllMarksCount() const override
returns the number of marks.
Definition: docbm.cxx:1242
Marks a position in the document model.
Definition: pam.hxx:35
sw::mark::FieldmarkWithDropDownButton * m_pLastActiveFieldmark
virtual const_iterator_t findFirstBookmarkStartsAfter(const SwPosition &rPos) const override
Finds the first mark that is starting after.
Definition: docbm.cxx:1255
wrapper iterator: wraps iterator of implementation while hiding MarkBase class; only IMark instances ...
container_t m_vFieldmarks
OUString getUniqueMarkName(const OUString &rName) const
Definition: docbm.cxx:1462
Provides access to the marks of a document.
Definition: doc.hxx:185
virtual ::sw::mark::IFieldmark * getFieldmarkAfter(const SwPosition &rPos) const override
Definition: docbm.cxx:1414
virtual const_iterator_t getAllMarksBegin() const override
returns a STL-like random access iterator to the begin of the sequence of marks.
Definition: docbm.cxx:1236
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
virtual const_iterator_t getAnnotationMarksBegin() const override
Definition: docbm.cxx:1420
virtual ::sw::mark::IFieldmark * getFieldmarkFor(const SwPosition &rPos) const override
Definition: docbm.cxx:1264
Fieldmark with a drop down button (e.g. this button opens the date picker for a date field) ...
Definition: bookmrk.hxx:273
virtual sw::mark::IFieldmark * makeNoTextFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType) override
Definition: docbm.cxx:690
virtual const_iterator_t findFirstMarkStartsBefore(const SwPosition &rPos) const override
Find the first Mark that does not start before.
Definition: docbm.cxx:1227
virtual const_iterator_t getBookmarksEnd() const override
returns a STL-like random access iterator to the end of the sequence of IBookmarks.
Definition: docbm.cxx:1248
virtual void clearAllMarks() override
Clear (deletes) all marks.
Definition: docbm.cxx:1203
container_t m_vBookmarks
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docbm.cxx:1520
virtual ::sw::mark::IMark * getMarkForTextNode(const SwTextNode &rTextNode, IDocumentMarkAccess::MarkType eMark) override
Returns a mark in the document for a paragraph.
Definition: docbm.cxx:738
virtual void deleteMarks(const SwNodeIndex &rStt, const SwNodeIndex &rEnd, std::vector< ::sw::mark::SaveBookmark > *pSaveBkmk, const SwIndex *pSttIdx, const SwIndex *pEndIdx) override
Deletes marks in a range.
Definition: docbm.cxx:906
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
struct _xmlTextWriter * xmlTextWriterPtr
virtual sal_Int32 getAnnotationMarksCount() const override
Definition: docbm.cxx:1430
container_t m_vAnnotationMarks
virtual const_iterator_t getAnnotationMarksEnd() const override
Definition: docbm.cxx:1425
std::vector< sw::mark::MarkBase * > container_t
virtual void assureSortedMarkContainers() const override
Definition: docbm.cxx:1502
MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset
virtual const_iterator_t findMark(const OUString &rName) const override
Finds a mark by name.
Definition: docbm.cxx:1214
virtual std::unique_ptr< ILazyDeleter > deleteMark(const const_iterator_t &ppMark) override
Deletes a mark.
Definition: docbm.cxx:1103
virtual bool renameMark(::sw::mark::IMark *io_pMark, const OUString &rNewName) override
Renames an existing Mark, if possible.
Definition: docbm.cxx:782
Marks a character position inside a document model node.
Definition: index.hxx:37
std::unordered_map< OUString, sal_Int32 > MarkBasenameMapUniqueOffset_t
Definition: MarkManager.hxx:32
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual const_iterator_t getAllMarksEnd() const override
returns a STL-like random access iterator to the end of the sequence of marks.
Definition: docbm.cxx:1239
virtual const_iterator_t findAnnotationMark(const OUString &rName) const override
Definition: docbm.cxx:1435
virtual sw::mark::IMark * makeAnnotationMark(const SwPaM &rPaM, const OUString &rName) override
Definition: docbm.cxx:751
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
virtual sal_Int32 getBookmarksCount() const override
returns the number of IBookmarks.
Definition: docbm.cxx:1251
virtual void correctMarksAbsolute(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset) override
Corrects marks (absolute) This method ignores the previous position of the mark in the paragraph...
Definition: docbm.cxx:811
virtual void NotifyCursorUpdate(const SwCursorShell &rCursorShell) override
Definition: docbm.cxx:1337
MarkManager & operator=(MarkManager const &)=delete
virtual sw::mark::IFieldmark * makeFieldBookmark(const SwPaM &rPaM, const OUString &rName, const OUString &rType) override
Definition: docbm.cxx:655
virtual const_iterator_t findBookmark(const OUString &rName) const override
Finds a bookmark by name.
Definition: docbm.cxx:1220
virtual void correctMarksRelative(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset) override
Corrects marks (relative) This method uses the previous position of the mark in the paragraph as offs...
Definition: docbm.cxx:857
virtual ::sw::mark::IFieldmark * getFieldmarkBefore(const SwPosition &rPos) const override
Definition: docbm.cxx:1417
virtual ::sw::mark::IFieldmark * getDropDownFor(const SwPosition &rPos) const override
Definition: docbm.cxx:1384
virtual void deleteFieldmarkAt(const SwPosition &rPos) override
Definition: docbm.cxx:1275
virtual std::vector< ::sw::mark::IFieldmark * > getDropDownsFor(const SwPaM &rPaM) const override
Definition: docbm.cxx:1392
virtual ::sw::mark::IFieldmark * changeFormFieldmarkType(::sw::mark::IFieldmark *pFieldmark, const OUString &rNewType) override
Definition: docbm.cxx:1287
virtual void ClearFieldActivation() override
Definition: docbm.cxx:1376
Definition: IMark.hxx:31
MarkManager(SwDoc &rDoc)
Definition: docbm.cxx:533
virtual const_iterator_t getBookmarksBegin() const override
returns a STL-like random access iterator to the begin of the sequence the IBookmarks.
Definition: docbm.cxx:1245
virtual void repositionMark(::sw::mark::IMark *io_pMark, const SwPaM &rPaM) override
Moves an existing mark to a new selection and performs needed updates.
Definition: docbm.cxx:759
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rName, IDocumentMarkAccess::MarkType eMark, sw::mark::InsertMode eMode) override
Definition: docbm.cxx:542