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