LibreOffice Module editeng (master) 1
editattr.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <editeng/eeitem.hxx>
23#include <svl/poolitem.hxx>
24#include <optional>
25#include <tools/color.hxx>
26#include <tools/debug.hxx>
27#include <tools/fontenum.hxx>
28
29class SvxFont;
30class SvxFontItem;
31class SvxWeightItem;
32class SvxPostureItem;
33class SvxShadowedItem;
35class SvxContourItem;
38class SvxOverlineItem;
41class SvxColorItem;
42class SvxAutoKernItem;
43class SvxKerningItem;
45class SvxFieldItem;
46class SvxLanguageItem;
49class SfxVoidItem;
50class OutputDevice;
51class SvxCaseMapItem;
52class SfxGrabBagItem;
53
54#define CH_FEATURE_OLD (sal_uInt8) 0xFF
55#define CH_FEATURE u'\x0001'
56
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
61
62
63
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
67{
69
70 sal_Int32 nStart;
71 sal_Int32 nEnd;
72 bool bFeature :1;
73 bool bEdge :1;
74
75public:
76 EditCharAttrib( const SfxPoolItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
77 virtual ~EditCharAttrib();
78
81
82 void dumpAsXml(xmlTextWriterPtr pWriter) const;
83
84 sal_uInt16 Which() const { return pItem->Which(); }
85 const SfxPoolItem* GetItem() const { return pItem; }
86
87 sal_Int32& GetStart() { return nStart; }
88 sal_Int32& GetEnd() { return nEnd; }
89
90 sal_Int32 GetStart() const { return nStart; }
91 sal_Int32 GetEnd() const { return nEnd; }
92
93 inline sal_Int32 GetLen() const;
94
95 inline void MoveForward( sal_Int32 nDiff );
96 inline void MoveBackward( sal_Int32 nDiff );
97
98 inline void Expand( sal_Int32 nDiff );
99 inline void Collaps( sal_Int32 nDiff );
100
101 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
102
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; }
109
110 bool IsFeature() const { return bFeature; }
111 void SetFeature( bool b) { bFeature = b; }
112
113 bool IsEdge() const { return bEdge; }
114 void SetEdge( bool b ) { bEdge = b; }
115};
116
117inline sal_Int32 EditCharAttrib::GetLen() const
118{
119 DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" );
120 return nEnd-nStart;
121}
122
123inline void EditCharAttrib::MoveForward( sal_Int32 nDiff )
124{
125 DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: MoveForward?!" );
126 nStart = nStart + nDiff;
127 nEnd = nEnd + nDiff;
128}
129
130inline void EditCharAttrib::MoveBackward( sal_Int32 nDiff )
131{
132 DBG_ASSERT( (nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
133 nStart = nStart - nDiff;
134 nEnd = nEnd - nDiff;
135}
136
137inline void EditCharAttrib::Expand( sal_Int32 nDiff )
138{
139 DBG_ASSERT( SAL_MAX_INT32 - nDiff > nEnd, "EditCharAttrib: Expand?!" );
140 DBG_ASSERT( !bFeature, "Please do not expand any features!" );
141 nEnd = nEnd + nDiff;
142}
143
144inline void EditCharAttrib::Collaps( sal_Int32 nDiff )
145{
146 DBG_ASSERT( nEnd - nDiff >= nStart, "EditCharAttrib: Collaps?!" );
147 DBG_ASSERT( !bFeature, "Please do not shrink any Features!" );
148 nEnd = nEnd - nDiff;
149}
150
151
152
154{
155public:
156 EditCharAttribFont( const SvxFontItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
157
158 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
159};
160
161
162
164{
165public:
166 EditCharAttribWeight( const SvxWeightItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
167
168 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
169};
170
171
173{
174public:
175 EditCharAttribItalic( const SvxPostureItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
176
177 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
178};
179
180
181
183{
184public:
185 EditCharAttribShadow( const SvxShadowedItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
186
187 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
188};
189
190
191
193{
194public:
195 EditCharAttribEscapement( const SvxEscapementItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
196
197 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
198};
199
200
201
203{
204public:
205 EditCharAttribOutline( const SvxContourItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
206
207 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
208};
209
210
211
213{
214public:
215 EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
216
217 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
218};
219
220
221
223{
224public:
225 EditCharAttribCaseMap( const SvxCaseMapItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
226
227 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
228};
229
230
231
233{
234public:
235 EditCharAttribUnderline( const SvxUnderlineItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
236
237 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
238};
239
240
241
243{
244public:
245 EditCharAttribOverline( const SvxOverlineItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
246
247 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
248};
249
250
251
253{
254public:
255 EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
256
257 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
258};
259
260
261
263{
264public:
265 EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
266
267 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
268};
269
270
271
273{
274public:
275 EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
276
277 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
278};
279
280
281
283{
284public:
285 EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
286
287 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
288};
289
290
291
293{
294public:
295 EditCharAttribColor( const SvxColorItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
296
297 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
298};
299
300
302{
303public:
305 sal_Int32 nStart,
306 sal_Int32 nEnd );
307 virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) override;
308};
309
310
311
313{
314public:
315 EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
316
317 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
318};
319
320
321
323{
324public:
325 EditCharAttribTab( const SfxVoidItem& rAttr, sal_Int32 nPos );
326
327 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
328};
329
330
331
333{
334public:
335 EditCharAttribLineBreak( const SfxVoidItem& rAttr, sal_Int32 nPos );
336
337 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
338};
339
340
341
343{
344 OUString aFieldValue;
345 std::optional<Color> mxTxtColor;
346 std::optional<Color> mxFldColor;
347 std::optional<FontLineStyle> mxFldLineStyle;
348
350
351public:
352 EditCharAttribField( const SvxFieldItem& rAttr, sal_Int32 nPos );
354 virtual ~EditCharAttribField() override;
355
356 bool operator == ( const EditCharAttribField& rAttr ) const;
357 bool operator != ( const EditCharAttribField& rAttr ) const
358 { return !(operator == ( rAttr ) ); }
359
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; }
364
365 const OUString& GetFieldValue() const { return aFieldValue;}
366 void SetFieldValue(const OUString& rVal);
367
368 void Reset();
369};
370
371
372
374{
375public:
376 EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
377
378 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
379};
380
381
382
384{
385public:
386 EditCharAttribKerning( const SvxKerningItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
387
388 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
389};
390
391
392
394{
395public:
396 EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
397
398 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev ) override;
399};
400
401
403{
404public:
405 EditCharAttribGrabBag( const SfxGrabBagItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd );
406};
407
408
409/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
EditCharAttribBackgroundColor(const SvxColorItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:221
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:230
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:201
EditCharAttribCaseMap(const SvxCaseMapItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:195
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:214
EditCharAttribColor(const SvxColorItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:208
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:435
EditCharAttribEmphasisMark(const SvxEmphasisMarkItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:429
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:269
EditCharAttribEscapement(const SvxEscapementItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:263
std::optional< Color > & GetFieldColor()
Definition: editattr.hxx:362
const OUString & GetFieldValue() const
Definition: editattr.hxx:365
std::optional< FontLineStyle > & GetFldLineStyle()
Definition: editattr.hxx:363
EditCharAttribField(const SvxFieldItem &rAttr, sal_Int32 nPos)
Definition: editattr.cxx:317
virtual ~EditCharAttribField() override
Definition: editattr.cxx:360
bool operator==(const EditCharAttribField &rAttr) const
Definition: editattr.cxx:365
std::optional< Color > & GetTextColor()
Definition: editattr.hxx:361
std::optional< Color > mxFldColor
Definition: editattr.hxx:346
std::optional< FontLineStyle > mxFldLineStyle
Definition: editattr.hxx:347
std::optional< Color > mxTxtColor
Definition: editattr.hxx:345
OUString aFieldValue
Definition: editattr.hxx:344
void SetFieldValue(const OUString &rVal)
Definition: editattr.cxx:337
EditCharAttribField & operator=(const EditCharAttribField &rAttr)=delete
bool operator!=(const EditCharAttribField &rAttr) const
Definition: editattr.hxx:357
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:323
EditCharAttribFontHeight(const SvxFontHeightItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:155
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:161
EditCharAttribFontWidth(const SvxCharScaleWidthItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:169
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:175
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:85
EditCharAttribFont(const SvxFontItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:79
EditCharAttribGrabBag(const SfxGrabBagItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:454
EditCharAttribItalic(const SvxPostureItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:97
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:103
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:409
EditCharAttribKerning(const SvxKerningItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:403
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:243
EditCharAttribLanguage(const SvxLanguageItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:237
EditCharAttribLineBreak(const SfxVoidItem &rAttr, sal_Int32 nPos)
Definition: editattr.cxx:305
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:311
EditCharAttribOutline(const SvxContourItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:280
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:286
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:146
EditCharAttribOverline(const SvxOverlineItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:140
EditCharAttribPairKerning(const SvxAutoKernItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:390
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:396
EditCharAttribRelief(const SvxCharReliefItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:442
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:448
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:256
EditCharAttribShadow(const SvxShadowedItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:250
EditCharAttribStrikeout(const SvxCrossedOutItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:182
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:188
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:299
EditCharAttribTab(const SfxVoidItem &rAttr, sal_Int32 nPos)
Definition: editattr.cxx:293
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:129
EditCharAttribUnderline(const SvxUnderlineItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:123
EditCharAttribWeight(const SvxWeightItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:110
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:116
EditCharAttribWordLineMode(const SvxWordLineModeItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:416
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev) override
Definition: editattr.cxx:422
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: editattr.cxx:66
void SetEdge(bool b)
Definition: editattr.hxx:114
sal_Int32 nStart
Definition: editattr.hxx:70
void MoveForward(sal_Int32 nDiff)
Definition: editattr.hxx:123
sal_Int32 & GetStart()
Definition: editattr.hxx:87
const SfxPoolItem * GetItem() const
Definition: editattr.hxx:85
sal_Int32 GetStart() const
Definition: editattr.hxx:90
void MoveBackward(sal_Int32 nDiff)
Definition: editattr.hxx:130
void SetFeature(bool b)
Definition: editattr.hxx:111
sal_Int32 nEnd
Definition: editattr.hxx:71
sal_uInt16 Which() const
Definition: editattr.hxx:84
sal_Int32 GetEnd() const
Definition: editattr.hxx:91
bool IsIn(sal_Int32 nIndex) const
Definition: editattr.hxx:103
bool IsEmpty() const
Definition: editattr.hxx:107
void Expand(sal_Int32 nDiff)
Definition: editattr.hxx:137
EditCharAttrib(const SfxPoolItem &rAttr, sal_Int32 nStart, sal_Int32 nEnd)
Definition: editattr.cxx:49
bool IsInside(sal_Int32 nIndex) const
Definition: editattr.hxx:105
sal_Int32 & GetEnd()
Definition: editattr.hxx:88
virtual ~EditCharAttrib()
Definition: editattr.cxx:58
virtual void SetFont(SvxFont &rFont, OutputDevice *pOutDev)
Definition: editattr.cxx:62
void Collaps(sal_Int32 nDiff)
Definition: editattr.hxx:144
bool IsFeature() const
Definition: editattr.hxx:110
EditCharAttrib(const EditCharAttrib &)=delete
const SfxPoolItem * pItem
Definition: editattr.hxx:68
sal_Int32 GetLen() const
Definition: editattr.hxx:117
EditCharAttrib & operator=(const EditCharAttrib &)=delete
bool IsEdge() const
Definition: editattr.hxx:113
sal_uInt16 Which() const
SvxColorItem item describes a color.
Definition: colritem.hxx:32
This item stores a field (SvxFieldData).
Definition: flditem.hxx:70
This item describes a Font.
Definition: fontitem.hxx:30
#define DBG_ASSERT(sCon, aError)
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int32 nIndex
sal_uInt16 nPos
#define SAL_MAX_INT32