/src/libreoffice/sw/source/uibase/inc/content.hxx
Line | Count | Source (jump to first uncovered line) |
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_SOURCE_UIBASE_INC_CONTENT_HXX |
20 | | #define INCLUDED_SW_SOURCE_UIBASE_INC_CONTENT_HXX |
21 | | #include <memory> |
22 | | #include "swcont.hxx" |
23 | | |
24 | | #include <ndarr.hxx> |
25 | | #include <fmtfld.hxx> |
26 | | #include <tools/long.hxx> |
27 | | #include <utility> |
28 | | |
29 | | class SwWrtShell; |
30 | | class SwContentArr; |
31 | | class SwContentType; |
32 | | class SwFormatField; |
33 | | class SwTextINetFormat; |
34 | | class SwTOXBase; |
35 | | class SwTextFootnote; |
36 | | |
37 | | // helper classes |
38 | | |
39 | | class SwOutlineContent final : public SwContent |
40 | | { |
41 | | SwOutlineNodes::size_type m_nOutlinePos; |
42 | | sal_uInt8 m_nOutlineLevel; |
43 | | bool m_bIsMoveable; |
44 | | public: |
45 | | SwOutlineContent( const SwContentType* pCnt, |
46 | | const OUString& rName, |
47 | | SwOutlineNodes::size_type nArrPos, |
48 | | sal_uInt8 nLevel, |
49 | | bool bMove, |
50 | | double nYPos) : |
51 | 0 | SwContent(pCnt, rName, nYPos), |
52 | 0 | m_nOutlinePos(nArrPos), m_nOutlineLevel(nLevel), m_bIsMoveable(bMove) {} |
53 | | |
54 | 0 | SwOutlineNodes::size_type GetOutlinePos() const {return m_nOutlinePos;} |
55 | 0 | sal_uInt8 GetOutlineLevel() const {return m_nOutlineLevel;} |
56 | 0 | bool IsMoveable() const {return m_bIsMoveable;}; |
57 | | }; |
58 | | |
59 | | class SwRegionContent final : public SwContent |
60 | | { |
61 | | |
62 | | sal_uInt8 m_nRegionLevel; |
63 | | const SwSectionFormat* m_pSectionFormat; |
64 | | |
65 | | public: |
66 | | SwRegionContent( const SwContentType* pCnt, |
67 | | const OUString& rName, |
68 | | sal_uInt8 nLevel, |
69 | | tools::Long nYPos, |
70 | | const SwSectionFormat* pSectionFormat) : |
71 | 0 | SwContent(pCnt, rName, nYPos), |
72 | 0 | m_nRegionLevel(nLevel), m_pSectionFormat(pSectionFormat){} |
73 | 0 | sal_uInt8 GetRegionLevel() const {return m_nRegionLevel;} |
74 | 0 | const SwSectionFormat* GetSectionFormat() const {return m_pSectionFormat;} |
75 | | |
76 | | bool IsProtect() const override; |
77 | | }; |
78 | | |
79 | | class SwURLFieldContent final : public SwContent |
80 | | { |
81 | | OUString m_sURL; |
82 | | const SwTextINetFormat* m_pINetAttr; |
83 | | |
84 | | public: |
85 | | SwURLFieldContent( const SwContentType* pCnt, |
86 | | const OUString& rName, |
87 | | OUString aURL, |
88 | | const SwTextINetFormat* pAttr, |
89 | | tools::Long nYPos ) |
90 | 0 | : SwContent( pCnt, rName, nYPos ), m_sURL(std::move( aURL )), m_pINetAttr( pAttr ) |
91 | 0 | {} |
92 | | |
93 | | virtual bool IsProtect() const override; |
94 | 0 | const OUString& GetURL() const { return m_sURL; } |
95 | 0 | const SwTextINetFormat* GetINetAttr() const { return m_pINetAttr; } |
96 | | }; |
97 | | |
98 | | class SwTextFieldContent final : public SwContent |
99 | | { |
100 | | const SwFormatField* m_pFormatField; |
101 | | public: |
102 | | SwTextFieldContent(const SwContentType* pCnt, |
103 | | const OUString& rName, |
104 | | const SwFormatField* pFormatField, |
105 | | tools::Long nYPos) |
106 | 0 | : SwContent(pCnt, rName, nYPos), |
107 | 0 | m_pFormatField(pFormatField) |
108 | 0 | {} |
109 | | |
110 | 0 | const SwFormatField* GetFormatField() const {return m_pFormatField;} |
111 | | virtual bool IsProtect() const override; |
112 | | }; |
113 | | |
114 | | class SwTextFootnoteContent final : public SwContent |
115 | | { |
116 | | const SwTextFootnote* m_pTextFootnote; |
117 | | public: |
118 | | SwTextFootnoteContent(const SwContentType* pCnt, |
119 | | const OUString& rName, |
120 | | const SwTextFootnote* pTextFootnote, |
121 | | tools::Long nYPos) |
122 | 0 | : SwContent(pCnt, rName, nYPos), |
123 | 0 | m_pTextFootnote(pTextFootnote) |
124 | 0 | {} |
125 | | |
126 | 0 | const SwTextFootnote* GetTextFootnote() const {return m_pTextFootnote;} |
127 | | }; |
128 | | |
129 | | class SwPostItContent final : public SwContent, public SfxListener |
130 | | { |
131 | | const SwFormatField* m_pField; |
132 | | public: |
133 | | SwPostItContent( const SwContentType* pCnt, |
134 | | const OUString& rName, |
135 | | const SwFormatField* pFormatField, |
136 | | tools::Long nYPos ) |
137 | 0 | : SwContent(pCnt, rName, nYPos) |
138 | 0 | , m_pField(pFormatField) |
139 | 0 | { |
140 | 0 | assert(m_pField); |
141 | 0 | StartListening(*const_cast<SwFormatField*>(m_pField)); |
142 | 0 | } |
143 | | |
144 | | virtual void Notify(SfxBroadcaster &, SfxHint const& rHint) override |
145 | 0 | { |
146 | 0 | if (rHint.GetId() == SfxHintId::Dying) |
147 | 0 | { |
148 | 0 | m_pField = nullptr; |
149 | 0 | } |
150 | 0 | } |
151 | | |
152 | 0 | const SwFormatField* GetPostIt() const { return m_pField; } |
153 | | SwPostItField const* GetPostItField() const; |
154 | | virtual bool IsProtect() const override; |
155 | | }; |
156 | | |
157 | | class SwGraphicContent final : public SwContent |
158 | | { |
159 | | OUString m_sLink; |
160 | | public: |
161 | | SwGraphicContent(const SwContentType* pCnt, const OUString& rName, OUString aLink, tools::Long nYPos) |
162 | 0 | : SwContent( pCnt, rName, nYPos ), m_sLink(std::move( aLink )) |
163 | 0 | {} |
164 | | virtual ~SwGraphicContent() override; |
165 | | |
166 | 0 | const OUString& GetLink() const {return m_sLink;} |
167 | | }; |
168 | | |
169 | | class SwTOXBaseContent final : public SwContent |
170 | | { |
171 | | const SwTOXBase* m_pBase; |
172 | | public: |
173 | | SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, tools::Long nYPos, const SwTOXBase& rBase) |
174 | 0 | : SwContent( pCnt, rName, nYPos ), m_pBase(&rBase) |
175 | 0 | {} |
176 | | virtual ~SwTOXBaseContent() override; |
177 | | |
178 | 0 | const SwTOXBase* GetTOXBase() const {return m_pBase;} |
179 | | }; |
180 | | |
181 | | /** |
182 | | * Content type, knows it's contents and the WrtShell. |
183 | | * |
184 | | * The class ContentType contains information to one type of content. |
185 | | * MemberArray is only populated if the content is requested by |
186 | | * GetMember. It is reloaded after Invalidate() only if the content |
187 | | * should be read again. |
188 | | */ |
189 | | class SwContentType final : public SwTypeNumber |
190 | | { |
191 | | SwWrtShell* m_pWrtShell; |
192 | | std::unique_ptr<SwContentArr> |
193 | | m_pMember; // array for content |
194 | | OUString m_sContentTypeName; // name of content type |
195 | | OUString m_sSingleContentTypeName; // name of content type, singular |
196 | | OUString m_sTypeToken; // attachment for URL |
197 | | size_t m_nMemberCount; // content count |
198 | | ContentTypeId m_nContentType; // content type's Id |
199 | | sal_uInt8 m_nOutlineLevel; |
200 | | bool m_bDataValid : 1; |
201 | | bool m_bEdit: 1; // can this type be edited? |
202 | | bool m_bDelete: 1; // can this type be deleted? |
203 | | bool m_bRenamable = false; |
204 | | |
205 | | bool m_bAlphabeticSort = false; |
206 | | |
207 | | static OUString RemoveNewline(const OUString&); |
208 | | public: |
209 | | SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel ); |
210 | | virtual ~SwContentType() override; |
211 | | |
212 | | /** Fill the List of contents */ |
213 | | void FillMemberList(bool* pbContentChanged = nullptr); |
214 | | size_t GetMemberCount() const |
215 | 0 | {return m_nMemberCount;}; |
216 | 0 | ContentTypeId GetType() const {return m_nContentType;} |
217 | | |
218 | | /** Deliver content, for that if necessary fill the list */ |
219 | | const SwContent* GetMember(size_t nIndex); |
220 | 0 | const OUString& GetName() const {return m_sContentTypeName;} |
221 | 0 | const OUString& GetSingleName() const {return m_sSingleContentTypeName;} |
222 | 0 | const OUString& GetTypeToken() const{return m_sTypeToken;} |
223 | | |
224 | | void SetOutlineLevel(sal_uInt8 nNew) |
225 | 0 | { |
226 | 0 | m_nOutlineLevel = nNew; |
227 | 0 | Invalidate(); |
228 | 0 | } |
229 | | |
230 | 0 | bool IsAlphabeticSort() const {return m_bAlphabeticSort;} |
231 | 0 | void SetAlphabeticSort(bool bAlphabetic) {m_bAlphabeticSort = bAlphabetic;} |
232 | | |
233 | | void Invalidate(); // only nMemberCount is read again |
234 | | |
235 | 0 | bool IsEditable() const {return m_bEdit;} |
236 | 0 | bool IsDeletable() const {return m_bDelete;} |
237 | 0 | bool IsRenamable() const {return m_bRenamable;} |
238 | | }; |
239 | | |
240 | | #endif |
241 | | |
242 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |