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 <swdllapi.h>
29 :
30 : struct SwPosition;
31 :
32 : namespace sw { namespace mark
33 : {
34 :
35 221526 : class SW_DLLPUBLIC 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 516 : bool operator==(const IMark& rOther) const
60 516 : { return GetMarkStart() == rOther.GetMarkStart(); }
61 365516 : bool StartsBefore(const SwPosition& rPos) const
62 365516 : { return GetMarkStart() < rPos; }
63 513 : bool StartsAfter(const SwPosition& rPos) const
64 513 : { 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 : virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const = 0;
72 : };
73 :
74 8866 : class SW_DLLPUBLIC IBookmark
75 : : virtual public IMark
76 : {
77 : public:
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;
82 : };
83 :
84 276 : class SW_DLLPUBLIC IFieldmark
85 : : virtual public IMark
86 : {
87 : public:
88 : typedef ::std::map< OUString, ::com::sun::star::uno::Any> parameter_map_t;
89 : //getters
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;
94 :
95 : //setters
96 : virtual void SetFieldname(const OUString& rFieldname) =0;
97 : virtual void SetFieldHelptext(const OUString& rFieldHelptext) =0;
98 : virtual void Invalidate() = 0;
99 : };
100 :
101 68 : class SW_DLLPUBLIC ICheckboxFieldmark
102 : : virtual public IFieldmark
103 : {
104 : public:
105 : virtual bool IsChecked() const =0;
106 : virtual void SetChecked(bool checked) =0;
107 : };
108 :
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
112 : {
113 73 : bool operator()(SwPosition const& rPos,
114 : boost::shared_ptr<sw::mark::IMark> const& pMark)
115 : {
116 73 : return pMark->StartsAfter(rPos);
117 : }
118 : #ifdef DBG_UTIL
119 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark,
120 : SwPosition const& rPos)
121 : {
122 : return pMark->StartsBefore(rPos);
123 : }
124 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark1,
125 : boost::shared_ptr<sw::mark::IMark> const& pMark2)
126 : {
127 : return (*pMark1) < (*pMark2);
128 : }
129 : #endif
130 : };
131 :
132 : // MSVC 2008 with _DEBUG calls this with parameters in wrong order
133 : // so it needs 3 overloads...
134 : struct CompareIMarkStartsBefore
135 : {
136 365516 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark,
137 : SwPosition const& rPos)
138 : {
139 365516 : return pMark->StartsBefore(rPos);
140 : }
141 : #ifdef DBG_UTIL
142 : bool operator()(SwPosition const& rPos,
143 : boost::shared_ptr<sw::mark::IMark> const& pMark)
144 : {
145 : return pMark->StartsAfter(rPos);
146 : }
147 : bool operator()(boost::shared_ptr<sw::mark::IMark> const& pMark1,
148 : boost::shared_ptr<sw::mark::IMark> const& pMark2)
149 : {
150 : return (*pMark1) < (*pMark2);
151 : }
152 : #endif
153 : };
154 :
155 : OUString ExpandFieldmark(IFieldmark* pBM);
156 :
157 : }}
158 : #endif
159 :
160 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|