1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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
25 #include <tools/long.hxx>
32 class SwTextINetFormat
;
39 class SwOutlineContent final
: public SwContent
41 SwOutlineNodes::size_type m_nOutlinePos
;
42 sal_uInt8 m_nOutlineLevel
;
45 SwOutlineContent( const SwContentType
* pCnt
,
46 const OUString
& rName
,
47 SwOutlineNodes::size_type nArrPos
,
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
;
65 SwRegionContent( const SwContentType
* pCnt
,
66 const OUString
& rName
,
69 SwContent(pCnt
, rName
, nYPos
),
70 m_nRegionLevel(nLevel
){}
71 sal_uInt8
GetRegionLevel() const {return m_nRegionLevel
;}
74 class SwURLFieldContent final
: public SwContent
77 const SwTextINetFormat
* m_pINetAttr
;
80 SwURLFieldContent( const SwContentType
* pCnt
,
81 const OUString
& rName
,
83 const SwTextINetFormat
* pAttr
,
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
;
97 SwTextFieldContent(const SwContentType
* pCnt
,
98 const OUString
& rName
,
99 const SwFormatField
* pFormatField
,
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
;
113 SwTextFootnoteContent(const SwContentType
* pCnt
,
114 const OUString
& rName
,
115 const SwTextFootnote
* pTextFootnote
,
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
;
128 SwPostItContent( const SwContentType
* pCnt
,
129 const OUString
& rName
,
130 const SwFormatField
* pFormatField
,
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
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
;
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
&);
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
;
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
;}
223 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */