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