Line data Source code
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 <limits.h>
22 : #include "swcont.hxx"
23 :
24 : #include <vcl/menu.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 :
36 0 : class SwOutlineContent : public SwContent
37 : {
38 : sal_uInt16 nOutlinePos;
39 : sal_uInt8 nOutlineLevel;
40 : bool bIsMoveable;
41 : public:
42 0 : SwOutlineContent( const SwContentType* pCnt,
43 : const OUString& rName,
44 : sal_uInt16 nArrPos,
45 : sal_uInt8 nLevel,
46 : bool bMove,
47 : long nYPos) :
48 : SwContent(pCnt, rName, nYPos),
49 0 : nOutlinePos(nArrPos), nOutlineLevel(nLevel), bIsMoveable(bMove) {}
50 :
51 0 : sal_uInt16 GetPos() const {return nOutlinePos;}
52 0 : sal_uInt8 GetOutlineLevel() const {return nOutlineLevel;}
53 0 : bool IsMoveable() const {return bIsMoveable;};
54 : };
55 :
56 0 : class SwRegionContent : public SwContent
57 : {
58 :
59 : sal_uInt8 nRegionLevel;
60 :
61 : public:
62 0 : SwRegionContent( const SwContentType* pCnt,
63 : const OUString& rName,
64 : sal_uInt8 nLevel,
65 : long nYPos) :
66 : SwContent(pCnt, rName, nYPos),
67 0 : nRegionLevel(nLevel){}
68 0 : sal_uInt8 GetRegionLevel() const {return nRegionLevel;}
69 : };
70 :
71 0 : class SwURLFieldContent : public SwContent
72 : {
73 : OUString sURL;
74 : const SwTextINetFormat* pINetAttr;
75 :
76 : public:
77 0 : SwURLFieldContent( const SwContentType* pCnt,
78 : const OUString& rName,
79 : const OUString& rURL,
80 : const SwTextINetFormat* pAttr,
81 : long nYPos )
82 0 : : SwContent( pCnt, rName, nYPos ), sURL( rURL ), pINetAttr( pAttr )
83 0 : {}
84 :
85 : virtual bool IsProtect() const SAL_OVERRIDE;
86 0 : const OUString& GetURL() const { return sURL; }
87 0 : const SwTextINetFormat* GetINetAttr() { return pINetAttr; }
88 : };
89 :
90 0 : class SwPostItContent : public SwContent
91 : {
92 : const SwFormatField* pField;
93 : SwRangeRedline* pRedline;
94 : bool mbPostIt;
95 : public:
96 0 : SwPostItContent( const SwContentType* pCnt,
97 : const OUString& rName,
98 : const SwFormatField* pFormatField,
99 : long nYPos )
100 : : SwContent(pCnt, rName, nYPos)
101 : , pField(pFormatField)
102 : , pRedline(NULL)
103 0 : , mbPostIt(true)
104 0 : {}
105 : SwPostItContent( const SwContentType* pCnt,
106 : const OUString& rName,
107 : SwRangeRedline* pRed,
108 : long nYPos )
109 : : SwContent(pCnt, rName, nYPos)
110 : , pField(NULL)
111 : , pRedline(pRed)
112 : , mbPostIt(false)
113 : {}
114 :
115 0 : const SwFormatField* GetPostIt() const { return pField; }
116 0 : SwRangeRedline* GetRedline() { return pRedline; }
117 : virtual bool IsProtect() const SAL_OVERRIDE;
118 0 : bool IsPostIt() const {return mbPostIt; }
119 : };
120 :
121 : class SwGraphicContent : public SwContent
122 : {
123 : OUString sLink;
124 : public:
125 0 : SwGraphicContent(const SwContentType* pCnt, const OUString& rName, const OUString& rLink, long nYPos)
126 0 : : SwContent( pCnt, rName, nYPos ), sLink( rLink )
127 0 : {}
128 : virtual ~SwGraphicContent();
129 :
130 0 : const OUString& GetLink() const {return sLink;}
131 : };
132 :
133 : class SwTOXBaseContent : public SwContent
134 : {
135 : const SwTOXBase* pBase;
136 : public:
137 0 : SwTOXBaseContent(const SwContentType* pCnt, const OUString& rName, long nYPos, const SwTOXBase& rBase)
138 0 : : SwContent( pCnt, rName, nYPos ), pBase(&rBase)
139 0 : {}
140 : virtual ~SwTOXBaseContent();
141 :
142 0 : const SwTOXBase* GetTOXBase() const {return pBase;}
143 : };
144 : /*
145 : class ContentType contains information to one type of content.
146 : MemberArray is only populated if the content is requested by
147 : GetMember. It is reloaded after Invalidate() only if the content
148 : should be read again.
149 : */
150 :
151 : class SwContentType : public SwTypeNumber
152 : {
153 : SwWrtShell* pWrtShell;
154 : SwContentArr* pMember; // array for content
155 : OUString sContentTypeName; // name of content type
156 : OUString sSingleContentTypeName; // name of content type, singular
157 : OUString sTypeToken; // attachment for URL
158 : size_t nMemberCount; // content count
159 : sal_uInt16 nContentType; // content type's Id
160 : sal_uInt8 nOutlineLevel;
161 : bool bDataValid : 1;
162 : bool bEdit: 1; // can this type be edited?
163 : bool bDelete: 1; // can this type be deleted?
164 : protected:
165 : static OUString RemoveNewline(const OUString&);
166 : public:
167 : SwContentType(SwWrtShell* pParent, sal_uInt16 nType, sal_uInt8 nLevel );
168 : virtual ~SwContentType();
169 :
170 : void Init(bool* pbInvalidateWindow = 0);
171 : void FillMemberList(bool* pbLevelChanged = NULL);
172 864 : size_t GetMemberCount() const
173 864 : {return nMemberCount;};
174 391 : sal_uInt16 GetType() const {return nContentType;}
175 : const SwContent* GetMember(size_t nIndex);
176 96 : const OUString& GetName() {return sContentTypeName;}
177 0 : const OUString& GetSingleName() const {return sSingleContentTypeName;}
178 0 : const OUString& GetTypeToken() const{return sTypeToken;}
179 :
180 0 : void SetOutlineLevel(sal_uInt8 nNew)
181 : {
182 0 : nOutlineLevel = nNew;
183 0 : Invalidate();
184 0 : }
185 :
186 : void Invalidate(); // only nMemberCount is read again
187 :
188 0 : bool IsEditable() const {return bEdit;}
189 0 : bool IsDeletable() const {return bDelete;}
190 : };
191 :
192 : #endif
193 :
194 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|