Revert "tdf#158280 Replace usage of InputDialog with SvxNameDialog"
[LibreOffice.git] / sw / source / uibase / inc / content.hxx
blobf0aad555619c81a4a673a2acf57ffd7dbb3067a0
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;
63 const SwSectionFormat* m_pSectionFormat;
65 public:
66 SwRegionContent( const SwContentType* pCnt,
67 const OUString& rName,
68 sal_uInt8 nLevel,
69 tools::Long nYPos,
70 const SwSectionFormat* pSectionFormat) :
71 SwContent(pCnt, rName, nYPos),
72 m_nRegionLevel(nLevel), m_pSectionFormat(pSectionFormat){}
73 sal_uInt8 GetRegionLevel() const {return m_nRegionLevel;}
74 const SwSectionFormat* GetSectionFormat() const {return m_pSectionFormat;}
76 bool IsProtect() const override;
79 class SwURLFieldContent final : public SwContent
81 OUString m_sURL;
82 const SwTextINetFormat* m_pINetAttr;
84 public:
85 SwURLFieldContent( const SwContentType* pCnt,
86 const OUString& rName,
87 OUString aURL,
88 const SwTextINetFormat* pAttr,
89 tools::Long nYPos )
90 : SwContent( pCnt, rName, nYPos ), m_sURL(std::move( aURL )), m_pINetAttr( pAttr )
93 virtual bool IsProtect() const override;
94 const OUString& GetURL() const { return m_sURL; }
95 const SwTextINetFormat* GetINetAttr() const { return m_pINetAttr; }
98 class SwTextFieldContent final : public SwContent
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 : SwContent(pCnt, rName, nYPos),
107 m_pFormatField(pFormatField)
110 const SwFormatField* GetFormatField() const {return m_pFormatField;}
111 virtual bool IsProtect() const override;
114 class SwTextFootnoteContent final : public SwContent
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 : SwContent(pCnt, rName, nYPos),
123 m_pTextFootnote(pTextFootnote)
126 const SwTextFootnote* GetTextFootnote() const {return m_pTextFootnote;}
129 class SwPostItContent final : public SwContent
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 : SwContent(pCnt, rName, nYPos)
138 , m_pField(pFormatField)
141 const SwFormatField* GetPostIt() const { return m_pField; }
142 virtual bool IsProtect() const override;
145 class SwGraphicContent final : public SwContent
147 OUString m_sLink;
148 public:
149 SwGraphicContent(const SwContentType* pCnt, const OUString& rName, OUString aLink, tools::Long nYPos)
150 : SwContent( pCnt, rName, nYPos ), m_sLink(std::move( aLink ))
152 virtual ~SwGraphicContent() override;
154 const OUString& GetLink() const {return m_sLink;}
157 class SwTOXBaseContent final : public SwContent
159 const SwTOXBase* m_pBase;
160 public:
161 SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, tools::Long nYPos, const SwTOXBase& rBase)
162 : SwContent( pCnt, rName, nYPos ), m_pBase(&rBase)
164 virtual ~SwTOXBaseContent() override;
166 const SwTOXBase* GetTOXBase() const {return m_pBase;}
170 * Content type, knows it's contents and the WrtShell.
172 * The class ContentType contains information to one type of content.
173 * MemberArray is only populated if the content is requested by
174 * GetMember. It is reloaded after Invalidate() only if the content
175 * should be read again.
177 class SwContentType final : public SwTypeNumber
179 SwWrtShell* m_pWrtShell;
180 std::unique_ptr<SwContentArr>
181 m_pMember; // array for content
182 OUString m_sContentTypeName; // name of content type
183 OUString m_sSingleContentTypeName; // name of content type, singular
184 OUString m_sTypeToken; // attachment for URL
185 size_t m_nMemberCount; // content count
186 ContentTypeId m_nContentType; // content type's Id
187 sal_uInt8 m_nOutlineLevel;
188 bool m_bDataValid : 1;
189 bool m_bEdit: 1; // can this type be edited?
190 bool m_bDelete: 1; // can this type be deleted?
191 bool m_bRenamable = false;
193 bool m_bAlphabeticSort = false;
195 static OUString RemoveNewline(const OUString&);
196 public:
197 SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
198 virtual ~SwContentType() override;
200 /** Fill the List of contents */
201 void FillMemberList(bool* pbContentChanged = nullptr);
202 size_t GetMemberCount() const
203 {return m_nMemberCount;};
204 ContentTypeId GetType() const {return m_nContentType;}
206 /** Deliver content, for that if necessary fill the list */
207 const SwContent* GetMember(size_t nIndex);
208 const OUString& GetName() const {return m_sContentTypeName;}
209 const OUString& GetSingleName() const {return m_sSingleContentTypeName;}
210 const OUString& GetTypeToken() const{return m_sTypeToken;}
212 void SetOutlineLevel(sal_uInt8 nNew)
214 m_nOutlineLevel = nNew;
215 Invalidate();
218 bool IsAlphabeticSort() const {return m_bAlphabeticSort;}
219 void SetAlphabeticSort(bool bAlphabetic) {m_bAlphabeticSort = bAlphabetic;}
221 void Invalidate(); // only nMemberCount is read again
223 bool IsEditable() const {return m_bEdit;}
224 bool IsDeletable() const {return m_bDelete;}
225 bool IsRenamable() const {return m_bRenamable;}
228 #endif
230 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */