LibreOffice Module sw (master) 1
content.hxx
Go to the documentation of this file.
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 <tools/long.hxx>
26#include <utility>
27
28class SwWrtShell;
29class SwContentArr;
30class SwContentType;
31class SwFormatField;
33class SwTOXBase;
34class SwRangeRedline;
35class SwTextFootnote;
36
37// helper classes
38
39class SwOutlineContent final : public SwContent
40{
44 public:
46 const OUString& rName,
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) {}
53
56 bool IsMoveable() const {return m_bIsMoveable;};
57};
58
59class SwRegionContent final : public SwContent
60{
61
63
64 public:
66 const OUString& rName,
67 sal_uInt8 nLevel,
68 tools::Long nYPos) :
69 SwContent(pCnt, rName, nYPos),
70 m_nRegionLevel(nLevel){}
72};
73
74class SwURLFieldContent final : public SwContent
75{
76 OUString m_sURL;
78
79public:
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 )
86 {}
87
88 virtual bool IsProtect() const override;
89 const OUString& GetURL() const { return m_sURL; }
90 const SwTextINetFormat* GetINetAttr() const { return m_pINetAttr; }
91};
92
93class SwTextFieldContent final : public SwContent
94{
96public:
98 const OUString& rName,
99 const SwFormatField* pFormatField,
100 tools::Long nYPos)
101 : SwContent(pCnt, rName, nYPos),
102 m_pFormatField(pFormatField)
103 {}
104
106 virtual bool IsProtect() const override;
107};
108
110{
112public:
114 const OUString& rName,
115 const SwTextFootnote* pTextFootnote,
116 tools::Long nYPos)
117 : SwContent(pCnt, rName, nYPos),
118 m_pTextFootnote(pTextFootnote)
119 {}
120
122};
123
124class SwPostItContent final : public SwContent
125{
127public:
129 const OUString& rName,
130 const SwFormatField* pFormatField,
131 tools::Long nYPos )
132 : SwContent(pCnt, rName, nYPos)
133 , m_pField(pFormatField)
134 {}
135
136 const SwFormatField* GetPostIt() const { return m_pField; }
137 virtual bool IsProtect() const override;
138};
139
140class SwGraphicContent final : public SwContent
141{
142 OUString m_sLink;
143public:
144 SwGraphicContent(const SwContentType* pCnt, const OUString& rName, OUString aLink, tools::Long nYPos)
145 : SwContent( pCnt, rName, nYPos ), m_sLink(std::move( aLink ))
146 {}
147 virtual ~SwGraphicContent() override;
148
149 const OUString& GetLink() const {return m_sLink;}
150};
151
152class SwTOXBaseContent final : public SwContent
153{
155public:
156 SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, tools::Long nYPos, const SwTOXBase& rBase)
157 : SwContent( pCnt, rName, nYPos ), m_pBase(&rBase)
158 {}
159 virtual ~SwTOXBaseContent() override;
160
161 const SwTOXBase* GetTOXBase() const {return m_pBase;}
162};
163
172class SwContentType final : public SwTypeNumber
173{
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
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?
186
187 bool m_bAlphabeticSort = false;
188
189 static OUString RemoveNewline(const OUString&);
190public:
191 SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
192 virtual ~SwContentType() override;
193
195 void FillMemberList(bool* pbContentChanged = nullptr);
196 size_t GetMemberCount() const
197 {return m_nMemberCount;};
199
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;}
205
207 {
208 m_nOutlineLevel = nNew;
209 Invalidate();
210 }
211
212 bool GetSortType() const {return m_bAlphabeticSort;}
213 void SetSortType(bool bAlphabetic) {m_bAlphabeticSort = bAlphabetic;}
214
215 void Invalidate(); // only nMemberCount is read again
216
217 bool IsEditable() const {return m_bEdit;}
218 bool IsDeletable() const {return m_bDelete;}
219};
220
221#endif
222
223/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Content type, knows it's contents and the WrtShell.
Definition: content.hxx:173
OUString m_sSingleContentTypeName
Definition: content.hxx:178
void FillMemberList(bool *pbContentChanged=nullptr)
Fill the List of contents.
Definition: content.cxx:426
sal_uInt8 m_nOutlineLevel
Definition: content.hxx:182
void Invalidate()
Definition: content.cxx:421
bool GetSortType() const
Definition: content.hxx:212
void SetSortType(bool bAlphabetic)
Definition: content.hxx:213
size_t m_nMemberCount
Definition: content.hxx:180
SwWrtShell * m_pWrtShell
Definition: content.hxx:174
bool m_bDataValid
Definition: content.hxx:183
bool IsEditable() const
Definition: content.hxx:217
virtual ~SwContentType() override
Definition: content.cxx:405
const OUString & GetName() const
Definition: content.hxx:202
ContentTypeId GetType() const
Definition: content.hxx:198
SwContentType(SwWrtShell *pParent, ContentTypeId nType, sal_uInt8 nLevel)
Definition: content.cxx:326
std::unique_ptr< SwContentArr > m_pMember
Definition: content.hxx:176
bool IsDeletable() const
Definition: content.hxx:218
bool m_bAlphabeticSort
Definition: content.hxx:187
size_t GetMemberCount() const
Definition: content.hxx:196
const OUString & GetSingleName() const
Definition: content.hxx:203
const OUString & GetTypeToken() const
Definition: content.hxx:204
void SetOutlineLevel(sal_uInt8 nNew)
Definition: content.hxx:206
OUString m_sContentTypeName
Definition: content.hxx:177
bool m_bDelete
Definition: content.hxx:185
const SwContent * GetMember(size_t nIndex)
Deliver content, for that if necessary fill the list.
Definition: content.cxx:409
OUString m_sTypeToken
Definition: content.hxx:179
ContentTypeId m_nContentType
Definition: content.hxx:181
static OUString RemoveNewline(const OUString &)
Definition: content.cxx:4976
virtual ~SwGraphicContent() override
Definition: content.cxx:238
const OUString & GetLink() const
Definition: content.hxx:149
OUString m_sLink
Definition: content.hxx:142
SwGraphicContent(const SwContentType *pCnt, const OUString &rName, OUString aLink, tools::Long nYPos)
Definition: content.hxx:144
SwOutlineContent(const SwContentType *pCnt, const OUString &rName, SwOutlineNodes::size_type nArrPos, sal_uInt8 nLevel, bool bMove, double nYPos)
Definition: content.hxx:45
SwOutlineNodes::size_type m_nOutlinePos
Definition: content.hxx:41
bool IsMoveable() const
Definition: content.hxx:56
bool m_bIsMoveable
Definition: content.hxx:43
SwOutlineNodes::size_type GetOutlinePos() const
Definition: content.hxx:54
sal_uInt8 GetOutlineLevel() const
Definition: content.hxx:55
sal_uInt8 m_nOutlineLevel
Definition: content.hxx:42
SwPostItContent(const SwContentType *pCnt, const OUString &rName, const SwFormatField *pFormatField, tools::Long nYPos)
Definition: content.hxx:128
virtual bool IsProtect() const override
Definition: content.cxx:228
const SwFormatField * m_pField
Definition: content.hxx:126
const SwFormatField * GetPostIt() const
Definition: content.hxx:136
SwRegionContent(const SwContentType *pCnt, const OUString &rName, sal_uInt8 nLevel, tools::Long nYPos)
Definition: content.hxx:65
sal_uInt8 m_nRegionLevel
Definition: content.hxx:62
sal_uInt8 GetRegionLevel() const
Definition: content.hxx:71
SwTOXBaseContent(const SwContentType *pCnt, const OUString &rName, tools::Long nYPos, const SwTOXBase &rBase)
Definition: content.hxx:156
const SwTOXBase * GetTOXBase() const
Definition: content.hxx:161
const SwTOXBase * m_pBase
Definition: content.hxx:154
virtual ~SwTOXBaseContent() override
Definition: content.cxx:242
SwTextFieldContent(const SwContentType *pCnt, const OUString &rName, const SwFormatField *pFormatField, tools::Long nYPos)
Definition: content.hxx:97
const SwFormatField * GetFormatField() const
Definition: content.hxx:105
virtual bool IsProtect() const override
Definition: content.cxx:223
const SwFormatField * m_pFormatField
Definition: content.hxx:95
const SwTextFootnote * m_pTextFootnote
Definition: content.hxx:111
const SwTextFootnote * GetTextFootnote() const
Definition: content.hxx:121
SwTextFootnoteContent(const SwContentType *pCnt, const OUString &rName, const SwTextFootnote *pTextFootnote, tools::Long nYPos)
Definition: content.hxx:113
SwTextAttr subclass for footnotes and endnotes.
Definition: txtftn.hxx:34
SwTextAttr subclass that tracks the location of the wrapped SwFormatURL.
Definition: txtinet.hxx:30
const SwTextINetFormat * GetINetAttr() const
Definition: content.hxx:90
const SwTextINetFormat * m_pINetAttr
Definition: content.hxx:77
const OUString & GetURL() const
Definition: content.hxx:89
OUString m_sURL
Definition: content.hxx:76
SwURLFieldContent(const SwContentType *pCnt, const OUString &rName, OUString aURL, const SwTextINetFormat *pAttr, tools::Long nYPos)
Definition: content.hxx:80
virtual bool IsProtect() const override
Definition: content.cxx:233
Used by the UI to modify the document model.
Definition: wrtsh.hxx:97
URL aURL
long Long
ContentTypeId
Definition: swcont.hxx:30
unsigned char sal_uInt8