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 : #ifndef INCLUDED_SW_INC_IMARK_HXX
20 : #define INCLUDED_SW_INC_IMARK_HXX
21 :
22 : #include <vcl/keycod.hxx>
23 : #include <calbck.hxx>
24 : #include <pam.hxx>
25 : #include <boost/operators.hpp>
26 : #include <boost/shared_ptr.hpp>
27 : #include <map>
28 : #include "swdll.hxx"
29 :
30 : struct SwPosition;
31 :
32 : namespace sw { namespace mark
33 : {
34 :
35 0 : class SAL_DLLPUBLIC_EXPORT IMark
36 : : virtual public SwModify // inherited as interface
37 : , public ::boost::totally_ordered<IMark>
38 : {
39 : public:
40 : //getters
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;
50 :
51 : //setters
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
55 :
56 : //operators and comparisons (non-virtual)
57 : bool operator<(const IMark& rOther) const
58 : { return GetMarkStart() < rOther.GetMarkStart(); }
59 0 : bool operator==(const IMark& rOther) const
60 0 : { return GetMarkStart() == rOther.GetMarkStart(); }
61 0 : bool StartsBefore(const SwPosition& rPos) const
62 0 : { return GetMarkStart() < rPos; }
63 0 : bool StartsAfter(const SwPosition& rPos) const
64 0 : { return GetMarkStart() > rPos; }
65 0 : bool EndsBefore(const SwPosition& rPos) const
66 0 : { return GetMarkEnd() < rPos; }
67 : bool EndsAfter(const SwPosition& rPos) const
68 : { return GetMarkEnd() > rPos; }
69 :
70 : virtual OUString ToString( ) const =0;
71 : };
72 :
73 0 : class SAL_DLLPUBLIC_EXPORT IBookmark
74 : : virtual public IMark
75 : {
76 : public:
77 : virtual const OUString& GetShortName() const =0;
78 : virtual const KeyCode& GetKeyCode() const =0;
79 : virtual void SetShortName(const OUString&) =0;
80 : virtual void SetKeyCode(const KeyCode&) =0;
81 : };
82 :
83 0 : class SAL_DLLPUBLIC_EXPORT IFieldmark
84 : : virtual public IMark
85 : {
86 : public:
87 : typedef ::std::map< OUString, ::com::sun::star::uno::Any> parameter_map_t;
88 : //getters
89 : virtual OUString GetFieldname() const =0;
90 : virtual OUString GetFieldHelptext() const =0;
91 : virtual parameter_map_t* GetParameters() =0;
92 : virtual const parameter_map_t* GetParameters() const =0;
93 :
94 : //setters
95 : virtual void SetFieldname(const OUString& rFieldname) =0;
96 : virtual void SetFieldHelptext(const OUString& rFieldHelptext) =0;
97 : virtual void Invalidate() = 0;
98 : };
99 :
100 0 : class SAL_DLLPUBLIC_EXPORT ICheckboxFieldmark
101 : : virtual public IFieldmark
102 : {
103 : public:
104 : virtual bool IsChecked() const =0;
105 : virtual void SetChecked(bool checked) =0;
106 : };
107 :
108 : // Apple llvm-g++ 4.2.1 with _GLIBCXX_DEBUG won't eat boost::bind for this
109 : // Neither will MSVC 2008 with _DEBUG
110 : struct CompareIMarkStartsAfter
111 : {
112 0 : bool operator()(SwPosition const& rPos,
113 : boost::shared_ptr<sw::mark::IMark> const& pMark)
114 : {
115 0 : return pMark->StartsAfter(rPos);
116 : }
117 : #ifdef DBG_UTIL
118 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark,
119 : SwPosition const& rPos)
120 : {
121 : return pMark->StartsBefore(rPos);
122 : }
123 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark1,
124 : boost::shared_ptr<sw::mark::IMark> const& pMark2)
125 : {
126 : return (*pMark1) < (*pMark2);
127 : }
128 : #endif
129 : };
130 :
131 : // MSVC 2008 with _DEBUG calls this with parameters in wrong order
132 : // so it needs 3 overloads...
133 : struct CompareIMarkStartsBefore
134 : {
135 0 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark,
136 : SwPosition const& rPos)
137 : {
138 0 : return pMark->StartsBefore(rPos);
139 : }
140 : #ifdef DBG_UTIL
141 : bool operator()(SwPosition const& rPos,
142 : boost::shared_ptr<sw::mark::IMark> const& pMark)
143 : {
144 : return pMark->StartsAfter(rPos);
145 : }
146 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark1,
147 : boost::shared_ptr<sw::mark::IMark> const& pMark2)
148 : {
149 : return (*pMark1) < (*pMark2);
150 : }
151 : #endif
152 : };
153 :
154 : OUString ExpandFieldmark(IFieldmark* pBM);
155 :
156 : }}
157 : #endif
158 :
159 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|