nss: upgrade to release 3.73
[LibreOffice.git] / editeng / inc / editattr.hxx
blobf0a6ec58da764ac869fa8daa6a613f6e41fb2b0b
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 SvxBackgroundColorItem;
42 class SvxAutoKernItem;
43 class SvxKerningItem;
44 class SvxWordLineModeItem;
45 class SvxFieldItem;
46 class SvxLanguageItem;
47 class SvxEmphasisMarkItem;
48 class SvxCharReliefItem;
49 class SfxVoidItem;
50 class OutputDevice;
51 class SvxCaseMapItem;
52 class SfxGrabBagItem;
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)
60 #define DEF_METRIC 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
66 class EditCharAttrib
68 const SfxPoolItem* pItem;
70 sal_Int32 nStart;
71 sal_Int32 nEnd;
72 bool bFeature :1;
73 bool bEdge :1;
75 public:
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 ) ); }
107 bool IsEmpty() const
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!" );
120 return nEnd-nStart;
123 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff )
125 DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" );
126 nStart = nStart + nDiff;
127 nEnd = nEnd + nDiff;
130 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff )
132 DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
133 nStart = nStart - nDiff;
134 nEnd = nEnd - 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!" );
141 nEnd = nEnd + nDiff;
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!" );
148 nEnd = nEnd - nDiff;
153 class EditCharAttribFont final : public EditCharAttrib
155 public:
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
165 public:
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
174 public:
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
184 public:
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
194 public:
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
204 public:
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
214 public:
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
224 public:
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
234 public:
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
244 public:
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
254 public:
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
264 public:
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
274 public:
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
284 public:
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
294 public:
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
303 public:
304 EditCharAttribBackgroundColor(const SvxBackgroundColorItem& rAttr,
305 sal_Int32 nStart,
306 sal_Int32 nEnd );
307 virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) override;
312 class EditCharAttribLanguage final : public EditCharAttrib
314 public:
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
324 public:
325 EditCharAttribTab( const SfxVoidItem& rAttr, sal_Int32 nPos );
327 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
332 class EditCharAttribLineBreak final : public EditCharAttrib
334 public:
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;
350 public:
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);
366 void Reset();
371 class EditCharAttribPairKerning final : public EditCharAttrib
373 public:
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
383 public:
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
393 public:
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
402 public:
403 EditCharAttribGrabBag( const SfxGrabBagItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
407 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */