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 :
20 : #ifndef INCLUDED_EDITENG_SOURCE_EDITENG_EDITATTR_HXX
21 : #define INCLUDED_EDITENG_SOURCE_EDITENG_EDITATTR_HXX
22 :
23 : #include <editeng/eeitem.hxx>
24 : #include <svl/poolitem.hxx>
25 :
26 : #include <boost/noncopyable.hpp>
27 :
28 : class SvxFont;
29 : class SvxFontItem;
30 : class SvxWeightItem;
31 : class SvxPostureItem;
32 : class SvxShadowedItem;
33 : class SvxEscapementItem;
34 : class SvxContourItem;
35 : class SvxCrossedOutItem;
36 : class SvxUnderlineItem;
37 : class SvxOverlineItem;
38 : class SvxFontHeightItem;
39 : class SvxCharScaleWidthItem;
40 : class SvxColorItem;
41 : class SvxBackgroundColorItem;
42 : class SvxAutoKernItem;
43 : class SvxKerningItem;
44 : class SvxWordLineModeItem;
45 : class SvxFieldItem;
46 : class SvxLanguageItem;
47 : class SvxEmphasisMarkItem;
48 : class SvxCharReliefItem;
49 : class SfxVoidItem;
50 : class OutputDevice;
51 : class SvxCaseMapItem;
52 : class SfxGrabBagItem;
53 :
54 : #define CH_FEATURE_OLD (sal_uInt8) 0xFF
55 : #define CH_FEATURE (sal_Unicode) 0x01
56 :
57 : // DEF_METRIC: For my pool, the DefMetric should always appear when
58 : // GetMetric (nWhich)!
59 : // => To determine the DefMetric simply use GetMetric(0)
60 : #define DEF_METRIC 0
61 :
62 :
63 : // class EditCharAttrib
64 :
65 : // bFeature: Attribute must not expand/shrink, length is always 1
66 : // bEdge: Attribute will not expand, if you want to expand just on the edge
67 : class EditCharAttrib : private boost::noncopyable
68 : {
69 : protected:
70 : const SfxPoolItem* pItem;
71 :
72 : sal_uInt16 nStart;
73 : sal_uInt16 nEnd;
74 : bool bFeature :1;
75 : bool bEdge :1;
76 :
77 : public:
78 : EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
79 : virtual ~EditCharAttrib();
80 :
81 4905913 : sal_uInt16 Which() const { return pItem->Which(); }
82 1041895 : const SfxPoolItem* GetItem() const { return pItem; }
83 :
84 5176661 : sal_uInt16& GetStart() { return nStart; }
85 4111079 : sal_uInt16& GetEnd() { return nEnd; }
86 :
87 3483890 : sal_uInt16 GetStart() const { return nStart; }
88 330488 : sal_uInt16 GetEnd() const { return nEnd; }
89 :
90 : inline sal_uInt16 GetLen() const;
91 :
92 : inline void MoveForward( sal_uInt16 nDiff );
93 : inline void MoveBackward( sal_uInt16 nDiff );
94 :
95 : inline void Expand( sal_uInt16 nDiff );
96 : inline void Collaps( sal_uInt16 nDiff );
97 :
98 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
99 :
100 13513 : bool IsIn( sal_uInt16 nIndex ) const
101 13513 : { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); }
102 7328 : bool IsInside( sal_uInt16 nIndex ) const
103 7328 : { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); }
104 335826 : bool IsEmpty() const
105 335826 : { return nStart == nEnd; }
106 :
107 1741777 : bool IsFeature() const { return bFeature; }
108 21737 : void SetFeature( bool b) { bFeature = b; }
109 :
110 35310 : bool IsEdge() const { return bEdge; }
111 0 : void SetEdge( bool b ) { bEdge = b; }
112 : };
113 :
114 51139 : inline sal_uInt16 EditCharAttrib::GetLen() const
115 : {
116 : DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" );
117 51139 : return nEnd-nStart;
118 : }
119 :
120 1842 : inline void EditCharAttrib::MoveForward( sal_uInt16 nDiff )
121 : {
122 : DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" );
123 1842 : nStart = nStart + nDiff;
124 1842 : nEnd = nEnd + nDiff;
125 1842 : }
126 :
127 207 : inline void EditCharAttrib::MoveBackward( sal_uInt16 nDiff )
128 : {
129 : DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
130 207 : nStart = nStart - nDiff;
131 207 : nEnd = nEnd - nDiff;
132 207 : }
133 :
134 24271 : inline void EditCharAttrib::Expand( sal_uInt16 nDiff )
135 : {
136 : DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: Expand?!" );
137 : DBG_ASSERT( !bFeature, "Please do not expand any features!" );
138 24271 : nEnd = nEnd + nDiff;
139 24271 : }
140 :
141 286 : inline void EditCharAttrib::Collaps( sal_uInt16 nDiff )
142 : {
143 : DBG_ASSERT( nEnd - nDiff >= nStart, "EditCharAttrib: Collaps?!" );
144 : DBG_ASSERT( !bFeature, "Please do not shrink any Features!" );
145 286 : nEnd = nEnd - nDiff;
146 286 : }
147 :
148 :
149 : // class EditCharAttribFont
150 :
151 68430 : class EditCharAttribFont: public EditCharAttrib
152 : {
153 : public:
154 : EditCharAttribFont( const SvxFontItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
155 :
156 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
157 : };
158 :
159 :
160 : // class EditCharAttribWeight
161 :
162 60482 : class EditCharAttribWeight : public EditCharAttrib
163 : {
164 : public:
165 : EditCharAttribWeight( const SvxWeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
166 :
167 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
168 : };
169 :
170 : // class EditCharAttribItalic
171 :
172 33314 : class EditCharAttribItalic : public EditCharAttrib
173 : {
174 : public:
175 : EditCharAttribItalic( const SvxPostureItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
176 :
177 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
178 : };
179 :
180 :
181 : // class EditCharAttribShadow
182 :
183 5634 : class EditCharAttribShadow : public EditCharAttrib
184 : {
185 : public:
186 : EditCharAttribShadow( const SvxShadowedItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
187 :
188 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
189 : };
190 :
191 :
192 : // class EditCharAttribEscapement
193 :
194 12418 : class EditCharAttribEscapement : public EditCharAttrib
195 : {
196 : public:
197 : EditCharAttribEscapement( const SvxEscapementItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
198 :
199 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
200 : };
201 :
202 :
203 : // class EditCharAttribOutline
204 :
205 5544 : class EditCharAttribOutline : public EditCharAttrib
206 : {
207 : public:
208 : EditCharAttribOutline( const SvxContourItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
209 :
210 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
211 : };
212 :
213 :
214 : // class EditCharAttribStrikeout
215 :
216 12206 : class EditCharAttribStrikeout : public EditCharAttrib
217 : {
218 : public:
219 : EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
220 :
221 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
222 : };
223 :
224 :
225 : // class EditCharAttribCaseMap
226 :
227 10242 : class EditCharAttribCaseMap : public EditCharAttrib
228 : {
229 : public:
230 : EditCharAttribCaseMap( const SvxCaseMapItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
231 :
232 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
233 : };
234 :
235 :
236 : // class EditCharAttribUnderline
237 :
238 14544 : class EditCharAttribUnderline : public EditCharAttrib
239 : {
240 : public:
241 : EditCharAttribUnderline( const SvxUnderlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
242 :
243 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
244 : };
245 :
246 :
247 : // class EditCharAttribOverline
248 :
249 3244 : class EditCharAttribOverline : public EditCharAttrib
250 : {
251 : public:
252 : EditCharAttribOverline( const SvxOverlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
253 :
254 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
255 : };
256 :
257 :
258 : // class EditCharAttribEmphasisMark
259 :
260 4950 : class EditCharAttribEmphasisMark : public EditCharAttrib
261 : {
262 : public:
263 : EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
264 :
265 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
266 : };
267 :
268 :
269 : // class EditCharAttribRelief
270 :
271 4308 : class EditCharAttribRelief : public EditCharAttrib
272 : {
273 : public:
274 : EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
275 :
276 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
277 : };
278 :
279 :
280 : // class EditCharAttribFontHeight
281 :
282 96066 : class EditCharAttribFontHeight : public EditCharAttrib
283 : {
284 : public:
285 : EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
286 :
287 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
288 : };
289 :
290 :
291 : // class EditCharAttribFontWidth
292 :
293 4294 : class EditCharAttribFontWidth : public EditCharAttrib
294 : {
295 : public:
296 : EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
297 :
298 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
299 : };
300 :
301 :
302 : // class EditCharAttribColor
303 :
304 37256 : class EditCharAttribColor : public EditCharAttrib
305 : {
306 : public:
307 : EditCharAttribColor( const SvxColorItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
308 :
309 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
310 : };
311 :
312 : // class EditCharAttribBackgroundColor
313 :
314 3880 : class EditCharAttribBackgroundColor : public EditCharAttrib
315 : {
316 : public:
317 : EditCharAttribBackgroundColor(const SvxBackgroundColorItem& rAttr,
318 : sal_uInt16 nStart,
319 : sal_uInt16 nEnd );
320 : virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) SAL_OVERRIDE;
321 : };
322 :
323 :
324 :
325 : // class EditCharAttribLanguage
326 :
327 48750 : class EditCharAttribLanguage : public EditCharAttrib
328 : {
329 : public:
330 : EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
331 :
332 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
333 : };
334 :
335 :
336 : // class EditCharAttribTab
337 :
338 208 : class EditCharAttribTab : public EditCharAttrib
339 : {
340 : public:
341 : EditCharAttribTab( const SfxVoidItem& rAttr, sal_uInt16 nPos );
342 :
343 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
344 : };
345 :
346 :
347 : // class EditCharAttribLineBreak
348 :
349 230 : class EditCharAttribLineBreak : public EditCharAttrib
350 : {
351 : public:
352 : EditCharAttribLineBreak( const SfxVoidItem& rAttr, sal_uInt16 nPos );
353 :
354 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
355 : };
356 :
357 :
358 : // class EditCharAttribField
359 :
360 : class EditCharAttribField: public EditCharAttrib
361 : {
362 : OUString aFieldValue;
363 : Color* pTxtColor;
364 : Color* pFldColor;
365 :
366 : EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) SAL_DELETED_FUNCTION;
367 :
368 : public:
369 : EditCharAttribField( const SvxFieldItem& rAttr, sal_uInt16 nPos );
370 : EditCharAttribField( const EditCharAttribField& rAttr );
371 : virtual ~EditCharAttribField();
372 :
373 : bool operator == ( const EditCharAttribField& rAttr ) const;
374 11748 : bool operator != ( const EditCharAttribField& rAttr ) const
375 11748 : { return !(operator == ( rAttr ) ); }
376 :
377 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
378 11748 : Color*& GetTextColor() { return pTxtColor; }
379 11927 : Color*& GetFieldColor() { return pFldColor; }
380 :
381 34845 : const OUString& GetFieldValue() const { return aFieldValue;}
382 : void SetFieldValue(const OUString& rVal);
383 :
384 : void Reset();
385 : };
386 :
387 :
388 : // class EditCharAttribPairKerning
389 :
390 4146 : class EditCharAttribPairKerning : public EditCharAttrib
391 : {
392 : public:
393 : EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
394 :
395 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
396 : };
397 :
398 :
399 : // class EditCharAttribKerning
400 :
401 11012 : class EditCharAttribKerning : public EditCharAttrib
402 : {
403 : public:
404 : EditCharAttribKerning( const SvxKerningItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
405 :
406 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
407 : };
408 :
409 :
410 : // class EditCharAttribWordLineMode
411 :
412 3960 : class EditCharAttribWordLineMode: public EditCharAttrib
413 : {
414 : public:
415 : EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
416 :
417 : virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) SAL_OVERRIDE;
418 : };
419 :
420 : // class EditCharAttribGrabBag
421 :
422 3086 : class EditCharAttribGrabBag: public EditCharAttrib
423 : {
424 : public:
425 : EditCharAttribGrabBag( const SfxGrabBagItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
426 : };
427 :
428 :
429 : #endif // INCLUDED_EDITENG_SOURCE_EDITENG_EDITATTR_HXX
430 :
431 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|