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 
26 class SwWrtShell;
27 class SwContentArr;
28 class SwContentType;
29 class SwFormatField;
30 class SwTextINetFormat;
31 class SwTOXBase;
32 class SwRangeRedline;
33 
34 // helper classes
35 
37 {
40  bool const bIsMoveable;
41  public:
43  const OUString& rName,
45  sal_uInt8 nLevel,
46  bool bMove,
47  long nYPos) :
48  SwContent(pCnt, rName, nYPos),
49  nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
50 
53  bool IsMoveable() const {return bIsMoveable;};
54 };
55 
56 class SwRegionContent : public SwContent
57 {
58 
60 
61  public:
63  const OUString& rName,
64  sal_uInt8 nLevel,
65  long nYPos) :
66  SwContent(pCnt, rName, nYPos),
67  nRegionLevel(nLevel){}
69 };
70 
72 {
73  OUString const sURL;
75 
76 public:
78  const OUString& rName,
79  const OUString& rURL,
80  const SwTextINetFormat* pAttr,
81  long nYPos )
82  : SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
83  {}
84 
85  virtual bool IsProtect() const override;
86  const OUString& GetURL() const { return sURL; }
87  const SwTextINetFormat* GetINetAttr() { return pINetAttr; }
88 };
89 
90 class SwPostItContent : public SwContent
91 {
93 public:
95  const OUString& rName,
96  const SwFormatField* pFormatField,
97  long nYPos )
98  : SwContent(pCnt, rName, nYPos)
99  , pField(pFormatField)
100  {}
101 
102  const SwFormatField* GetPostIt() const { return pField; }
103  virtual bool IsProtect() const override;
104 };
105 
107 {
108  OUString const sLink;
109 public:
110  SwGraphicContent(const SwContentType* pCnt, const OUString& rName, const OUString& rLink, long nYPos)
111  : SwContent( pCnt, rName, nYPos ), sLink( rLink )
112  {}
113  virtual ~SwGraphicContent() override;
114 
115  const OUString& GetLink() const {return sLink;}
116 };
117 
119 {
120  const SwTOXBase* pBase;
121 public:
122  SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, long nYPos, const SwTOXBase& rBase)
123  : SwContent( pCnt, rName, nYPos ), pBase(&rBase)
124  {}
125  virtual ~SwTOXBaseContent() override;
126 
127  const SwTOXBase* GetTOXBase() const {return pBase;}
128 };
129 
139 {
141  std::unique_ptr<SwContentArr>
142  m_pMember; // array for content
143  OUString const m_sContentTypeName; // name of content type
144  OUString const m_sSingleContentTypeName; // name of content type, singular
145  OUString m_sTypeToken; // attachment for URL
146  size_t m_nMemberCount; // content count
147  ContentTypeId const m_nContentType; // content type's Id
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?
152 protected:
153  static OUString RemoveNewline(const OUString&);
154 public:
155  SwContentType(SwWrtShell* pParent, ContentTypeId nType, sal_uInt8 nLevel );
156  virtual ~SwContentType() override;
157 
158  void Init(bool* pbInvalidateWindow = nullptr);
159 
161  void FillMemberList(bool* pbLevelChanged = nullptr);
162  size_t GetMemberCount() const
163  {return m_nMemberCount;};
165 
167  const SwContent* GetMember(size_t nIndex);
168  const OUString& GetName() {return m_sContentTypeName;}
169  const OUString& GetSingleName() const {return m_sSingleContentTypeName;}
170  const OUString& GetTypeToken() const{return m_sTypeToken;}
171 
173  {
174  m_nOutlineLevel = nNew;
175  Invalidate();
176  }
177 
178  void Invalidate(); // only nMemberCount is read again
179 
180  bool IsEditable() const {return m_bEdit;}
181  bool IsDeletable() const {return m_bDelete;}
182 };
183 
184 #endif
185 
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void FillMemberList(bool *pbLevelChanged=nullptr)
Fill the List of contents.
Definition: content.cxx:521
void Init(bool *pbInvalidateWindow=nullptr)
Definition: content.cxx:284
ContentTypeId
Definition: swcont.hxx:28
virtual bool IsProtect() const override
Definition: content.cxx:201
OUString m_sTypeToken
Definition: content.hxx:145
const OUString & GetLink() const
Definition: content.hxx:115
const SwTOXBase * pBase
Definition: content.hxx:120
SwTOXBaseContent(const SwContentType *pCnt, const OUString &rName, long nYPos, const SwTOXBase &rBase)
Definition: content.hxx:122
SwRegionContent(const SwContentType *pCnt, const OUString &rName, sal_uInt8 nLevel, long nYPos)
Definition: content.hxx:62
SwPostItContent(const SwContentType *pCnt, const OUString &rName, const SwFormatField *pFormatField, long nYPos)
Definition: content.hxx:94
bool IsDeletable() const
Definition: content.hxx:181
Used by the UI to modify the document model.
Definition: wrtsh.hxx:88
ContentTypeId GetType() const
Definition: content.hxx:164
const SwTextINetFormat * GetINetAttr()
Definition: content.hxx:87
SwContentType(SwWrtShell *pParent, ContentTypeId nType, sal_uInt8 nLevel)
Definition: content.cxx:269
const OUString & GetURL() const
Definition: content.hxx:86
size_t GetMemberCount() const
Definition: content.hxx:162
SwOutlineNodes::size_type GetOutlinePos() const
Definition: content.hxx:51
const OUString & GetSingleName() const
Definition: content.hxx:169
const SwTOXBase * GetTOXBase() const
Definition: content.hxx:127
sal_uInt8 GetRegionLevel() const
Definition: content.hxx:68
virtual ~SwContentType() override
Definition: content.cxx:500
bool const bIsMoveable
Definition: content.hxx:40
SwURLFieldContent(const SwContentType *pCnt, const OUString &rName, const OUString &rURL, const SwTextINetFormat *pAttr, long nYPos)
Definition: content.hxx:77
OUString const sURL
Definition: content.hxx:73
const OUString & GetName()
Definition: content.hxx:168
Content type, knows it's contents and the WrtShell.
Definition: content.hxx:138
virtual ~SwGraphicContent() override
Definition: content.cxx:206
const SwTextINetFormat * pINetAttr
Definition: content.hxx:74
const OUString & GetTypeToken() const
Definition: content.hxx:170
sal_uInt8 m_nOutlineLevel
Definition: content.hxx:148
std::unique_ptr< SwContentArr > m_pMember
Definition: content.hxx:142
sal_uInt8 const nOutlineLevel
Definition: content.hxx:39
void SetOutlineLevel(sal_uInt8 nNew)
Definition: content.hxx:172
void Invalidate()
Definition: content.cxx:516
OUString const m_sContentTypeName
Definition: content.hxx:143
ContentTypeId const m_nContentType
Definition: content.hxx:147
bool m_bDelete
Definition: content.hxx:151
bool IsEditable() const
Definition: content.hxx:180
static OUString RemoveNewline(const OUString &)
Definition: content.cxx:3395
bool IsMoveable() const
Definition: content.hxx:53
unsigned char sal_uInt8
virtual ~SwTOXBaseContent() override
Definition: content.cxx:210
const SwFormatField * GetPostIt() const
Definition: content.hxx:102
size_t m_nMemberCount
Definition: content.hxx:146
OUString const sLink
Definition: content.hxx:108
SwGraphicContent(const SwContentType *pCnt, const OUString &rName, const OUString &rLink, long nYPos)
Definition: content.hxx:110
sal_uInt8 const nRegionLevel
Definition: content.hxx:59
bool m_bDataValid
Definition: content.hxx:149
virtual bool IsProtect() const override
Definition: content.cxx:196
sal_uInt8 GetOutlineLevel() const
Definition: content.hxx:52
const SwFormatField * pField
Definition: content.hxx:92
SwOutlineNodes::size_type const nOutlinePos
Definition: content.hxx:38
const SwContent * GetMember(size_t nIndex)
Deliver content, for that if necessary fill the list.
Definition: content.cxx:504
SwOutlineContent(const SwContentType *pCnt, const OUString &rName, SwOutlineNodes::size_type nArrPos, sal_uInt8 nLevel, bool bMove, long nYPos)
Definition: content.hxx:42
std::vector< SwNode * >::size_type size_type
SwWrtShell * m_pWrtShell
Definition: content.hxx:140
OUString const m_sSingleContentTypeName
Definition: content.hxx:144