bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / inc / content.hxx
blob57c292748db0e1cfe4cebe715b0df382ae61854a
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 _CONTENT_HXX
20 #define _CONTENT_HXX
21 #include <limits.h> // USHRT_MAX
22 #include "swcont.hxx"
24 #include <vcl/menu.hxx>
26 class SwWrtShell;
27 class SwContentArr;
28 class SwContentType;
29 class SwFmtFld;
30 class SwTxtINetFmt;
31 class SwTOXBase;
32 class SwRedline;
34 //----------------------------------------------------------------------------
35 // helper classes
36 //----------------------------------------------------------------------------
38 class SwPopup : public PopupMenu
40 sal_uInt16 nCurId;
41 virtual void Select(){nCurId = GetCurItemId();}
43 public:
44 SwPopup() :
45 PopupMenu(),
46 nCurId(USHRT_MAX){}
48 sal_uInt16 GetCurId() const { return nCurId; }
52 //----------------------------------------------------------------------------
54 class SwOutlineContent : public SwContent
56 sal_uInt16 nOutlinePos;
57 sal_uInt8 nOutlineLevel;
58 bool bIsMoveable;
59 public:
60 SwOutlineContent( const SwContentType* pCnt,
61 const String& rName,
62 sal_uInt16 nArrPos,
63 sal_uInt8 nLevel,
64 bool bMove,
65 long nYPos) :
66 SwContent(pCnt, rName, nYPos),
67 nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
69 sal_uInt16 GetPos(){return nOutlinePos;}
70 sal_uInt8 GetOutlineLevel(){return nOutlineLevel;}
71 bool IsMoveable(){return bIsMoveable;};
74 //----------------------------------------------------------------------------
75 class SwRegionContent : public SwContent
78 sal_uInt8 nRegionLevel;
80 public:
81 SwRegionContent( const SwContentType* pCnt,
82 const String& rName,
83 sal_uInt8 nLevel,
84 long nYPos) :
85 SwContent(pCnt, rName, nYPos),
86 nRegionLevel(nLevel){}
87 sal_uInt8 GetRegionLevel() const {return nRegionLevel;}
89 //----------------------------------------------------------------------------
91 class SwURLFieldContent : public SwContent
93 String sURL;
94 const SwTxtINetFmt* pINetAttr;
96 public:
97 SwURLFieldContent( const SwContentType* pCnt,
98 const String& rName,
99 const String& rURL,
100 const SwTxtINetFmt* pAttr,
101 long nYPos )
102 : SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
105 virtual sal_Bool IsProtect() const;
106 const String& GetURL() { return sURL; }
107 const SwTxtINetFmt* GetINetAttr() { return pINetAttr; }
110 //----------------------------------------------------------------------------
111 class SwPostItContent : public SwContent
113 const SwFmtFld* pFld;
114 SwRedline* pRedline;
115 bool mbPostIt;
116 public:
117 SwPostItContent( const SwContentType* pCnt,
118 const String& rName,
119 const SwFmtFld* pField,
120 long nYPos )
121 : SwContent( pCnt, rName, nYPos ), pFld( pField ),mbPostIt(true)
123 SwPostItContent( const SwContentType* pCnt,
124 const String& rName,
125 SwRedline* pRed,
126 long nYPos )
127 : SwContent( pCnt, rName, nYPos ), pRedline( pRed ),mbPostIt(false)
130 const SwFmtFld* GetPostIt() { return pFld; }
131 SwRedline* GetRedline() { return pRedline; }
132 virtual sal_Bool IsProtect() const;
133 bool IsPostIt() {return mbPostIt; }
136 //----------------------------------------------------------------------------
138 class SwGraphicContent : public SwContent
140 String sLink;
141 public:
142 SwGraphicContent(const SwContentType* pCnt, const String& rName, const String& rLink, long nYPos)
143 : SwContent( pCnt, rName, nYPos ), sLink( rLink )
145 virtual ~SwGraphicContent();
147 const String& GetLink() const {return sLink;}
150 //----------------------------------------------------------------------------
151 class SwTOXBaseContent : public SwContent
153 const SwTOXBase* pBase;
154 public:
155 SwTOXBaseContent(const SwContentType* pCnt, const String& rName, long nYPos, const SwTOXBase& rBase)
156 : SwContent( pCnt, rName, nYPos ), pBase(&rBase)
158 virtual ~SwTOXBaseContent();
160 const SwTOXBase* GetTOXBase() const {return pBase;}
163 class ContentType contains information to one type of content.
164 MemberArray is only populated if the content is requested by
165 GetMember. It is reloaded after Invalidate() only if the content
166 should be read again.
168 //----------------------------------------------------------------------------
170 class SwContentType : public SwTypeNumber
172 SwWrtShell* pWrtShell;
173 SwContentArr* pMember; // array for content
174 String sContentTypeName; // name of content type
175 String sSingleContentTypeName; // name of content type, singular
176 String sTypeToken; // attachment for URL
177 sal_uInt16 nMemberCount; // content count
178 sal_uInt16 nContentType; // content type's Id
179 sal_uInt8 nOutlineLevel;
180 bool bDataValid : 1; //
181 bool bEdit: 1; // can this type be edited?
182 bool bDelete: 1; // can this type be deleted?
183 protected:
184 void RemoveNewline(String&);
185 public:
186 SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
187 ~SwContentType();
189 void Init(sal_Bool* pbInvalidateWindow = 0);
190 void FillMemberList(sal_Bool* pbLevelChanged = NULL);
191 sal_uInt16 GetMemberCount() const
192 {return nMemberCount;};
193 sal_uInt16 GetType() const {return nContentType;}
194 const SwContent* GetMember(sal_uInt16 nIndex);
195 const String& GetName() {return sContentTypeName;}
196 const String& GetSingleName() const {return sSingleContentTypeName;}
197 const String& GetTypeToken() const{return sTypeToken;}
199 void SetOutlineLevel(sal_uInt8 nNew)
201 nOutlineLevel = nNew;
202 Invalidate();
205 void Invalidate(); // only nMemberCount is read again
207 bool IsEditable() const {return bEdit;}
208 bool IsDeletable() const {return bDelete;}
211 #endif
213 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */