Send various state changes to LOK
[LibreOffice.git] / editeng / inc / editattr.hxx
blob85df8454dccc62db221645084ccf67b098599d2e
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 #ifndef INCLUDED_EDITENG_INC_EDITATTR_HXX
21 #define INCLUDED_EDITENG_INC_EDITATTR_HXX
23 #include <editeng/eeitem.hxx>
24 #include <svl/poolitem.hxx>
25 #include <optional>
26 #include <tools/color.hxx>
27 #include <tools/debug.hxx>
29 class SvxFont;
30 class SvxFontItem;
31 class SvxWeightItem;
32 class SvxPostureItem;
33 class SvxShadowedItem;
34 class SvxEscapementItem;
35 class SvxContourItem;
36 class SvxCrossedOutItem;
37 class SvxUnderlineItem;
38 class SvxOverlineItem;
39 class SvxFontHeightItem;
40 class SvxCharScaleWidthItem;
41 class SvxColorItem;
42 class SvxBackgroundColorItem;
43 class SvxAutoKernItem;
44 class SvxKerningItem;
45 class SvxWordLineModeItem;
46 class SvxFieldItem;
47 class SvxLanguageItem;
48 class SvxEmphasisMarkItem;
49 class SvxCharReliefItem;
50 class SfxVoidItem;
51 class OutputDevice;
52 class SvxCaseMapItem;
53 class SfxGrabBagItem;
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)
61 #define DEF_METRIC 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
67 class EditCharAttrib
69 const SfxPoolItem* pItem;
71 sal_Int32 nStart;
72 sal_Int32 nEnd;
73 bool bFeature :1;
74 bool bEdge :1;
76 public:
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 ) ); }
108 bool IsEmpty() const
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!" );
121 return nEnd-nStart;
124 inline void EditCharAttrib::MoveForward( sal_Int32 nDiff )
126 DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" );
127 nStart = nStart + nDiff;
128 nEnd = nEnd + nDiff;
131 inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff )
133 DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
134 nStart = nStart - nDiff;
135 nEnd = nEnd - 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!" );
142 nEnd = nEnd + nDiff;
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!" );
149 nEnd = nEnd - nDiff;
154 class EditCharAttribFont final : public EditCharAttrib
156 public:
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
166 public:
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
175 public:
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
185 public:
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
195 public:
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
205 public:
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
215 public:
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
225 public:
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
235 public:
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
245 public:
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
255 public:
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
265 public:
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
275 public:
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
285 public:
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
295 public:
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
304 public:
305 EditCharAttribBackgroundColor(const SvxBackgroundColorItem& rAttr,
306 sal_Int32 nStart,
307 sal_Int32 nEnd );
308 virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) override;
313 class EditCharAttribLanguage final : public EditCharAttrib
315 public:
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
325 public:
326 EditCharAttribTab( const SfxVoidItem& rAttr, sal_Int32 nPos );
328 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
333 class EditCharAttribLineBreak final : public EditCharAttrib
335 public:
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;
351 public:
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);
367 void Reset();
372 class EditCharAttribPairKerning final : public EditCharAttrib
374 public:
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
384 public:
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
394 public:
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
403 public:
404 EditCharAttribGrabBag( const SfxGrabBagItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
408 #endif
410 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */