Bump version to 4.1-6
[LibreOffice.git] / editeng / source / editeng / editattr.hxx
blob0c9bd7b7a2092c278e4988c81fd6c758ca3daf43
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef _EDITATTR_HXX
21 #define _EDITATTR_HXX
23 #include <editeng/eeitem.hxx>
24 #include <svl/poolitem.hxx>
26 #include <boost/noncopyable.hpp>
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;
52 #define CH_FEATURE_OLD (sal_uInt8) 0xFF
53 #define CH_FEATURE (sal_Unicode) 0x01
55 // DEF_METRIC: For my pool, the DefMetric should always appear when
56 // GetMetric (nWhich)!
57 // => To determine the DefMetric simply use GetMetric(0)
58 #define DEF_METRIC 0
60 // -------------------------------------------------------------------------
61 // class EditCharAttrib
62 // -------------------------------------------------------------------------
63 // bFeature: Attribute must not expand/shrink, length is always 1
64 // bEdge: Attribute will not expand, if you want to expand just on the edge
65 class EditCharAttrib : private boost::noncopyable
67 protected:
68 const SfxPoolItem* pItem;
70 sal_uInt16 nStart;
71 sal_uInt16 nEnd;
72 sal_Bool bFeature :1;
73 sal_Bool bEdge :1;
75 public:
76 EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
77 virtual ~EditCharAttrib();
79 sal_uInt16 Which() const { return pItem->Which(); }
80 const SfxPoolItem* GetItem() const { return pItem; }
82 sal_uInt16& GetStart() { return nStart; }
83 sal_uInt16& GetEnd() { return nEnd; }
85 sal_uInt16 GetStart() const { return nStart; }
86 sal_uInt16 GetEnd() const { return nEnd; }
88 inline sal_uInt16 GetLen() const;
90 inline void MoveForward( sal_uInt16 nDiff );
91 inline void MoveBackward( sal_uInt16 nDiff );
93 inline void Expand( sal_uInt16 nDiff );
94 inline void Collaps( sal_uInt16 nDiff );
96 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
98 sal_Bool IsIn( sal_uInt16 nIndex ) const
99 { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); }
100 sal_Bool IsInside( sal_uInt16 nIndex ) const
101 { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); }
102 bool IsEmpty() const
103 { return nStart == nEnd; }
105 bool IsFeature() const { return bFeature; }
106 void SetFeature( sal_Bool b) { bFeature = b; }
108 sal_Bool IsEdge() const { return bEdge; }
109 void SetEdge( sal_Bool b ) { bEdge = b; }
112 inline sal_uInt16 EditCharAttrib::GetLen() const
114 DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" );
115 return nEnd-nStart;
118 inline void EditCharAttrib::MoveForward( sal_uInt16 nDiff )
120 DBG_ASSERT( ((long)nEnd + nDiff) <= 0xFFFF, "EditCharAttrib: MoveForward?!" );
121 nStart = nStart + nDiff;
122 nEnd = nEnd + nDiff;
125 inline void EditCharAttrib::MoveBackward( sal_uInt16 nDiff )
127 DBG_ASSERT( ((long)nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
128 nStart = nStart - nDiff;
129 nEnd = nEnd - nDiff;
132 inline void EditCharAttrib::Expand( sal_uInt16 nDiff )
134 DBG_ASSERT( ( ((long)nEnd + nDiff) <= (long)0xFFFF ), "EditCharAttrib: Expand?!" );
135 DBG_ASSERT( !bFeature, "Please do not expand any features!" );
136 nEnd = nEnd + nDiff;
139 inline void EditCharAttrib::Collaps( sal_uInt16 nDiff )
141 DBG_ASSERT( (long)nEnd - nDiff >= (long)nStart, "EditCharAttrib: Collaps?!" );
142 DBG_ASSERT( !bFeature, "Please do not shrink any Features!" );
143 nEnd = nEnd - nDiff;
146 // -------------------------------------------------------------------------
147 // class EditCharAttribFont
148 // -------------------------------------------------------------------------
149 class EditCharAttribFont: public EditCharAttrib
151 public:
152 EditCharAttribFont( const SvxFontItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
154 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
157 // -------------------------------------------------------------------------
158 // class EditCharAttribWeight
159 // -------------------------------------------------------------------------
160 class EditCharAttribWeight : public EditCharAttrib
162 public:
163 EditCharAttribWeight( const SvxWeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
165 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
167 // -------------------------------------------------------------------------
168 // class EditCharAttribItalic
169 // -------------------------------------------------------------------------
170 class EditCharAttribItalic : public EditCharAttrib
172 public:
173 EditCharAttribItalic( const SvxPostureItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
175 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
178 // -------------------------------------------------------------------------
179 // class EditCharAttribShadow
180 // -------------------------------------------------------------------------
181 class EditCharAttribShadow : public EditCharAttrib
183 public:
184 EditCharAttribShadow( const SvxShadowedItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
186 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
189 // -------------------------------------------------------------------------
190 // class EditCharAttribEscapement
191 // -------------------------------------------------------------------------
192 class EditCharAttribEscapement : public EditCharAttrib
194 public:
195 EditCharAttribEscapement( const SvxEscapementItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
197 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
200 // -------------------------------------------------------------------------
201 // class EditCharAttribOutline
202 // -------------------------------------------------------------------------
203 class EditCharAttribOutline : public EditCharAttrib
205 public:
206 EditCharAttribOutline( const SvxContourItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
208 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
211 // -------------------------------------------------------------------------
212 // class EditCharAttribStrikeout
213 // -------------------------------------------------------------------------
214 class EditCharAttribStrikeout : public EditCharAttrib
216 public:
217 EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
219 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
222 // -------------------------------------------------------------------------
223 // class EditCharAttribCaseMap
224 // -------------------------------------------------------------------------
225 class EditCharAttribCaseMap : public EditCharAttrib
227 public:
228 EditCharAttribCaseMap( const SvxCaseMapItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
230 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
233 // -------------------------------------------------------------------------
234 // class EditCharAttribUnderline
235 // -------------------------------------------------------------------------
236 class EditCharAttribUnderline : public EditCharAttrib
238 public:
239 EditCharAttribUnderline( const SvxUnderlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
241 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
244 // -------------------------------------------------------------------------
245 // class EditCharAttribOverline
246 // -------------------------------------------------------------------------
247 class EditCharAttribOverline : public EditCharAttrib
249 public:
250 EditCharAttribOverline( const SvxOverlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
252 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
255 // -------------------------------------------------------------------------
256 // class EditCharAttribEmphasisMark
257 // -------------------------------------------------------------------------
258 class EditCharAttribEmphasisMark : public EditCharAttrib
260 public:
261 EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
263 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
266 // -------------------------------------------------------------------------
267 // class EditCharAttribRelief
268 // -------------------------------------------------------------------------
269 class EditCharAttribRelief : public EditCharAttrib
271 public:
272 EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
274 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
277 // -------------------------------------------------------------------------
278 // class EditCharAttribFontHeight
279 // -------------------------------------------------------------------------
280 class EditCharAttribFontHeight : public EditCharAttrib
282 public:
283 EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
285 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
288 // -------------------------------------------------------------------------
289 // class EditCharAttribFontWidth
290 // -------------------------------------------------------------------------
291 class EditCharAttribFontWidth : public EditCharAttrib
293 public:
294 EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
296 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
299 // -------------------------------------------------------------------------
300 // class EditCharAttribColor
301 // -------------------------------------------------------------------------
302 class EditCharAttribColor : public EditCharAttrib
304 public:
305 EditCharAttribColor( const SvxColorItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
307 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
310 // -------------------------------------------------------------------------
311 // class EditCharAttribLanguage
312 // -------------------------------------------------------------------------
313 class EditCharAttribLanguage : public EditCharAttrib
315 public:
316 EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
318 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
321 // -------------------------------------------------------------------------
322 // class EditCharAttribTab
323 // -------------------------------------------------------------------------
324 class EditCharAttribTab : public EditCharAttrib
326 public:
327 EditCharAttribTab( const SfxVoidItem& rAttr, sal_uInt16 nPos );
329 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
332 // -------------------------------------------------------------------------
333 // class EditCharAttribLineBreak
334 // -------------------------------------------------------------------------
335 class EditCharAttribLineBreak : public EditCharAttrib
337 public:
338 EditCharAttribLineBreak( const SfxVoidItem& rAttr, sal_uInt16 nPos );
340 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
343 // -------------------------------------------------------------------------
344 // class EditCharAttribField
345 // -------------------------------------------------------------------------
346 class EditCharAttribField: public EditCharAttrib
348 OUString aFieldValue;
349 Color* pTxtColor;
350 Color* pFldColor;
352 EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) const;
354 public:
355 EditCharAttribField( const SvxFieldItem& rAttr, sal_uInt16 nPos );
356 EditCharAttribField( const EditCharAttribField& rAttr );
357 ~EditCharAttribField();
359 bool operator == ( const EditCharAttribField& rAttr ) const;
360 bool operator != ( const EditCharAttribField& rAttr ) const
361 { return !(operator == ( rAttr ) ); }
363 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
364 Color*& GetTxtColor() { return pTxtColor; }
365 Color*& GetFldColor() { return pFldColor; }
367 const OUString& GetFieldValue() const;
368 void SetFieldValue(const OUString& rVal);
370 void Reset();
373 // -------------------------------------------------------------------------
374 // class EditCharAttribPairKerning
375 // -------------------------------------------------------------------------
376 class EditCharAttribPairKerning : public EditCharAttrib
378 public:
379 EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
381 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
384 // -------------------------------------------------------------------------
385 // class EditCharAttribKerning
386 // -------------------------------------------------------------------------
387 class EditCharAttribKerning : public EditCharAttrib
389 public:
390 EditCharAttribKerning( const SvxKerningItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
392 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
395 // -------------------------------------------------------------------------
396 // class EditCharAttribWordLineMode
397 // -------------------------------------------------------------------------
398 class EditCharAttribWordLineMode: public EditCharAttrib
400 public:
401 EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
403 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
407 #endif // _EDITATTR_HXX
409 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */