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 <map>
26 #include <memory>
27 #include "swdllapi.h"
28 
29 namespace sw { namespace mark
30 {
31     enum class InsertMode
32     {
33         New,
34         CopyText,
35     };
36 
37     class SW_DLLPUBLIC IMark
38         : virtual public sw::BroadcastingModify // inherited as interface
39     {
40         protected:
41             IMark() = default;
42 
43         public:
44             //getters
45             virtual const SwPosition& GetMarkPos() const =0;
46             // GetOtherMarkPos() is only guaranteed to return a valid
47             // reference if IsExpanded() returned true
48             virtual const SwPosition& GetOtherMarkPos() const =0;
49             virtual const SwPosition& GetMarkStart() const =0;
50             virtual const SwPosition& GetMarkEnd() const =0;
51             virtual const OUString& GetName() const =0;
52             virtual bool IsExpanded() const =0;
53             virtual bool IsCoveringPosition(const SwPosition& rPos) const =0;
54 
55             //setters
56             // not available in IMark
57             // inside core, you can cast to MarkBase and use its setters,
58             // make sure to update the sorting in Markmanager in this case
59 
60             virtual OUString ToString( ) const =0;
61             virtual void dumpAsXml(xmlTextWriterPtr pWriter) const = 0;
62         private:
63             IMark(IMark const &) = delete;
64             IMark &operator =(IMark const&) = delete;
65     };
66 
67     class SW_DLLPUBLIC IBookmark
68         : virtual public IMark
69     {
70         protected:
71             IBookmark() = default;
72 
73         public:
74             virtual const OUString& GetShortName() const =0;
75             virtual const vcl::KeyCode& GetKeyCode() const =0;
76             virtual void SetShortName(const OUString&) =0;
77             virtual void SetKeyCode(const vcl::KeyCode&) =0;
78             virtual bool IsHidden() const =0;
79             virtual const OUString& GetHideCondition() const =0;
80             virtual void Hide(bool hide) =0;
81             virtual void SetHideCondition(const OUString&) =0;
82         private:
83             IBookmark(IBookmark const &) = delete;
84             IBookmark &operator =(IBookmark const&) = delete;
85     };
86 
87     class SW_DLLPUBLIC IFieldmark
88         : virtual public IMark
89     {
90         protected:
91             IFieldmark() = default;
92 
93         public:
94             typedef std::map< OUString, css::uno::Any> parameter_map_t;
95             //getters
96             virtual OUString GetFieldname() const =0;
97             virtual OUString GetFieldHelptext() const =0;
98             virtual parameter_map_t* GetParameters() =0;
99             virtual const parameter_map_t* GetParameters() const =0;
100 
101             //setters
102             virtual void SetFieldname(const OUString& rFieldname) =0;
103             virtual void SetFieldHelptext(const OUString& rFieldHelptext) =0;
104             virtual void Invalidate() = 0;
105         private:
106             IFieldmark(IFieldmark const &) = delete;
107             IFieldmark &operator =(IFieldmark const&) = delete;
108     };
109 
110     class SW_DLLPUBLIC ICheckboxFieldmark
111         : virtual public IFieldmark
112     {
113         protected:
114             ICheckboxFieldmark() = default;
115 
116         public:
117             virtual bool IsChecked() const =0;
118             virtual void SetChecked(bool checked) =0;
119         private:
120             ICheckboxFieldmark(ICheckboxFieldmark const &) = delete;
121             ICheckboxFieldmark &operator =(ICheckboxFieldmark const&) = delete;
122     };
123 
124     class SW_DLLPUBLIC IDateFieldmark
125         : virtual public IFieldmark
126     {
127         protected:
128             IDateFieldmark() = default;
129 
130         public:
131             virtual OUString GetContent() const = 0;
132             virtual void ReplaceContent(const OUString& sNewContent) = 0;
133 
134             virtual std::pair<bool, double> GetCurrentDate() const = 0;
135             virtual void SetCurrentDate(double fDate) = 0;
136             virtual OUString GetDateInStandardDateFormat(double fDate) const = 0;
137 
138     private:
139             IDateFieldmark(ICheckboxFieldmark const &) = delete;
140             IDateFieldmark &operator =(ICheckboxFieldmark const&) = delete;
141     };
142 
143     OUString ExpandFieldmark(IFieldmark* pBM);
144 
145 }}
146 #endif
147 
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
149