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 _SW_BOOKMARK_MARKMANAGER_HXX
21 : #define _SW_BOOKMARK_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<rtl::OUString, sal_Int32, rtl::OUStringHash> MarkBasenameMapUniqueOffset_t;
31 :
32 204 : 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 ::rtl::OUString& rName, IDocumentMarkAccess::MarkType eMark);
40 :
41 : virtual sw::mark::IFieldmark* makeFieldBookmark( const SwPaM& rPaM,
42 : const rtl::OUString& rName,
43 : const rtl::OUString& rType);
44 : virtual sw::mark::IFieldmark* makeNoTextFieldBookmark( const SwPaM& rPaM,
45 : const rtl::OUString& rName,
46 : const rtl::OUString& rType);
47 :
48 : virtual ::sw::mark::IMark* getMarkForTxtNode(const SwTxtNode& rTxtNode, IDocumentMarkAccess::MarkType eMark);
49 :
50 : virtual void repositionMark(::sw::mark::IMark* io_pMark, const SwPaM& rPaM);
51 : virtual bool renameMark(::sw::mark::IMark* io_pMark, const ::rtl::OUString& rNewName);
52 : virtual void correctMarksAbsolute(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const xub_StrLen nOffset);
53 : virtual void correctMarksRelative(const SwNodeIndex& rOldNode, const SwPosition& rNewPos, const xub_StrLen nOffset);
54 :
55 : virtual void deleteMarks(const SwNodeIndex& rStt, const SwNodeIndex& rEnd, ::std::vector< ::sw::mark::SaveBookmark>* pSaveBkmk, const SwIndex* pSttIdx, const SwIndex* pEndIdx);
56 :
57 : // deleters
58 : virtual void deleteMark(const const_iterator_t ppMark);
59 : virtual void deleteMark(const ::sw::mark::IMark* const pMark);
60 : virtual void clearAllMarks();
61 :
62 : // marks
63 : virtual const_iterator_t getMarksBegin() const;
64 : virtual const_iterator_t getMarksEnd() const;
65 : virtual sal_Int32 getMarksCount() const;
66 : virtual const_iterator_t findMark(const ::rtl::OUString& rName) const;
67 : virtual bool hasMark(const ::rtl::OUString& rName) const;
68 :
69 : // bookmarks
70 : virtual const_iterator_t getBookmarksBegin() const;
71 : virtual const_iterator_t getBookmarksEnd() const;
72 : virtual sal_Int32 getBookmarksCount() const;
73 : virtual const_iterator_t findBookmark(const ::rtl::OUString& rName) const;
74 :
75 : // Fieldmarks
76 : virtual ::sw::mark::IFieldmark* getFieldmarkFor(const SwPosition& rPos) const;
77 : virtual ::sw::mark::IFieldmark* getFieldmarkBefore(const SwPosition& rPos) const;
78 : virtual ::sw::mark::IFieldmark* getFieldmarkAfter(const SwPosition& rPos) const;
79 :
80 : private:
81 : // make names
82 : ::rtl::OUString getUniqueMarkName(const ::rtl::OUString& rName) const;
83 : void sortMarks();
84 :
85 : container_t m_vMarks;
86 : container_t m_vBookmarks;
87 : container_t m_vFieldmarks;
88 : boost::unordered_set<rtl::OUString, rtl::OUStringHash> m_aMarkNamesSet;
89 : mutable MarkBasenameMapUniqueOffset_t m_aMarkBasenameMapUniqueOffset;
90 : SwDoc * const m_pDoc;
91 : };
92 : } // namespace mark
93 : }
94 :
95 : #endif
96 :
97 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|