Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / sw / inc / IMark.hxx
blobf4b38a9a189bd16539748f3986ca7d532a35ecb8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SW_INC_IMARK_HXX
20 #define INCLUDED_SW_INC_IMARK_HXX
22 #include <vcl/keycod.hxx>
23 #include <calbck.hxx>
24 #include <pam.hxx>
25 #include <boost/operators.hpp>
26 #include <map>
27 #include <memory>
28 #include <swdllapi.h>
30 struct SwPosition;
32 namespace sw { namespace mark
34 enum class InsertMode
36 New,
37 CopyText,
40 class SW_DLLPUBLIC IMark
41 : virtual public SwModify // inherited as interface
42 , public ::boost::totally_ordered<IMark>
44 protected:
45 IMark() = default;
47 public:
48 //getters
49 virtual const SwPosition& GetMarkPos() const =0;
50 // GetOtherMarkPos() is only guaranteed to return a valid
51 // reference if IsExpanded() returned true
52 virtual const SwPosition& GetOtherMarkPos() const =0;
53 virtual const SwPosition& GetMarkStart() const =0;
54 virtual const SwPosition& GetMarkEnd() const =0;
55 virtual const OUString& GetName() const =0;
56 virtual bool IsExpanded() const =0;
57 virtual bool IsCoveringPosition(const SwPosition& rPos) const =0;
59 //setters
60 // not available in IMark
61 // inside core, you can cast to MarkBase and use its setters,
62 // make sure to update the sorting in Markmanager in this case
64 //operators and comparisons (non-virtual)
65 bool operator<(const IMark& rOther) const
66 { return GetMarkStart() < rOther.GetMarkStart(); }
67 bool operator==(const IMark& rOther) const
68 { return GetMarkStart() == rOther.GetMarkStart(); }
69 bool StartsBefore(const SwPosition& rPos) const
70 { return GetMarkStart() < rPos; }
71 bool StartsAfter(const SwPosition& rPos) const
72 { return GetMarkStart() > rPos; }
73 bool EndsBefore(const SwPosition& rPos) const
74 { return GetMarkEnd() < rPos; }
76 virtual OUString ToString( ) const =0;
77 virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const = 0;
78 private:
79 IMark(IMark&) = delete;
80 IMark &operator =(IMark const&) = delete;
83 class SW_DLLPUBLIC IBookmark
84 : virtual public IMark
86 protected:
87 IBookmark() = default;
89 public:
90 virtual const OUString& GetShortName() const =0;
91 virtual const vcl::KeyCode& GetKeyCode() const =0;
92 virtual void SetShortName(const OUString&) =0;
93 virtual void SetKeyCode(const vcl::KeyCode&) =0;
94 private:
95 IBookmark(IBookmark&) = delete;
96 IBookmark &operator =(IBookmark const&) = delete;
99 class SW_DLLPUBLIC IFieldmark
100 : virtual public IMark
102 protected:
103 IFieldmark() = default;
105 public:
106 typedef std::map< OUString, css::uno::Any> parameter_map_t;
107 //getters
108 virtual OUString GetFieldname() const =0;
109 virtual OUString GetFieldHelptext() const =0;
110 virtual parameter_map_t* GetParameters() =0;
111 virtual const parameter_map_t* GetParameters() const =0;
113 //setters
114 virtual void SetFieldname(const OUString& rFieldname) =0;
115 virtual void SetFieldHelptext(const OUString& rFieldHelptext) =0;
116 virtual void Invalidate() = 0;
117 private:
118 IFieldmark(IFieldmark&) = delete;
119 IFieldmark &operator =(IFieldmark const&) = delete;
122 class SW_DLLPUBLIC ICheckboxFieldmark
123 : virtual public IFieldmark
125 protected:
126 ICheckboxFieldmark() = default;
128 public:
129 virtual bool IsChecked() const =0;
130 virtual void SetChecked(bool checked) =0;
131 private:
132 ICheckboxFieldmark(ICheckboxFieldmark&) = delete;
133 ICheckboxFieldmark &operator =(ICheckboxFieldmark const&) = delete;
136 // Apple llvm-g++ 4.2.1 with _GLIBCXX_DEBUG won't eat boost::bind for this
137 // Neither will MSVC 2008 with _DEBUG
138 struct CompareIMarkStartsAfter
140 bool operator()(SwPosition const& rPos,
141 std::shared_ptr<sw::mark::IMark> const& pMark)
143 return pMark->StartsAfter(rPos);
147 struct CompareIMarkStartsBefore
149 bool operator()(std::shared_ptr<sw::mark::IMark> const& pMark,
150 SwPosition const& rPos)
152 return pMark->StartsBefore(rPos);
156 OUString ExpandFieldmark(IFieldmark* pBM);
159 #endif
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */