1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <editeng/eeitem.hxx>
23 #include <svl/poolitem.hxx>
25 #include <tools/color.hxx>
26 #include <tools/debug.hxx>
32 class SvxShadowedItem
;
33 class SvxEscapementItem
;
35 class SvxCrossedOutItem
;
36 class SvxUnderlineItem
;
37 class SvxOverlineItem
;
38 class SvxFontHeightItem
;
39 class SvxCharScaleWidthItem
;
41 class SvxBackgroundColorItem
;
42 class SvxAutoKernItem
;
44 class SvxWordLineModeItem
;
46 class SvxLanguageItem
;
47 class SvxEmphasisMarkItem
;
48 class SvxCharReliefItem
;
54 #define CH_FEATURE_OLD (sal_uInt8) 0xFF
55 #define CH_FEATURE u'\x0001'
57 // DEF_METRIC: For my pool, the DefMetric should always appear when
58 // GetMetric (nWhich)!
59 // => To determine the DefMetric simply use GetMetric(0)
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
68 const SfxPoolItem
* pItem
;
76 EditCharAttrib( const SfxPoolItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
77 virtual ~EditCharAttrib();
79 EditCharAttrib(const EditCharAttrib
&) = delete;
80 EditCharAttrib
& operator=(const EditCharAttrib
&) = delete;
82 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
84 sal_uInt16
Which() const { return pItem
->Which(); }
85 const SfxPoolItem
* GetItem() const { return pItem
; }
87 sal_Int32
& GetStart() { return nStart
; }
88 sal_Int32
& GetEnd() { return nEnd
; }
90 sal_Int32
GetStart() const { return nStart
; }
91 sal_Int32
GetEnd() const { return nEnd
; }
93 inline sal_Int32
GetLen() const;
95 inline void MoveForward( sal_Int32 nDiff
);
96 inline void MoveBackward( sal_Int32 nDiff
);
98 inline void Expand( sal_Int32 nDiff
);
99 inline void Collaps( sal_Int32 nDiff
);
101 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
);
103 bool IsIn( sal_Int32 nIndex
) const
104 { return ( ( nStart
<= nIndex
) && ( nEnd
>= nIndex
) ); }
105 bool IsInside( sal_Int32 nIndex
) const
106 { return ( ( nStart
< nIndex
) && ( nEnd
> nIndex
) ); }
108 { return nStart
== nEnd
; }
110 bool IsFeature() const { return bFeature
; }
111 void SetFeature( bool b
) { bFeature
= b
; }
113 bool IsEdge() const { return bEdge
; }
114 void SetEdge( bool b
) { bEdge
= b
; }
117 inline sal_Int32
EditCharAttrib::GetLen() const
119 DBG_ASSERT( nEnd
>= nStart
, "EditCharAttrib: nEnd < nStart!" );
123 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff
)
125 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: MoveForward?!" );
126 nStart
= nStart
+ nDiff
;
130 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff
)
132 DBG_ASSERT( (nStart
- nDiff
) >= 0, "EditCharAttrib: MoveBackward?!" );
133 nStart
= nStart
- nDiff
;
137 inline void EditCharAttrib::Expand( sal_Int32 nDiff
)
139 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: Expand?!" );
140 DBG_ASSERT( !bFeature
, "Please do not expand any features!" );
144 inline void EditCharAttrib::Collaps( sal_Int32 nDiff
)
146 DBG_ASSERT( nEnd
- nDiff
>= nStart
, "EditCharAttrib: Collaps?!" );
147 DBG_ASSERT( !bFeature
, "Please do not shrink any Features!" );
153 class EditCharAttribFont final
: public EditCharAttrib
156 EditCharAttribFont( const SvxFontItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
158 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
163 class EditCharAttribWeight final
: public EditCharAttrib
166 EditCharAttribWeight( const SvxWeightItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
168 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
172 class EditCharAttribItalic final
: public EditCharAttrib
175 EditCharAttribItalic( const SvxPostureItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
177 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
182 class EditCharAttribShadow final
: public EditCharAttrib
185 EditCharAttribShadow( const SvxShadowedItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
187 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
192 class EditCharAttribEscapement final
: public EditCharAttrib
195 EditCharAttribEscapement( const SvxEscapementItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
197 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
202 class EditCharAttribOutline final
: public EditCharAttrib
205 EditCharAttribOutline( const SvxContourItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
207 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
212 class EditCharAttribStrikeout final
: public EditCharAttrib
215 EditCharAttribStrikeout( const SvxCrossedOutItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
217 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
222 class EditCharAttribCaseMap final
: public EditCharAttrib
225 EditCharAttribCaseMap( const SvxCaseMapItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
227 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
232 class EditCharAttribUnderline final
: public EditCharAttrib
235 EditCharAttribUnderline( const SvxUnderlineItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
237 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
242 class EditCharAttribOverline final
: public EditCharAttrib
245 EditCharAttribOverline( const SvxOverlineItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
247 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
252 class EditCharAttribEmphasisMark final
: public EditCharAttrib
255 EditCharAttribEmphasisMark( const SvxEmphasisMarkItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
257 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
262 class EditCharAttribRelief final
: public EditCharAttrib
265 EditCharAttribRelief( const SvxCharReliefItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
267 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
272 class EditCharAttribFontHeight final
: public EditCharAttrib
275 EditCharAttribFontHeight( const SvxFontHeightItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
277 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
282 class EditCharAttribFontWidth final
: public EditCharAttrib
285 EditCharAttribFontWidth( const SvxCharScaleWidthItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
287 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
292 class EditCharAttribColor final
: public EditCharAttrib
295 EditCharAttribColor( const SvxColorItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
297 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
301 class EditCharAttribBackgroundColor final
: public EditCharAttrib
304 EditCharAttribBackgroundColor(const SvxBackgroundColorItem
& rAttr
,
307 virtual void SetFont(SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
312 class EditCharAttribLanguage final
: public EditCharAttrib
315 EditCharAttribLanguage( const SvxLanguageItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
317 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
322 class EditCharAttribTab final
: public EditCharAttrib
325 EditCharAttribTab( const SfxVoidItem
& rAttr
, sal_Int32 nPos
);
327 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
332 class EditCharAttribLineBreak final
: public EditCharAttrib
335 EditCharAttribLineBreak( const SfxVoidItem
& rAttr
, sal_Int32 nPos
);
337 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
342 class EditCharAttribField final
: public EditCharAttrib
344 OUString aFieldValue
;
345 std::optional
<Color
> mxTxtColor
;
346 std::optional
<Color
> mxFldColor
;
348 EditCharAttribField
& operator = ( const EditCharAttribField
& rAttr
) = delete;
351 EditCharAttribField( const SvxFieldItem
& rAttr
, sal_Int32 nPos
);
352 EditCharAttribField( const EditCharAttribField
& rAttr
);
353 virtual ~EditCharAttribField() override
;
355 bool operator == ( const EditCharAttribField
& rAttr
) const;
356 bool operator != ( const EditCharAttribField
& rAttr
) const
357 { return !(operator == ( rAttr
) ); }
359 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
360 std::optional
<Color
>& GetTextColor() { return mxTxtColor
; }
361 std::optional
<Color
>& GetFieldColor() { return mxFldColor
; }
363 const OUString
& GetFieldValue() const { return aFieldValue
;}
364 void SetFieldValue(const OUString
& rVal
);
371 class EditCharAttribPairKerning final
: public EditCharAttrib
374 EditCharAttribPairKerning( const SvxAutoKernItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
376 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
381 class EditCharAttribKerning final
: public EditCharAttrib
384 EditCharAttribKerning( const SvxKerningItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
386 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
391 class EditCharAttribWordLineMode final
: public EditCharAttrib
394 EditCharAttribWordLineMode( const SvxWordLineModeItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
396 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
400 class EditCharAttribGrabBag final
: public EditCharAttrib
403 EditCharAttribGrabBag( const SfxGrabBagItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
407 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */