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 
35 // helper classes
36 
37 class SwOutlineContent final : public SwContent
38 {
42  public:
44  const OUString& rName,
46  sal_uInt8 nLevel,
47  bool bMove,
48  tools::Long nYPos) :
49  SwContent(pCnt, rName, nYPos),
50  nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
51 
54  bool IsMoveable() const {return bIsMoveable;};
55 };
56 
57 class SwRegionContent final : public SwContent
58 {
59 
61 
62  public:
64  const OUString& rName,
65  sal_uInt8 nLevel,
66  tools::Long nYPos) :
67  SwContent(pCnt, rName, nYPos),
68  nRegionLevel(nLevel){}
70 };
71 
72 class SwURLFieldContent final : public SwContent
73 {
74  OUString sURL;
76 
77 public:
79  const OUString& rName,
80  const OUString& rURL,
81  const SwTextINetFormat* pAttr,
82  tools::Long nYPos )
83  : SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
84  {}
85 
86  virtual bool IsProtect() const override;
87  const OUString& GetURL() const { return sURL; }
88  const SwTextINetFormat* GetINetAttr() const { return pINetAttr; }
89 };
90 
91 class SwTextFieldContent final : public SwContent
92 {
94 public:
96  const OUString& rName,
97  const SwFormatField* pFormatField,
98  tools::Long nYPos)
99  : SwContent(pCnt, rName, nYPos),
100  m_pFormatField(pFormatField)
101  {}
102 
103  const SwFormatField* GetFormatField() const {return m_pFormatField;}
104  virtual bool IsProtect() const override;
105 };
106 
107 class SwPostItContent final : public SwContent
108 {
110 public:
112  const OUString& rName,
113  const SwFormatField* pFormatField,
114  tools::Long nYPos )
115  : SwContent(pCnt, rName, nYPos)
116  , pField(pFormatField)
117  {}
118 
119  const SwFormatField* GetPostIt() const { return pField; }
120  virtual bool IsProtect() const override;
121 };
122 
123 class SwGraphicContent final : public SwContent
124 {
125  OUString sLink;
126 public:
127  SwGraphicContent(const SwContentType* pCnt, const OUString& rName, const OUString& rLink, tools::Long nYPos)
128  : SwContent( pCnt, rName, nYPos ), sLink( rLink )
129  {}
130  virtual ~SwGraphicContent() override;
131 
132  const OUString& GetLink() const {return sLink;}
133 };
134 
135 class SwTOXBaseContent final : public SwContent
136 {
137  const SwTOXBase* pBase;
138 public:
139  SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, tools::Long nYPos, const SwTOXBase& rBase)
140  : SwContent( pCnt, rName, nYPos ), pBase(&rBase)
141  {}
142  virtual ~SwTOXBaseContent() override;
143 
144  const SwTOXBase* GetTOXBase() const {return pBase;}
145 };
146 
155 class SwContentType final : public SwTypeNumber
156 {
158  std::unique_ptr<SwContentArr>
159  m_pMember; // array for content
160  OUString m_sContentTypeName; // name of content type
161  OUString m_sSingleContentTypeName; // name of content type, singular
162  OUString m_sTypeToken; // attachment for URL
163  size_t m_nMemberCount; // content count
164  ContentTypeId m_nContentType; // content type's Id
166  bool m_bDataValid : 1;
167  bool m_bEdit: 1; // can this type be edited?
168  bool m_bDelete: 1; // can this type be deleted?
169 
170  static OUString RemoveNewline(const OUString&);
171 public:
172  SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
173  virtual ~SwContentType() override;
174 
175  void Init(bool* pbInvalidateWindow = nullptr);
176 
178  void FillMemberList(bool* pbLevelChanged = nullptr);
179  size_t GetMemberCount() const
180  {return m_nMemberCount;};
182 
184  const SwContent* GetMember(size_t nIndex);
185  const OUString& GetName() const {return m_sContentTypeName;}
186  const OUString& GetSingleName() const {return m_sSingleContentTypeName;}
187  const OUString& GetTypeToken() const{return m_sTypeToken;}
188 
190  {
191  m_nOutlineLevel = nNew;
192  Invalidate();
193  }
194 
195  void Invalidate(); // only nMemberCount is read again
196 
197  bool IsEditable() const {return m_bEdit;}
198  bool IsDeletable() const {return m_bDelete;}
199 };
200 
201 #endif
202 
203 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwURLFieldContent(const SwContentType *pCnt, const OUString &rName, const OUString &rURL, const SwTextINetFormat *pAttr, tools::Long nYPos)
Definition: content.hxx:78
void FillMemberList(bool *pbLevelChanged=nullptr)
Fill the List of contents.
Definition: content.cxx:601
void Init(bool *pbInvalidateWindow=nullptr)
Definition: content.cxx:333
ContentTypeId
Definition: swcont.hxx:29
virtual bool IsProtect() const override
Definition: content.cxx:228
OUString m_sTypeToken
Definition: content.hxx:162
const OUString & GetLink() const
Definition: content.hxx:132
virtual bool IsProtect() const override
Definition: content.cxx:218
const SwTextINetFormat * GetINetAttr() const
Definition: content.hxx:88
const SwTOXBase * pBase
Definition: content.hxx:137
SwGraphicContent(const SwContentType *pCnt, const OUString &rName, const OUString &rLink, tools::Long nYPos)
Definition: content.hxx:127
OUString m_sSingleContentTypeName
Definition: content.hxx:161
SwOutlineNodes::size_type nOutlinePos
Definition: content.hxx:39
long Long
OUString sLink
Definition: content.hxx:125
bool IsDeletable() const
Definition: content.hxx:198
const SwFormatField * GetFormatField() const
Definition: content.hxx:103
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
ContentTypeId GetType() const
Definition: content.hxx:181
SwContentType(SwWrtShell *pParent, ContentTypeId nType, sal_uInt8 nLevel)
Definition: content.cxx:318
ContentTypeId m_nContentType
Definition: content.hxx:164
const OUString & GetURL() const
Definition: content.hxx:87
size_t GetMemberCount() const
Definition: content.hxx:179
SwOutlineNodes::size_type GetOutlinePos() const
Definition: content.hxx:52
SwRegionContent(const SwContentType *pCnt, const OUString &rName, sal_uInt8 nLevel, tools::Long nYPos)
Definition: content.hxx:63
const OUString & GetSingleName() const
Definition: content.hxx:186
const SwTOXBase * GetTOXBase() const
Definition: content.hxx:144
sal_uInt8 GetRegionLevel() const
Definition: content.hxx:69
virtual ~SwContentType() override
Definition: content.cxx:580
OUString sURL
Definition: content.hxx:74
Content type, knows it's contents and the WrtShell.
Definition: content.hxx:155
virtual ~SwGraphicContent() override
Definition: content.cxx:233
const SwTextINetFormat * pINetAttr
Definition: content.hxx:75
const OUString & GetTypeToken() const
Definition: content.hxx:187
sal_uInt8 m_nOutlineLevel
Definition: content.hxx:165
std::unique_ptr< SwContentArr > m_pMember
Definition: content.hxx:159
void SetOutlineLevel(sal_uInt8 nNew)
Definition: content.hxx:189
void Invalidate()
Definition: content.cxx:596
sal_uInt8 nRegionLevel
Definition: content.hxx:60
bool m_bDelete
Definition: content.hxx:168
SwOutlineContent(const SwContentType *pCnt, const OUString &rName, SwOutlineNodes::size_type nArrPos, sal_uInt8 nLevel, bool bMove, tools::Long nYPos)
Definition: content.hxx:43
bool IsEditable() const
Definition: content.hxx:197
SwPostItContent(const SwContentType *pCnt, const OUString &rName, const SwFormatField *pFormatField, tools::Long nYPos)
Definition: content.hxx:111
static OUString RemoveNewline(const OUString &)
Definition: content.cxx:4320
bool IsMoveable() const
Definition: content.hxx:54
unsigned char sal_uInt8
virtual ~SwTOXBaseContent() override
Definition: content.cxx:237
const SwFormatField * m_pFormatField
Definition: content.hxx:93
const SwFormatField * GetPostIt() const
Definition: content.hxx:119
size_t m_nMemberCount
Definition: content.hxx:163
bool m_bDataValid
Definition: content.hxx:166
virtual bool IsProtect() const override
Definition: content.cxx:223
const OUString & GetName() const
Definition: content.hxx:185
OUString m_sContentTypeName
Definition: content.hxx:160
sal_uInt8 GetOutlineLevel() const
Definition: content.hxx:53
const SwFormatField * pField
Definition: content.hxx:109
const SwContent * GetMember(size_t nIndex)
Deliver content, for that if necessary fill the list.
Definition: content.cxx:584
sal_uInt8 nOutlineLevel
Definition: content.hxx:40
std::vector< SwNode * >::size_type size_type
SwTextFieldContent(const SwContentType *pCnt, const OUString &rName, const SwFormatField *pFormatField, tools::Long nYPos)
Definition: content.hxx:95
SwWrtShell * m_pWrtShell
Definition: content.hxx:157
SwTOXBaseContent(const SwContentType *pCnt, const OUString &rName, tools::Long nYPos, const SwTOXBase &rBase)
Definition: content.hxx:139