update credits
[LibreOffice.git] / editeng / inc / editattr.hxx
blob502a5b08460556517015d13198352f55f43aa115
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 #pragma once
22 #include <editeng/eeitem.hxx>
23 #include <svl/poolitem.hxx>
24 #include <optional>
25 #include <tools/color.hxx>
26 #include <tools/debug.hxx>
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;
51 class SfxGrabBagItem;
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)
59 #define DEF_METRIC 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
65 class EditCharAttrib
67 const SfxPoolItem* pItem;
69 sal_Int32 nStart;
70 sal_Int32 nEnd;
71 bool bFeature :1;
72 bool bEdge :1;
74 public:
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 ) ); }
106 bool IsEmpty() const
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!" );
119 return nEnd-nStart;
122 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff )
124 DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" );
125 nStart = nStart + nDiff;
126 nEnd = nEnd + nDiff;
129 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff )
131 DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
132 nStart = nStart - nDiff;
133 nEnd = nEnd - 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!" );
140 nEnd = nEnd + nDiff;
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!" );
147 nEnd = nEnd - nDiff;
152 class EditCharAttribFont final : public EditCharAttrib
154 public:
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
164 public:
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
173 public:
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
183 public:
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
193 public:
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
203 public:
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
213 public:
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
223 public:
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
233 public:
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
243 public:
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
253 public:
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
263 public:
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
273 public:
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
283 public:
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
293 public:
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
302 public:
303 EditCharAttribBackgroundColor(const SvxColorItem& rAttr,
304 sal_Int32 nStart,
305 sal_Int32 nEnd );
306 virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) override;
311 class EditCharAttribLanguage final : public EditCharAttrib
313 public:
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
323 public:
324 EditCharAttribTab( const SfxVoidItem& rAttr, sal_Int32 nPos );
326 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
331 class EditCharAttribLineBreak final : public EditCharAttrib
333 public:
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;
349 public:
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);
365 void Reset();
370 class EditCharAttribPairKerning final : public EditCharAttrib
372 public:
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
382 public:
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
392 public:
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
401 public:
402 EditCharAttribGrabBag( const SfxGrabBagItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
406 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */