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