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 .
22 #include <vcl/keycod.hxx>
25 #include <boost/operators.hpp>
26 #include <boost/shared_ptr.hpp>
30 #ifndef SW_DECL_SWSERVEROBJECT_DEFINED
31 #define SW_DECL_SWSERVEROBJECT_DEFINED
32 SV_DECL_REF( SwServerObject
)
38 namespace sw
{ namespace mark
41 class SAL_DLLPUBLIC_EXPORT IMark
42 : virtual public SwModify
// inherited as interface
43 , public ::boost::totally_ordered
<IMark
>
47 virtual const SwPosition
& GetMarkPos() const =0;
48 // GetOtherMarkPos() is only guaranteed to return a valid
49 // reference if IsExpanded() returned true
50 virtual const SwPosition
& GetOtherMarkPos() const =0;
51 virtual const SwPosition
& GetMarkStart() const =0;
52 virtual const SwPosition
& GetMarkEnd() const =0;
53 virtual const OUString
& GetName() const =0;
54 virtual bool IsExpanded() const =0;
55 virtual bool IsCoveringPosition(const SwPosition
& rPos
) const =0;
58 // not available in IMark
59 // inside core, you can cast to MarkBase and use its setters,
60 // make sure to update the sortings in Markmanager in this case
62 //operators and comparisons (non-virtual)
63 bool operator<(const IMark
& rOther
) const
64 { return GetMarkStart() < rOther
.GetMarkStart(); }
65 bool operator==(const IMark
& rOther
) const
66 { return GetMarkStart() == rOther
.GetMarkStart(); }
67 bool StartsBefore(const SwPosition
& rPos
) const
68 { return GetMarkStart() < rPos
; }
69 bool StartsAfter(const SwPosition
& rPos
) const
70 { return GetMarkStart() > rPos
; }
71 bool EndsBefore(const SwPosition
& rPos
) const
72 { return GetMarkEnd() < rPos
; }
73 bool EndsAfter(const SwPosition
& rPos
) const
74 { return GetMarkEnd() > rPos
; }
76 virtual OUString
ToString( ) const =0;
79 class SAL_DLLPUBLIC_EXPORT IBookmark
80 : virtual public IMark
83 virtual const OUString
& GetShortName() const =0;
84 virtual const KeyCode
& GetKeyCode() const =0;
85 virtual void SetShortName(const OUString
&) =0;
86 virtual void SetKeyCode(const KeyCode
&) =0;
89 class SAL_DLLPUBLIC_EXPORT IFieldmark
90 : virtual public IMark
93 typedef ::std::map
< OUString
, ::com::sun::star::uno::Any
> parameter_map_t
;
95 virtual OUString
GetFieldname() const =0;
96 virtual OUString
GetFieldHelptext() const =0;
97 virtual parameter_map_t
* GetParameters() =0;
98 virtual const parameter_map_t
* GetParameters() const =0;
101 virtual void SetFieldname(const OUString
& rFieldname
) =0;
102 virtual void SetFieldHelptext(const OUString
& rFieldHelptext
) =0;
103 virtual void Invalidate() = 0;
106 class SAL_DLLPUBLIC_EXPORT ICheckboxFieldmark
107 : virtual public IFieldmark
110 virtual bool IsChecked() const =0;
111 virtual void SetChecked(bool checked
) =0;
114 // Apple llvm-g++ 4.2.1 with _GLIBCXX_DEBUG won't eat boost::bind for this
115 // Neither will MSVC 2008 with _DEBUG
116 struct CompareIMarkStartsAfter
118 bool operator()(SwPosition
const& rPos
,
119 boost::shared_ptr
<sw::mark::IMark
> const& pMark
)
121 return pMark
->StartsAfter(rPos
);
124 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark
,
125 SwPosition
const& rPos
)
127 return pMark
->StartsBefore(rPos
);
129 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark1
,
130 boost::shared_ptr
<sw::mark::IMark
> const& pMark2
)
132 return (*pMark1
) < (*pMark2
);
137 // MSVC 2008 with _DEBUG calls this with parameters in wrong order
138 // so it needs 3 overloads...
139 struct CompareIMarkStartsBefore
141 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark
,
142 SwPosition
const& rPos
)
144 return pMark
->StartsBefore(rPos
);
147 bool operator()(SwPosition
const& rPos
,
148 boost::shared_ptr
<sw::mark::IMark
> const& pMark
)
150 return pMark
->StartsAfter(rPos
);
152 bool operator()(boost::shared_ptr
<sw::mark::IMark
> const& pMark1
,
153 boost::shared_ptr
<sw::mark::IMark
> const& pMark2
)
155 return (*pMark1
) < (*pMark2
);
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */