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>
27 #include <tools/fontenum.hxx>
28 #include <svl/itemset.hxx>
34 class SvxShadowedItem
;
35 class SvxEscapementItem
;
37 class SvxCrossedOutItem
;
38 class SvxUnderlineItem
;
39 class SvxOverlineItem
;
40 class SvxFontHeightItem
;
41 class SvxCharScaleWidthItem
;
43 class SvxAutoKernItem
;
45 class SvxWordLineModeItem
;
47 class SvxLanguageItem
;
48 class SvxEmphasisMarkItem
;
49 class SvxCharReliefItem
;
55 #define CH_FEATURE u'\x0001'
56 #define CH_SOFTHYPHEN u'\x00AD'
58 // DEF_METRIC: For my pool, the DefMetric should always appear when
59 // GetMetric (nWhich)!
60 // => 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 SfxPoolItemHolder maItemHolder
;
75 EditCharAttrib(SfxItemPool
&, const SfxPoolItem
&, 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 const SfxPoolItemHolder
& GetHolder() const { return maItemHolder
; }
84 const SfxPoolItem
* GetItem() const { return GetHolder().getItem(); }
85 sal_uInt16
Which() const { if(GetItem()) return GetItem()->Which(); return 0; }
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 IsInLeftClosedRightOpen( sal_Int32 nIndex
) const
106 { return ( ( nStart
<= nIndex
) && ( nEnd
> nIndex
) ); }
107 bool IsInside( sal_Int32 nIndex
) const
108 { return ( ( nStart
< nIndex
) && ( nEnd
> nIndex
) ); }
110 { return nStart
== nEnd
; }
112 bool IsFeature() const { return bFeature
; }
113 void SetFeature( bool b
) { bFeature
= b
; }
115 bool IsEdge() const { return bEdge
; }
116 void SetEdge( bool b
) { bEdge
= b
; }
119 inline sal_Int32
EditCharAttrib::GetLen() const
121 DBG_ASSERT( nEnd
>= nStart
, "EditCharAttrib: nEnd < nStart!" );
125 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff
)
127 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: MoveForward?!" );
128 nStart
= nStart
+ nDiff
;
132 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff
)
134 DBG_ASSERT( (nStart
- nDiff
) >= 0, "EditCharAttrib: MoveBackward?!" );
135 nStart
= nStart
- nDiff
;
139 inline void EditCharAttrib::Expand( sal_Int32 nDiff
)
141 DBG_ASSERT( SAL_MAX_INT32
- nDiff
> nEnd
, "EditCharAttrib: Expand?!" );
142 DBG_ASSERT( !bFeature
, "Please do not expand any features!" );
146 inline void EditCharAttrib::Collaps( sal_Int32 nDiff
)
148 DBG_ASSERT( nEnd
- nDiff
>= nStart
, "EditCharAttrib: Collaps?!" );
149 DBG_ASSERT( !bFeature
, "Please do not shrink any Features!" );
155 class EditCharAttribFont final
: public EditCharAttrib
158 EditCharAttribFont(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
160 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
165 class EditCharAttribWeight final
: public EditCharAttrib
168 EditCharAttribWeight(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
170 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
174 class EditCharAttribItalic final
: public EditCharAttrib
177 EditCharAttribItalic(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
179 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
184 class EditCharAttribShadow final
: public EditCharAttrib
187 EditCharAttribShadow(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
189 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
194 class EditCharAttribEscapement final
: public EditCharAttrib
197 EditCharAttribEscapement(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
199 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
204 class EditCharAttribOutline final
: public EditCharAttrib
207 EditCharAttribOutline(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
209 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
214 class EditCharAttribStrikeout final
: public EditCharAttrib
217 EditCharAttribStrikeout(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
219 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
224 class EditCharAttribCaseMap final
: public EditCharAttrib
227 EditCharAttribCaseMap(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
229 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
234 class EditCharAttribUnderline final
: public EditCharAttrib
237 EditCharAttribUnderline(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
239 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
244 class EditCharAttribOverline final
: public EditCharAttrib
247 EditCharAttribOverline(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
249 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
254 class EditCharAttribEmphasisMark final
: public EditCharAttrib
257 EditCharAttribEmphasisMark(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
259 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
264 class EditCharAttribRelief final
: public EditCharAttrib
267 EditCharAttribRelief(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
269 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
274 class EditCharAttribFontHeight final
: public EditCharAttrib
277 EditCharAttribFontHeight(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
279 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
284 class EditCharAttribFontWidth final
: public EditCharAttrib
287 EditCharAttribFontWidth(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
289 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
294 class EditCharAttribColor final
: public EditCharAttrib
297 EditCharAttribColor(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
299 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
303 class EditCharAttribBackgroundColor final
: public EditCharAttrib
306 EditCharAttribBackgroundColor(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
307 virtual void SetFont(SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
312 class EditCharAttribLanguage final
: public EditCharAttrib
315 EditCharAttribLanguage(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
317 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
322 class EditCharAttribTab final
: public EditCharAttrib
325 EditCharAttribTab(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nPos
);
327 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
332 class EditCharAttribLineBreak final
: public EditCharAttrib
335 EditCharAttribLineBreak(SfxItemPool
&, const SfxPoolItem
&, 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
;
347 std::optional
<FontLineStyle
> mxFldLineStyle
;
349 EditCharAttribField
& operator = ( const EditCharAttribField
& rAttr
) = delete;
352 EditCharAttribField(SfxItemPool
&, const SfxPoolItem
&, 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
; }
363 std::optional
<FontLineStyle
>& GetFldLineStyle() { return mxFldLineStyle
; }
365 const OUString
& GetFieldValue() const { return aFieldValue
;}
366 void SetFieldValue(const OUString
& rVal
);
373 class EditCharAttribPairKerning final
: public EditCharAttrib
376 EditCharAttribPairKerning(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
378 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
383 class EditCharAttribKerning final
: public EditCharAttrib
386 EditCharAttribKerning(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
388 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
393 class EditCharAttribWordLineMode final
: public EditCharAttrib
396 EditCharAttribWordLineMode(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
398 virtual void SetFont( SvxFont
& rFont
, OutputDevice
* pOutDev
) override
;
402 class EditCharAttribGrabBag final
: public EditCharAttrib
405 EditCharAttribGrabBag(SfxItemPool
&, const SfxPoolItem
&, sal_Int32 nStart
, sal_Int32 nEnd
);
409 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */