xref: /aoo41x/main/sw/source/ui/inc/content.hxx (revision 1d2dbeb0)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _CONTENT_HXX
24 #define _CONTENT_HXX
25 #include <limits.h>		// USHRT_MAX
26 #include "swcont.hxx"
27 
28 #ifndef _MENU_HXX //autogen
29 #include <vcl/menu.hxx>
30 #endif
31 
32 class SwWrtShell;
33 class SwContentArr;
34 class SwContentType;
35 class SwFmtFld;
36 class SwTxtINetFmt;
37 class SwTOXBase;
38 class SwRedline;
39 
40 //----------------------------------------------------------------------------
41 //	Hilfsklassen
42 //----------------------------------------------------------------------------
43 
44 class SwPopup : public PopupMenu
45 {
46 	sal_uInt16			nCurId;
Select()47 	virtual void    Select(){nCurId = GetCurItemId();}
48 
49 public:
SwPopup()50 	SwPopup() :
51 		PopupMenu(),
52 		nCurId(USHRT_MAX){}
53 
GetCurId() const54 	sal_uInt16			GetCurId() const { return nCurId; }
55 
56 };
57 
58 //----------------------------------------------------------------------------
59 
60 class SwOutlineContent : public SwContent
61 {
62 	sal_uInt16	nOutlinePos;
63 	sal_uInt8	nOutlineLevel;
64 	sal_Bool	bIsMoveable;
65 	public:
SwOutlineContent(const SwContentType * pCnt,const String & rName,sal_uInt16 nArrPos,sal_uInt8 nLevel,sal_Bool bMove,long nYPos)66 		SwOutlineContent(	const SwContentType* pCnt,
67 							const String& rName,
68 							sal_uInt16 nArrPos,
69 							sal_uInt8 nLevel,
70 							sal_Bool bMove,
71 							long nYPos) :
72 			SwContent(pCnt, rName, nYPos),
73 			nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
74 
GetPos()75 	sal_uInt16 	GetPos(){return nOutlinePos;}
GetOutlineLevel()76 	sal_uInt8 	GetOutlineLevel(){return nOutlineLevel;}
IsMoveable()77 	sal_Bool	IsMoveable(){return bIsMoveable;};
78 };
79 
80 //----------------------------------------------------------------------------
81 class SwRegionContent : public SwContent
82 {
83 
84 	sal_uInt8	nRegionLevel;
85 
86 	public:
SwRegionContent(const SwContentType * pCnt,const String & rName,sal_uInt8 nLevel,long nYPos)87 		SwRegionContent(	const SwContentType* pCnt,
88 							const String& rName,
89 							sal_uInt8 nLevel,
90 							long nYPos) :
91 			SwContent(pCnt, rName, nYPos),
92 						nRegionLevel(nLevel){}
GetRegionLevel() const93 	sal_uInt8 	GetRegionLevel() const {return nRegionLevel;}
94 };
95 //----------------------------------------------------------------------------
96 
97 class SwURLFieldContent : public SwContent
98 {
99 	String sURL;
100 	const SwTxtINetFmt* pINetAttr;
101 
102 public:
SwURLFieldContent(const SwContentType * pCnt,const String & rName,const String & rURL,const SwTxtINetFmt * pAttr,long nYPos)103 	SwURLFieldContent(	const SwContentType* pCnt,
104 							const String& rName,
105 							const String& rURL,
106 							const SwTxtINetFmt* pAttr,
107 							long nYPos )
108 		: SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
109 	{}
110 
111 	virtual sal_Bool	IsProtect() const;
GetURL()112 	const String& 	GetURL() 				{ return sURL; }
GetINetAttr()113 	const SwTxtINetFmt* GetINetAttr()		{ return pINetAttr; }
114 };
115 
116 //----------------------------------------------------------------------------
117 class SwPostItContent : public SwContent
118 {
119 	const SwFmtFld* 	pFld;
120 	SwRedline* 			pRedline;
121 	bool				mbPostIt;
122 public:
SwPostItContent(const SwContentType * pCnt,const String & rName,const SwFmtFld * pField,long nYPos)123 	SwPostItContent( const SwContentType* pCnt,
124 							const String& rName,
125 							const SwFmtFld* pField,
126 							long nYPos )
127 		: SwContent( pCnt, rName, nYPos ), pFld( pField ),mbPostIt(true)
128 	{}
SwPostItContent(const SwContentType * pCnt,const String & rName,SwRedline * pRed,long nYPos)129 	SwPostItContent( const SwContentType* pCnt,
130 							const String& rName,
131 							SwRedline* pRed,
132 							long nYPos )
133 		: SwContent( pCnt, rName, nYPos ), pRedline( pRed ),mbPostIt(false)
134 	{}
135 
GetPostIt()136 	const SwFmtFld* GetPostIt()		{ return pFld; }
GetRedline()137 	SwRedline* GetRedline()	{ return pRedline; }
138 	virtual sal_Bool	IsProtect()		const;
IsPostIt()139 	bool			IsPostIt()		{return mbPostIt; }
140 };
141 
142 //----------------------------------------------------------------------------
143 
144 class SwGraphicContent : public SwContent
145 {
146 	String 		sLink;
147 public:
SwGraphicContent(const SwContentType * pCnt,const String & rName,const String & rLink,long nYPos)148 	SwGraphicContent(const SwContentType* pCnt, const String& rName, const String& rLink, long nYPos)
149 		: SwContent( pCnt, rName, nYPos ), sLink( rLink )
150 		{}
151 	virtual ~SwGraphicContent();
152 
GetLink() const153 	const String& 	GetLink() const {return sLink;}
154 };
155 
156 //----------------------------------------------------------------------------
157 class SwTOXBaseContent : public SwContent
158 {
159 	const SwTOXBase* pBase;
160 public:
SwTOXBaseContent(const SwContentType * pCnt,const String & rName,long nYPos,const SwTOXBase & rBase)161 	SwTOXBaseContent(const SwContentType* pCnt, const String& rName, long nYPos, const SwTOXBase& rBase)
162 		: SwContent( pCnt, rName, nYPos ), pBase(&rBase)
163 		{}
164 	virtual ~SwTOXBaseContent();
165 
GetTOXBase() const166 	const SwTOXBase* GetTOXBase() const {return pBase;}
167 };
168 /*
169 	class ContentType enthaelt Informationen zu einer Inhaltsform
170 	Das MemberArray wird nur gefuellt, wenn der Inhalt mit GetMember
171 	angefordert wird. Es wird nach Invalidate() nur dann neu geladen,
172 	wenn der Inhalt erneut ausgelesen werden soll.
173 */
174 //----------------------------------------------------------------------------
175 //----------------------------------------------------------------------------
176 
177 class SwContentType : public SwTypeNumber
178 {
179 	SwWrtShell* 		pWrtShell;
180 	SwContentArr* 		pMember;			// Array fuer Inhalte
181 	String 				sContentTypeName; 	// Name der Inhaltsform
182 	String 				sSingleContentTypeName; // Name der Inhaltsform, Singular
183 	String 				sTypeToken;			// Anhaengsel fuer URL
184 	sal_uInt16				nMemberCount;		// Inhaltsanzahl
185 	sal_uInt16				nContentType;		// Id der Inhaltsform
186 	sal_uInt8 				nOutlineLevel;
187 	sal_Bool 				bMemberFilled : 1; 	// wurden die Inhalte bereits eingefuegt?
188 	sal_Bool 				bIsInternalDrag:1;	// koennen die Inhalte verschoben werden?
189 	sal_Bool				bDataValid : 	1;  //
190 	sal_Bool				bEdit:			1;	// kann diese Type bearbeitet werden ?
191 	sal_Bool				bDelete:		1;	// kann diese Type geloescht werden ?
192 protected:
193 		void			RemoveNewline(String&);
194 public:
195 		SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
196 		~SwContentType();
197 
198 		void				Init(sal_Bool* pbInvalidateWindow = 0);
199 		void				FillMemberList(sal_Bool* pbLevelChanged = NULL);
GetMemberCount() const200 		sal_uInt16				GetMemberCount() const
201 								{return nMemberCount;};
GetType() const202 		sal_uInt16				GetType() const {return nContentType;}
203 		const SwContent*	GetMember(sal_uInt16 nIndex);
GetName()204 		const String&		GetName() {return sContentTypeName;}
GetSingleName() const205 		const String&		GetSingleName() const {return sSingleContentTypeName;}
GetTypeToken() const206 		const String&		GetTypeToken() const{return sTypeToken;}
207 
SetOutlineLevel(sal_uInt8 nNew)208 		void				SetOutlineLevel(sal_uInt8 nNew)
209 							{
210 								nOutlineLevel = nNew;
211 								Invalidate();
212 							}
213 
214 		void				Invalidate(); // nur nMemberCount wird neu gelesen
215 
IsEditable() const216 		sal_Bool 				IsEditable() const {return bEdit;}
IsDeletable() const217 		sal_Bool				IsDeletable() const {return bDelete;}
218 };
219 
220 #endif
221 
222