Line data Source code
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_SOURCE_CORE_INC_MARKMANAGER_HXX
21 : #define INCLUDED_SW_SOURCE_CORE_INC_MARKMANAGER_HXX
22 :
23 : #include <IMark.hxx>
24 : #include <IDocumentMarkAccess.hxx>
25 : #include <boost/unordered_set.hpp>
26 : #include <boost/unordered_map.hpp>
27 :
28 : namespace sw {
29 : namespace mark {
30 : typedef boost::unordered_map<OUString, sal_Int32, OUStringHash> MarkBasenameMapUniqueOffset_t;
31 :
32 0 : class MarkManager
33 : : private ::boost::noncopyable
34 : , virtual public IDocumentMarkAccess
35 : {
36 : public:
37 : MarkManager(/*[in/out]*/ SwDoc& rDoc);
38 : // IDocumentMarkAccess
39 : virtual ::sw::mark::IMark* makeMark(const SwPaM& rPaM, const OUString& rName, IDocumentMarkAccess::MarkType eMark) SAL_OVERRIDE;
40 :
41 : virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
42 : const OUString& rName,
43 : const OUString& rType) SAL_OVERRIDE;
44 : virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
45 : const OUString& rName,
46 : const OUString& rType) SAL_OVERRIDE;
47 :
48 : virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode, IDocumentMarkAccess::MarkType eMark) SAL_OVERRIDE;
49 :
50 : virtual sw::mark::IMark* makeAnnotationMark(
51 : const SwPaM& rPaM,
52 : const ::rtl::OUString& rName ) SAL_OVERRIDE;
53 :
54 : virtual void repositionMark(::sw::mark::IMark* io_pMark, const SwPaM& rPaM) SAL_OVERRIDE;
55 : virtual bool renameMark(::sw::mark::IMark* io_pMark, const OUString& rNewName) SAL_OVERRIDE;
56 : virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset) SAL_OVERRIDE;
57 : virtual void correctMarksRelative(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const sal_Int32 nOffset) SAL_OVERRIDE;
58 :
59 : virtual void deleteMarks(const SwNodeIndex& rStt, const SwNodeIndex& rEnd, ::std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, const SwIndex* pSttIdx, const SwIndex* pEndIdx) SAL_OVERRIDE;
60 :
61 : // deleters
62 : virtual ::boost::shared_ptr<ILazyDeleter>
63 : deleteMark(const const_iterator_t ppMark) SAL_OVERRIDE;
64 : virtual void deleteMark(const ::sw::mark::IMark* const pMark) SAL_OVERRIDE;
65 : virtual void clearAllMarks() SAL_OVERRIDE;
66 :
67 : // marks
68 : virtual const_iterator_t getAllMarksBegin() const SAL_OVERRIDE;
69 : virtual const_iterator_t getAllMarksEnd() const SAL_OVERRIDE;
70 : virtual sal_Int32 getAllMarksCount() const SAL_OVERRIDE;
71 : virtual const_iterator_t findMark(const OUString& rName) const SAL_OVERRIDE;
72 : virtual bool hasMark(const OUString& rName) const;
73 :
74 : // bookmarks
75 : virtual const_iterator_t getBookmarksBegin() const SAL_OVERRIDE;
76 : virtual const_iterator_t getBookmarksEnd() const SAL_OVERRIDE;
77 : virtual sal_Int32 getBookmarksCount() const SAL_OVERRIDE;
78 : virtual const_iterator_t findBookmark(const OUString& rName) const SAL_OVERRIDE;
79 :
80 : // Fieldmarks
81 : virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& rPos) const SAL_OVERRIDE;
82 : virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& rPos) const SAL_OVERRIDE;
83 : virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos) const SAL_OVERRIDE;
84 :
85 : virtual ::sw::mark::IFieldmark* getDropDownFor(const SwPosition &rPos) const SAL_OVERRIDE;
86 : virtual std::vector< ::sw::mark::IFieldmark* > getDropDownsFor(const SwPaM &rPaM) const SAL_OVERRIDE;
87 :
88 : void dumpAsXml(xmlTextWriterPtr w);
89 :
90 : // Marks exclusive annotation marks
91 : virtual const_iterator_t getCommonMarksBegin() const SAL_OVERRIDE;
92 : virtual const_iterator_t getCommonMarksEnd() const SAL_OVERRIDE;
93 : virtual sal_Int32 getCommonMarksCount() const SAL_OVERRIDE;
94 :
95 : // Annotation Marks
96 : virtual const_iterator_t getAnnotationMarksBegin() const SAL_OVERRIDE;
97 : virtual const_iterator_t getAnnotationMarksEnd() const SAL_OVERRIDE;
98 : virtual sal_Int32 getAnnotationMarksCount() const SAL_OVERRIDE;
99 : virtual const_iterator_t findAnnotationMark( const ::rtl::OUString& rName ) const SAL_OVERRIDE;
100 :
101 : virtual void assureSortedMarkContainers() const SAL_OVERRIDE;
102 :
103 : private:
104 : // make names
105 : OUString getUniqueMarkName(const OUString& rName) const;
106 : void sortMarks();
107 : void sortSubsetMarks();
108 :
109 : // container for all marks
110 : container_t m_vAllMarks;
111 :
112 : // additional container for bookmarks
113 : container_t m_vBookmarks;
114 : // additional container for fieldmarks
115 : container_t m_vFieldmarks;
116 :
117 : boost::unordered_set<OUString, OUStringHash> m_aMarkNamesSet;
118 : mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset;
119 :
120 : // container for annotation marks
121 : container_t m_vAnnotationMarks;
122 :
123 : // container for all marks except annotation marks
124 : container_t m_vCommonMarks;
125 :
126 : SwDoc * const m_pDoc;
127 : };
128 : } // namespace mark
129 : }
130 :
131 : #endif
132 :
133 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|