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
30 class SwTextINetFormat
;
36 class SwOutlineContent
: public SwContent
38 SwOutlineNodes::size_type nOutlinePos
;
39 sal_uInt8 nOutlineLevel
;
42 SwOutlineContent( const SwContentType
* pCnt
,
43 const OUString
& rName
,
44 SwOutlineNodes::size_type nArrPos
,
48 SwContent(pCnt
, rName
, nYPos
),
49 nOutlinePos(nArrPos
), nOutlineLevel(nLevel
), bIsMoveable(bMove
) {}
51 SwOutlineNodes::size_type
GetOutlinePos() const {return nOutlinePos
;}
52 sal_uInt8
GetOutlineLevel() const {return nOutlineLevel
;}
53 bool IsMoveable() const {return bIsMoveable
;};
56 class SwRegionContent
: public SwContent
59 sal_uInt8 nRegionLevel
;
62 SwRegionContent( const SwContentType
* pCnt
,
63 const OUString
& rName
,
66 SwContent(pCnt
, rName
, nYPos
),
67 nRegionLevel(nLevel
){}
68 sal_uInt8
GetRegionLevel() const {return nRegionLevel
;}
71 class SwURLFieldContent
: public SwContent
74 const SwTextINetFormat
* pINetAttr
;
77 SwURLFieldContent( const SwContentType
* pCnt
,
78 const OUString
& rName
,
80 const SwTextINetFormat
* pAttr
,
82 : SwContent( pCnt
, rName
, nYPos
), sURL( rURL
), pINetAttr( pAttr
)
85 virtual bool IsProtect() const override
;
86 const OUString
& GetURL() const { return sURL
; }
87 const SwTextINetFormat
* GetINetAttr() const { return pINetAttr
; }
90 class SwPostItContent
: public SwContent
92 const SwFormatField
* pField
;
94 SwPostItContent( const SwContentType
* pCnt
,
95 const OUString
& rName
,
96 const SwFormatField
* pFormatField
,
98 : SwContent(pCnt
, rName
, nYPos
)
99 , pField(pFormatField
)
102 const SwFormatField
* GetPostIt() const { return pField
; }
103 virtual bool IsProtect() const override
;
106 class SwGraphicContent
: public SwContent
110 SwGraphicContent(const SwContentType
* pCnt
, const OUString
& rName
, const OUString
& rLink
, tools::Long nYPos
)
111 : SwContent( pCnt
, rName
, nYPos
), sLink( rLink
)
113 virtual ~SwGraphicContent() override
;
115 const OUString
& GetLink() const {return sLink
;}
118 class SwTOXBaseContent
: public SwContent
120 const SwTOXBase
* pBase
;
122 SwTOXBaseContent(const SwContentType
* pCnt
, const OUString
& rName
, tools::Long nYPos
, const SwTOXBase
& rBase
)
123 : SwContent( pCnt
, rName
, nYPos
), pBase(&rBase
)
125 virtual ~SwTOXBaseContent() override
;
127 const SwTOXBase
* GetTOXBase() const {return pBase
;}
131 * Content type, knows it's contents and the WrtShell.
133 * The class ContentType contains information to one type of content.
134 * MemberArray is only populated if the content is requested by
135 * GetMember. It is reloaded after Invalidate() only if the content
136 * should be read again.
138 class SwContentType
: public SwTypeNumber
140 SwWrtShell
* m_pWrtShell
;
141 std::unique_ptr
<SwContentArr
>
142 m_pMember
; // array for content
143 OUString m_sContentTypeName
; // name of content type
144 OUString m_sSingleContentTypeName
; // name of content type, singular
145 OUString m_sTypeToken
; // attachment for URL
146 size_t m_nMemberCount
; // content count
147 ContentTypeId m_nContentType
; // content type's Id
148 sal_uInt8 m_nOutlineLevel
;
149 bool m_bDataValid
: 1;
150 bool m_bEdit
: 1; // can this type be edited?
151 bool m_bDelete
: 1; // can this type be deleted?
153 static OUString
RemoveNewline(const OUString
&);
155 SwContentType(SwWrtShell
* pParent
, ContentTypeId nType
, sal_uInt8 nLevel
);
156 virtual ~SwContentType() override
;
158 void Init(bool* pbInvalidateWindow
= nullptr);
160 /** Fill the List of contents */
161 void FillMemberList(bool* pbLevelChanged
= nullptr);
162 size_t GetMemberCount() const
163 {return m_nMemberCount
;};
164 ContentTypeId
GetType() const {return m_nContentType
;}
166 /** Deliver content, for that if necessary fill the list */
167 const SwContent
* GetMember(size_t nIndex
);
168 const OUString
& GetName() const {return m_sContentTypeName
;}
169 const OUString
& GetSingleName() const {return m_sSingleContentTypeName
;}
170 const OUString
& GetTypeToken() const{return m_sTypeToken
;}
172 void SetOutlineLevel(sal_uInt8 nNew
)
174 m_nOutlineLevel
= nNew
;
178 void Invalidate(); // only nMemberCount is read again
180 bool IsEditable() const {return m_bEdit
;}
181 bool IsDeletable() const {return m_bDelete
;}
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */