Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : : #ifndef _CONTENT_HXX
29 : : #define _CONTENT_HXX
30 : : #include <limits.h> // USHRT_MAX
31 : : #include "swcont.hxx"
32 : :
33 : : #include <vcl/menu.hxx>
34 : :
35 : : class SwWrtShell;
36 : : class SwContentArr;
37 : : class SwContentType;
38 : : class SwFmtFld;
39 : : class SwTxtINetFmt;
40 : : class SwTOXBase;
41 : : class SwRedline;
42 : :
43 : : //----------------------------------------------------------------------------
44 : : // helper classes
45 : : //----------------------------------------------------------------------------
46 : :
47 [ # # ]: 0 : class SwPopup : public PopupMenu
48 : : {
49 : : sal_uInt16 nCurId;
50 : 0 : virtual void Select(){nCurId = GetCurItemId();}
51 : :
52 : : public:
53 : : SwPopup() :
54 : : PopupMenu(),
55 : : nCurId(USHRT_MAX){}
56 : :
57 : : sal_uInt16 GetCurId() const { return nCurId; }
58 : :
59 : : };
60 : :
61 : : //----------------------------------------------------------------------------
62 : :
63 [ # # ]: 0 : class SwOutlineContent : public SwContent
64 : : {
65 : : sal_uInt16 nOutlinePos;
66 : : sal_uInt8 nOutlineLevel;
67 : : sal_Bool bIsMoveable;
68 : : public:
69 : 0 : SwOutlineContent( const SwContentType* pCnt,
70 : : const String& rName,
71 : : sal_uInt16 nArrPos,
72 : : sal_uInt8 nLevel,
73 : : sal_Bool bMove,
74 : : long nYPos) :
75 : : SwContent(pCnt, rName, nYPos),
76 : 0 : nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
77 : :
78 : 0 : sal_uInt16 GetPos(){return nOutlinePos;}
79 : 0 : sal_uInt8 GetOutlineLevel(){return nOutlineLevel;}
80 : 0 : sal_Bool IsMoveable(){return bIsMoveable;};
81 : : };
82 : :
83 : : //----------------------------------------------------------------------------
84 [ # # ]: 0 : class SwRegionContent : public SwContent
85 : : {
86 : :
87 : : sal_uInt8 nRegionLevel;
88 : :
89 : : public:
90 : 0 : SwRegionContent( const SwContentType* pCnt,
91 : : const String& rName,
92 : : sal_uInt8 nLevel,
93 : : long nYPos) :
94 : : SwContent(pCnt, rName, nYPos),
95 : 0 : nRegionLevel(nLevel){}
96 : 0 : sal_uInt8 GetRegionLevel() const {return nRegionLevel;}
97 : : };
98 : : //----------------------------------------------------------------------------
99 : :
100 [ # # ][ # # ]: 0 : class SwURLFieldContent : public SwContent
101 : : {
102 : : String sURL;
103 : : const SwTxtINetFmt* pINetAttr;
104 : :
105 : : public:
106 : 0 : SwURLFieldContent( const SwContentType* pCnt,
107 : : const String& rName,
108 : : const String& rURL,
109 : : const SwTxtINetFmt* pAttr,
110 : : long nYPos )
111 [ # # ]: 0 : : SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
112 : 0 : {}
113 : :
114 : : virtual sal_Bool IsProtect() const;
115 : 0 : const String& GetURL() { return sURL; }
116 : 0 : const SwTxtINetFmt* GetINetAttr() { return pINetAttr; }
117 : : };
118 : :
119 : : //----------------------------------------------------------------------------
120 [ # # ]: 0 : class SwPostItContent : public SwContent
121 : : {
122 : : const SwFmtFld* pFld;
123 : : SwRedline* pRedline;
124 : : bool mbPostIt;
125 : : public:
126 : 0 : SwPostItContent( const SwContentType* pCnt,
127 : : const String& rName,
128 : : const SwFmtFld* pField,
129 : : long nYPos )
130 : 0 : : SwContent( pCnt, rName, nYPos ), pFld( pField ),mbPostIt(true)
131 : 0 : {}
132 : : SwPostItContent( const SwContentType* pCnt,
133 : : const String& rName,
134 : : SwRedline* pRed,
135 : : long nYPos )
136 : : : SwContent( pCnt, rName, nYPos ), pRedline( pRed ),mbPostIt(false)
137 : : {}
138 : :
139 : 0 : const SwFmtFld* GetPostIt() { return pFld; }
140 : 0 : SwRedline* GetRedline() { return pRedline; }
141 : : virtual sal_Bool IsProtect() const;
142 : 0 : bool IsPostIt() {return mbPostIt; }
143 : : };
144 : :
145 : : //----------------------------------------------------------------------------
146 : :
147 : : class SwGraphicContent : public SwContent
148 : : {
149 : : String sLink;
150 : : public:
151 : 0 : SwGraphicContent(const SwContentType* pCnt, const String& rName, const String& rLink, long nYPos)
152 [ # # ]: 0 : : SwContent( pCnt, rName, nYPos ), sLink( rLink )
153 : 0 : {}
154 : : virtual ~SwGraphicContent();
155 : :
156 : 0 : const String& GetLink() const {return sLink;}
157 : : };
158 : :
159 : : //----------------------------------------------------------------------------
160 : : class SwTOXBaseContent : public SwContent
161 : : {
162 : : const SwTOXBase* pBase;
163 : : public:
164 : 0 : SwTOXBaseContent(const SwContentType* pCnt, const String& rName, long nYPos, const SwTOXBase& rBase)
165 : 0 : : SwContent( pCnt, rName, nYPos ), pBase(&rBase)
166 : 0 : {}
167 : : virtual ~SwTOXBaseContent();
168 : :
169 : 0 : const SwTOXBase* GetTOXBase() const {return pBase;}
170 : : };
171 : : /*
172 : : class ContentType contains information to one type of content.
173 : : MemberArray is only populated if the content is requested by
174 : : GetMember. It is reloaded after Invalidate() only if the content
175 : : should be read again.
176 : : */
177 : : //----------------------------------------------------------------------------
178 : :
179 : : class SwContentType : public SwTypeNumber
180 : : {
181 : : SwWrtShell* pWrtShell;
182 : : SwContentArr* pMember; // array for content
183 : : String sContentTypeName; // name of content type
184 : : String sSingleContentTypeName; // name of content type, singular
185 : : String sTypeToken; // attachment for URL
186 : : sal_uInt16 nMemberCount; // content count
187 : : sal_uInt16 nContentType; // content type's Id
188 : : sal_uInt8 nOutlineLevel;
189 : : sal_Bool bMemberFilled : 1; // has content already been inserted?
190 : : sal_Bool bIsInternalDrag:1; // can content be relocated?
191 : : sal_Bool bDataValid : 1; //
192 : : sal_Bool bEdit: 1; // can this type be edited?
193 : : sal_Bool bDelete: 1; // can this type be deleted?
194 : : protected:
195 : : void RemoveNewline(String&);
196 : : public:
197 : : SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
198 : : ~SwContentType();
199 : :
200 : : void Init(sal_Bool* pbInvalidateWindow = 0);
201 : : void FillMemberList(sal_Bool* pbLevelChanged = NULL);
202 : 0 : sal_uInt16 GetMemberCount() const
203 : 0 : {return nMemberCount;};
204 : 0 : sal_uInt16 GetType() const {return nContentType;}
205 : : const SwContent* GetMember(sal_uInt16 nIndex);
206 : 0 : const String& GetName() {return sContentTypeName;}
207 : 0 : const String& GetSingleName() const {return sSingleContentTypeName;}
208 : 0 : const String& GetTypeToken() const{return sTypeToken;}
209 : :
210 : 0 : void SetOutlineLevel(sal_uInt8 nNew)
211 : : {
212 : 0 : nOutlineLevel = nNew;
213 : 0 : Invalidate();
214 : 0 : }
215 : :
216 : : void Invalidate(); // only nMemberCount is read again
217 : :
218 : 0 : sal_Bool IsEditable() const {return bEdit;}
219 : 0 : sal_Bool IsDeletable() const {return bDelete;}
220 : : };
221 : :
222 : : #endif
223 : :
224 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|