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 SvxAutoKernItem
;
43 class SvxWordLineModeItem
;
45 class SvxLanguageItem
;
46 class SvxEmphasisMarkItem
;
47 class SvxCharReliefItem
;
53 #define CH_FEATURE_OLD (sal_uInt8) 0xFF
54 #define CH_FEATURE u'\x0001'
56 // DEF_METRIC: For my pool, the DefMetric should always appear when
57 // GetMetric (nWhich)!
58 // => To determine the DefMetric simply use GetMetric(0)
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
67 const SfxPoolItem
* pItem
;
75 EditCharAttrib( const SfxPoolItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
76 virtual ~EditCharAttrib();
78 EditCharAttrib(const EditCharAttrib
&) = delete;
79 EditCharAttrib
& operator=(const EditCharAttrib
&) = delete;
81 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
83 sal_uInt16
Which() const { return pItem
->Which(); }
84 const SfxPoolItem
* GetItem() const { return pItem
; }
86 sal_Int32
& GetStart() { return nStart
; }
87 sal_Int32
& GetEnd() { return nEnd
; }
89 sal_Int32
GetStart() const { return nStart
; }
90 sal_Int32
GetEnd() const { return nEnd
; }
92 inline sal_Int32
GetLen() const;
94 inline void MoveForward( sal_Int32 nDiff
);
95 inline void MoveBackward( sal_Int32 nDiff
);
97 inline void Expand( sal_Int32 nDiff
);
98 inline void Collaps( sal_Int32 nDiff
);
100 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
);
102 bool IsIn( sal_Int32 nIndex
) const
103 { return ( ( nStart
<= nIndex
) && ( nEnd
>= nIndex
) ); }
104 bool IsInside( sal_Int32 nIndex
) const
105 { return ( ( nStart
< nIndex
) && ( nEnd
> nIndex
) ); }
107 { return nStart
== nEnd
; }
109 bool IsFeature() const { return bFeature
; }
110 void SetFeature( bool b
) { bFeature
= b
; }
112 bool IsEdge() const { return bEdge
; }
113 void SetEdge( bool b
) { bEdge
= b
; }
116 inline sal_Int32
EditCharAttrib::GetLen() const
118 DBG_ASSERT( nEnd
>= nStart
, "EditCharAttrib: nEnd < nStart!" );
122 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff
)
124 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: MoveForward?!" );
125 nStart
= nStart
+ nDiff
;
129 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff
)
131 DBG_ASSERT( (nStart
- nDiff
) >= 0, "EditCharAttrib: MoveBackward?!" );
132 nStart
= nStart
- nDiff
;
136 inline void EditCharAttrib::Expand( sal_Int32 nDiff
)
138 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: Expand?!" );
139 DBG_ASSERT( !bFeature
, "Please do not expand any features!" );
143 inline void EditCharAttrib::Collaps( sal_Int32 nDiff
)
145 DBG_ASSERT( nEnd
- nDiff
>= nStart
, "EditCharAttrib: Collaps?!" );
146 DBG_ASSERT( !bFeature
, "Please do not shrink any Features!" );
152 class EditCharAttribFont final
: public EditCharAttrib
155 EditCharAttribFont( const SvxFontItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
157 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
162 class EditCharAttribWeight final
: public EditCharAttrib
165 EditCharAttribWeight( const SvxWeightItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
167 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
171 class EditCharAttribItalic final
: public EditCharAttrib
174 EditCharAttribItalic( const SvxPostureItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
176 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
181 class EditCharAttribShadow final
: public EditCharAttrib
184 EditCharAttribShadow( const SvxShadowedItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
186 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
191 class EditCharAttribEscapement final
: public EditCharAttrib
194 EditCharAttribEscapement( const SvxEscapementItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
196 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
201 class EditCharAttribOutline final
: public EditCharAttrib
204 EditCharAttribOutline( const SvxContourItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
206 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
211 class EditCharAttribStrikeout final
: public EditCharAttrib
214 EditCharAttribStrikeout( const SvxCrossedOutItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
216 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
221 class EditCharAttribCaseMap final
: public EditCharAttrib
224 EditCharAttribCaseMap( const SvxCaseMapItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
226 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
231 class EditCharAttribUnderline final
: public EditCharAttrib
234 EditCharAttribUnderline( const SvxUnderlineItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
236 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
241 class EditCharAttribOverline final
: public EditCharAttrib
244 EditCharAttribOverline( const SvxOverlineItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
246 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
251 class EditCharAttribEmphasisMark final
: public EditCharAttrib
254 EditCharAttribEmphasisMark( const SvxEmphasisMarkItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
256 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
261 class EditCharAttribRelief final
: public EditCharAttrib
264 EditCharAttribRelief( const SvxCharReliefItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
266 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
271 class EditCharAttribFontHeight final
: public EditCharAttrib
274 EditCharAttribFontHeight( const SvxFontHeightItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
276 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
281 class EditCharAttribFontWidth final
: public EditCharAttrib
284 EditCharAttribFontWidth( const SvxCharScaleWidthItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
286 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
291 class EditCharAttribColor final
: public EditCharAttrib
294 EditCharAttribColor( const SvxColorItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
296 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
300 class EditCharAttribBackgroundColor final
: public EditCharAttrib
303 EditCharAttribBackgroundColor(const SvxColorItem
& rAttr
,
306 virtual void SetFont(SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
311 class EditCharAttribLanguage final
: public EditCharAttrib
314 EditCharAttribLanguage( const SvxLanguageItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
316 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
321 class EditCharAttribTab final
: public EditCharAttrib
324 EditCharAttribTab( const SfxVoidItem
& rAttr
, sal_Int32 nPos
);
326 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
331 class EditCharAttribLineBreak final
: public EditCharAttrib
334 EditCharAttribLineBreak( const SfxVoidItem
& rAttr
, sal_Int32 nPos
);
336 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
341 class EditCharAttribField final
: public EditCharAttrib
343 OUString aFieldValue
;
344 std::optional
<Color
> mxTxtColor
;
345 std::optional
<Color
> mxFldColor
;
347 EditCharAttribField
& operator = ( const EditCharAttribField
& rAttr
) = delete;
350 EditCharAttribField( const SvxFieldItem
& rAttr
, sal_Int32 nPos
);
351 EditCharAttribField( const EditCharAttribField
& rAttr
);
352 virtual ~EditCharAttribField() override
;
354 bool operator == ( const EditCharAttribField
& rAttr
) const;
355 bool operator != ( const EditCharAttribField
& rAttr
) const
356 { return !(operator == ( rAttr
) ); }
358 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
359 std::optional
<Color
>& GetTextColor() { return mxTxtColor
; }
360 std::optional
<Color
>& GetFieldColor() { return mxFldColor
; }
362 const OUString
& GetFieldValue() const { return aFieldValue
;}
363 void SetFieldValue(const OUString
& rVal
);
370 class EditCharAttribPairKerning final
: public EditCharAttrib
373 EditCharAttribPairKerning( const SvxAutoKernItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
375 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
380 class EditCharAttribKerning final
: public EditCharAttrib
383 EditCharAttribKerning( const SvxKerningItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
385 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
390 class EditCharAttribWordLineMode final
: public EditCharAttrib
393 EditCharAttribWordLineMode( const SvxWordLineModeItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
395 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
399 class EditCharAttribGrabBag final
: public EditCharAttrib
402 EditCharAttribGrabBag( const SfxGrabBagItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
406 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */