Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / inc / content.hxx
blobf7666e97244b7142a07663de6ad88a570d591a07
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
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"
24 #include <ndarr.hxx>
25 #include <tools/long.hxx>
26 #include <utility>
28 class SwWrtShell;
29 class SwContentArr;
30 class SwContentType;
31 class SwFormatField;
32 class SwTextINetFormat;
33 class SwTOXBase;
34 class SwRangeRedline;
35 class SwTextFootnote;
37 // helper classes
39 class SwOutlineContent final : public SwContent
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 SwContent(pCnt, rName, nYPos),
52 m_nOutlinePos(nArrPos), m_nOutlineLevel(nLevel), m_bIsMoveable(bMove) {}
54 SwOutlineNodes::size_type GetOutlinePos() const {return m_nOutlinePos;}
55 sal_uInt8 GetOutlineLevel() const {return m_nOutlineLevel;}
56 bool IsMoveable() const {return m_bIsMoveable;};
59 class SwRegionContent final : public SwContent
62 sal_uInt8 m_nRegionLevel;
64 public:
65 SwRegionContent( const SwContentType* pCnt,
66 const OUString& rName,
67 sal_uInt8 nLevel,
68 tools::Long nYPos) :
69 SwContent(pCnt, rName, nYPos),
70 m_nRegionLevel(nLevel){}
71 sal_uInt8 GetRegionLevel() const {return m_nRegionLevel;}
74 class SwURLFieldContent final : public SwContent
76 OUString m_sURL;
77 const SwTextINetFormat* m_pINetAttr;
79 public:
80 SwURLFieldContent( const SwContentType* pCnt,
81 const OUString& rName,
82 OUString aURL,
83 const SwTextINetFormat* pAttr,
84 tools::Long nYPos )
85 : SwContent( pCnt, rName, nYPos ), m_sURL(std::move( aURL )), m_pINetAttr( pAttr )
88 virtual bool IsProtect() const override;
89 const OUString& GetURL() const { return m_sURL; }
90 const SwTextINetFormat* GetINetAttr() const { return m_pINetAttr; }
93 class SwTextFieldContent final : public SwContent
95 const SwFormatField* m_pFormatField;
96 public:
97 SwTextFieldContent(const SwContentType* pCnt,
98 const OUString& rName,
99 const SwFormatField* pFormatField,
100 tools::Long nYPos)
101 : SwContent(pCnt, rName, nYPos),
102 m_pFormatField(pFormatField)
105 const SwFormatField* GetFormatField() const {return m_pFormatField;}
106 virtual bool IsProtect() const override;
109 class SwTextFootnoteContent final : public SwContent
111 const SwTextFootnote* m_pTextFootnote;
112 public:
113 SwTextFootnoteContent(const SwContentType* pCnt,
114 const OUString& rName,
115 const SwTextFootnote* pTextFootnote,
116 tools::Long nYPos)
117 : SwContent(pCnt, rName, nYPos),
118 m_pTextFootnote(pTextFootnote)
121 const SwTextFootnote* GetTextFootnote() const {return m_pTextFootnote;}
124 class SwPostItContent final : public SwContent
126 const SwFormatField* m_pField;
127 public:
128 SwPostItContent( const SwContentType* pCnt,
129 const OUString& rName,
130 const SwFormatField* pFormatField,
131 tools::Long nYPos )
132 : SwContent(pCnt, rName, nYPos)
133 , m_pField(pFormatField)
136 const SwFormatField* GetPostIt() const { return m_pField; }
137 virtual bool IsProtect() const override;
140 class SwGraphicContent final : public SwContent
142 OUString m_sLink;
143 public:
144 SwGraphicContent(const SwContentType* pCnt, const OUString& rName, OUString aLink, tools::Long nYPos)
145 : SwContent( pCnt, rName, nYPos ), m_sLink(std::move( aLink ))
147 virtual ~SwGraphicContent() override;
149 const OUString& GetLink() const {return m_sLink;}
152 class SwTOXBaseContent final : public SwContent
154 const SwTOXBase* m_pBase;
155 public:
156 SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, tools::Long nYPos, const SwTOXBase& rBase)
157 : SwContent( pCnt, rName, nYPos ), m_pBase(&rBase)
159 virtual ~SwTOXBaseContent() override;
161 const SwTOXBase* GetTOXBase() const {return m_pBase;}
165 * Content type, knows it's contents and the WrtShell.
167 * The class ContentType contains information to one type of content.
168 * MemberArray is only populated if the content is requested by
169 * GetMember. It is reloaded after Invalidate() only if the content
170 * should be read again.
172 class SwContentType final : public SwTypeNumber
174 SwWrtShell* m_pWrtShell;
175 std::unique_ptr<SwContentArr>
176 m_pMember; // array for content
177 OUString m_sContentTypeName; // name of content type
178 OUString m_sSingleContentTypeName; // name of content type, singular
179 OUString m_sTypeToken; // attachment for URL
180 size_t m_nMemberCount; // content count
181 ContentTypeId m_nContentType; // content type's Id
182 sal_uInt8 m_nOutlineLevel;
183 bool m_bDataValid : 1;
184 bool m_bEdit: 1; // can this type be edited?
185 bool m_bDelete: 1; // can this type be deleted?
187 bool m_bAlphabeticSort = false;
189 static OUString RemoveNewline(const OUString&);
190 public:
191 SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
192 virtual ~SwContentType() override;
194 /** Fill the List of contents */
195 void FillMemberList(bool* pbContentChanged = nullptr);
196 size_t GetMemberCount() const
197 {return m_nMemberCount;};
198 ContentTypeId GetType() const {return m_nContentType;}
200 /** Deliver content, for that if necessary fill the list */
201 const SwContent* GetMember(size_t nIndex);
202 const OUString& GetName() const {return m_sContentTypeName;}
203 const OUString& GetSingleName() const {return m_sSingleContentTypeName;}
204 const OUString& GetTypeToken() const{return m_sTypeToken;}
206 void SetOutlineLevel(sal_uInt8 nNew)
208 m_nOutlineLevel = nNew;
209 Invalidate();
212 bool GetSortType() const {return m_bAlphabeticSort;}
213 void SetSortType(bool bAlphabetic) {m_bAlphabeticSort = bAlphabetic;}
215 void Invalidate(); // only nMemberCount is read again
217 bool IsEditable() const {return m_bEdit;}
218 bool IsDeletable() const {return m_bDelete;}
221 #endif
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */