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 .
19 #ifndef INCLUDED_SW_INC_IMARK_HXX
20 #define INCLUDED_SW_INC_IMARK_HXX
22 #include <vcl/keycod.hxx>
25 #include <boost/operators.hpp>
26 #include <boost/shared_ptr.hpp>
32 namespace sw
{ namespace mark
35 class SW_DLLPUBLIC IMark
36 : virtual public SwModify
// inherited as interface
37 , public ::boost::totally_ordered
<IMark
>
41 virtual const SwPosition
& GetMarkPos() const =0;
42 // GetOtherMarkPos() is only guaranteed to return a valid
43 // reference if IsExpanded() returned true
44 virtual const SwPosition
& GetOtherMarkPos() const =0;
45 virtual const SwPosition
& GetMarkStart() const =0;
46 virtual const SwPosition
& GetMarkEnd() const =0;
47 virtual const OUString
& GetName() const =0;
48 virtual bool IsExpanded() const =0;
49 virtual bool IsCoveringPosition(const SwPosition
& rPos
) const =0;
52 // not available in IMark
53 // inside core, you can cast to MarkBase and use its setters,
54 // make sure to update the sortings in Markmanager in this case
56 //operators and comparisons (non-virtual)
57 bool operator<(const IMark
& rOther
) const
58 { return GetMarkStart() < rOther
.GetMarkStart(); }
59 bool operator==(const IMark
& rOther
) const
60 { return GetMarkStart() == rOther
.GetMarkStart(); }
61 bool StartsBefore(const SwPosition
& rPos
) const
62 { return GetMarkStart() < rPos
; }
63 bool StartsAfter(const SwPosition
& rPos
) const
64 { return GetMarkStart() > rPos
; }
65 bool EndsBefore(const SwPosition
& rPos
) const
66 { return GetMarkEnd() < rPos
; }
67 bool EndsAfter(const SwPosition
& rPos
) const
68 { return GetMarkEnd() > rPos
; }
70 virtual OUString
ToString( ) const =0;
71 virtual void dumpAsXml(struct _xmlTextWriter
* pWriter
) const = 0;
74 class SW_DLLPUBLIC IBookmark
75 : virtual public IMark
78 virtual const OUString
& GetShortName() const =0;
79 virtual const vcl::KeyCode
& GetKeyCode() const =0;
80 virtual void SetShortName(const OUString
&) =0;
81 virtual void SetKeyCode(const vcl::KeyCode
&) =0;
84 class SW_DLLPUBLIC IFieldmark
85 : virtual public IMark
88 typedef ::std::map
< OUString
, ::com::sun::star::uno::Any
> parameter_map_t
;
90 virtual OUString
GetFieldname() const =0;
91 virtual OUString
GetFieldHelptext() const =0;
92 virtual parameter_map_t
* GetParameters() =0;
93 virtual const parameter_map_t
* GetParameters() const =0;
96 virtual void SetFieldname(const OUString
& rFieldname
) =0;
97 virtual void SetFieldHelptext(const OUString
& rFieldHelptext
) =0;
98 virtual void Invalidate() = 0;
101 class SW_DLLPUBLIC ICheckboxFieldmark
102 : virtual public IFieldmark
105 virtual bool IsChecked() const =0;
106 virtual void SetChecked(bool checked
) =0;
109 // Apple llvm-g++ 4.2.1 with _GLIBCXX_DEBUG won't eat boost::bind for this
110 // Neither will MSVC 2008 with _DEBUG
111 struct CompareIMarkStartsAfter
113 bool operator()(SwPosition
const& rPos
,
114 boost::shared_ptr
<sw::mark::IMark
> const& pMark
)
116 return pMark
->StartsAfter(rPos
);
119 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark
,
120 SwPosition
const& rPos
)
122 return pMark
->StartsBefore(rPos
);
124 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark1
,
125 boost::shared_ptr
<sw::mark::IMark
> const& pMark2
)
127 return (*pMark1
) < (*pMark2
);
132 // MSVC 2008 with _DEBUG calls this with parameters in wrong order
133 // so it needs 3 overloads...
134 struct CompareIMarkStartsBefore
136 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark
,
137 SwPosition
const& rPos
)
139 return pMark
->StartsBefore(rPos
);
142 bool operator()(SwPosition
const& rPos
,
143 boost::shared_ptr
<sw::mark::IMark
> const& pMark
)
145 return pMark
->StartsAfter(rPos
);
147 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark1
,
148 boost::shared_ptr
<sw::mark::IMark
> const& pMark2
)
150 return (*pMark1
) < (*pMark2
);
155 OUString
ExpandFieldmark(IFieldmark
* pBM
);
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */