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 .
20 #ifndef INCLUDED_EDITENG_INC_EDITATTR_HXX
21 #define INCLUDED_EDITENG_INC_EDITATTR_HXX
23 #include <editeng/eeitem.hxx>
24 #include <svl/poolitem.hxx>
26 #include <tools/color.hxx>
27 #include <tools/debug.hxx>
33 class SvxShadowedItem
;
34 class SvxEscapementItem
;
36 class SvxCrossedOutItem
;
37 class SvxUnderlineItem
;
38 class SvxOverlineItem
;
39 class SvxFontHeightItem
;
40 class SvxCharScaleWidthItem
;
42 class SvxBackgroundColorItem
;
43 class SvxAutoKernItem
;
45 class SvxWordLineModeItem
;
47 class SvxLanguageItem
;
48 class SvxEmphasisMarkItem
;
49 class SvxCharReliefItem
;
55 #define CH_FEATURE_OLD (sal_uInt8) 0xFF
56 #define CH_FEATURE u'\x0001'
58 // DEF_METRIC: For my pool, the DefMetric should always appear when
59 // GetMetric (nWhich)!
60 // => To determine the DefMetric simply use GetMetric(0)
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
69 const SfxPoolItem
* pItem
;
77 EditCharAttrib( const SfxPoolItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
78 virtual ~EditCharAttrib();
80 EditCharAttrib(const EditCharAttrib
&) = delete;
81 EditCharAttrib
& operator=(const EditCharAttrib
&) = delete;
83 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
85 sal_uInt16
Which() const { return pItem
->Which(); }
86 const SfxPoolItem
* GetItem() const { return pItem
; }
88 sal_Int32
& GetStart() { return nStart
; }
89 sal_Int32
& GetEnd() { return nEnd
; }
91 sal_Int32
GetStart() const { return nStart
; }
92 sal_Int32
GetEnd() const { return nEnd
; }
94 inline sal_Int32
GetLen() const;
96 inline void MoveForward( sal_Int32 nDiff
);
97 inline void MoveBackward( sal_Int32 nDiff
);
99 inline void Expand( sal_Int32 nDiff
);
100 inline void Collaps( sal_Int32 nDiff
);
102 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
);
104 bool IsIn( sal_Int32 nIndex
) const
105 { return ( ( nStart
<= nIndex
) && ( nEnd
>= nIndex
) ); }
106 bool IsInside( sal_Int32 nIndex
) const
107 { return ( ( nStart
< nIndex
) && ( nEnd
> nIndex
) ); }
109 { return nStart
== nEnd
; }
111 bool IsFeature() const { return bFeature
; }
112 void SetFeature( bool b
) { bFeature
= b
; }
114 bool IsEdge() const { return bEdge
; }
115 void SetEdge( bool b
) { bEdge
= b
; }
118 inline sal_Int32
EditCharAttrib::GetLen() const
120 DBG_ASSERT( nEnd
>= nStart
, "EditCharAttrib: nEnd < nStart!" );
124 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff
)
126 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: MoveForward?!" );
127 nStart
= nStart
+ nDiff
;
131 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff
)
133 DBG_ASSERT( (nStart
- nDiff
) >= 0, "EditCharAttrib: MoveBackward?!" );
134 nStart
= nStart
- nDiff
;
138 inline void EditCharAttrib::Expand( sal_Int32 nDiff
)
140 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: Expand?!" );
141 DBG_ASSERT( !bFeature
, "Please do not expand any features!" );
145 inline void EditCharAttrib::Collaps( sal_Int32 nDiff
)
147 DBG_ASSERT( nEnd
- nDiff
>= nStart
, "EditCharAttrib: Collaps?!" );
148 DBG_ASSERT( !bFeature
, "Please do not shrink any Features!" );
154 class EditCharAttribFont final
: public EditCharAttrib
157 EditCharAttribFont( const SvxFontItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
159 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
164 class EditCharAttribWeight final
: public EditCharAttrib
167 EditCharAttribWeight( const SvxWeightItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
169 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
173 class EditCharAttribItalic final
: public EditCharAttrib
176 EditCharAttribItalic( const SvxPostureItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
178 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
183 class EditCharAttribShadow final
: public EditCharAttrib
186 EditCharAttribShadow( const SvxShadowedItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
188 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
193 class EditCharAttribEscapement final
: public EditCharAttrib
196 EditCharAttribEscapement( const SvxEscapementItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
198 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
203 class EditCharAttribOutline final
: public EditCharAttrib
206 EditCharAttribOutline( const SvxContourItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
208 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
213 class EditCharAttribStrikeout final
: public EditCharAttrib
216 EditCharAttribStrikeout( const SvxCrossedOutItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
218 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
223 class EditCharAttribCaseMap final
: public EditCharAttrib
226 EditCharAttribCaseMap( const SvxCaseMapItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
228 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
233 class EditCharAttribUnderline final
: public EditCharAttrib
236 EditCharAttribUnderline( const SvxUnderlineItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
238 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
243 class EditCharAttribOverline final
: public EditCharAttrib
246 EditCharAttribOverline( const SvxOverlineItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
248 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
253 class EditCharAttribEmphasisMark final
: public EditCharAttrib
256 EditCharAttribEmphasisMark( const SvxEmphasisMarkItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
258 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
263 class EditCharAttribRelief final
: public EditCharAttrib
266 EditCharAttribRelief( const SvxCharReliefItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
268 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
273 class EditCharAttribFontHeight final
: public EditCharAttrib
276 EditCharAttribFontHeight( const SvxFontHeightItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
278 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
283 class EditCharAttribFontWidth final
: public EditCharAttrib
286 EditCharAttribFontWidth( const SvxCharScaleWidthItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
288 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
293 class EditCharAttribColor final
: public EditCharAttrib
296 EditCharAttribColor( const SvxColorItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
298 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
302 class EditCharAttribBackgroundColor final
: public EditCharAttrib
305 EditCharAttribBackgroundColor(const SvxBackgroundColorItem
& rAttr
,
308 virtual void SetFont(SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
313 class EditCharAttribLanguage final
: public EditCharAttrib
316 EditCharAttribLanguage( const SvxLanguageItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
318 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
323 class EditCharAttribTab final
: public EditCharAttrib
326 EditCharAttribTab( const SfxVoidItem
& rAttr
, sal_Int32 nPos
);
328 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
333 class EditCharAttribLineBreak final
: public EditCharAttrib
336 EditCharAttribLineBreak( const SfxVoidItem
& rAttr
, sal_Int32 nPos
);
338 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
343 class EditCharAttribField final
: public EditCharAttrib
345 OUString aFieldValue
;
346 std::optional
<Color
> mxTxtColor
;
347 std::optional
<Color
> mxFldColor
;
349 EditCharAttribField
& operator = ( const EditCharAttribField
& rAttr
) = delete;
352 EditCharAttribField( const SvxFieldItem
& rAttr
, sal_Int32 nPos
);
353 EditCharAttribField( const EditCharAttribField
& rAttr
);
354 virtual ~EditCharAttribField() override
;
356 bool operator == ( const EditCharAttribField
& rAttr
) const;
357 bool operator != ( const EditCharAttribField
& rAttr
) const
358 { return !(operator == ( rAttr
) ); }
360 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
361 std::optional
<Color
>& GetTextColor() { return mxTxtColor
; }
362 std::optional
<Color
>& GetFieldColor() { return mxFldColor
; }
364 const OUString
& GetFieldValue() const { return aFieldValue
;}
365 void SetFieldValue(const OUString
& rVal
);
372 class EditCharAttribPairKerning final
: public EditCharAttrib
375 EditCharAttribPairKerning( const SvxAutoKernItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
377 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
382 class EditCharAttribKerning final
: public EditCharAttrib
385 EditCharAttribKerning( const SvxKerningItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
387 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
392 class EditCharAttribWordLineMode final
: public EditCharAttrib
395 EditCharAttribWordLineMode( const SvxWordLineModeItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
397 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
401 class EditCharAttribGrabBag final
: public EditCharAttrib
404 EditCharAttribGrabBag( const SfxGrabBagItem
& rAttr
, sal_Int32 nStart
, sal_Int32 nEnd
);
410 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */