1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 #ifndef _EDITATTR_HXX
25 #define _EDITATTR_HXX
26
27 #include <editeng/eeitem.hxx>
28
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 SvxAutoKernItem;
43 class SvxKerningItem;
44 class SvxCharSetColorItem;
45 class SvxWordLineModeItem;
46 class SvxFieldItem;
47 class SvxLanguageItem;
48 class SvxEmphasisMarkItem;
49 class SvxCharReliefItem;
50 #include <svl/poolitem.hxx>
51
52
53 class SfxVoidItem;
54
55 #define CH_FEATURE_OLD (sal_uInt8) 0xFF
56 #define CH_FEATURE (sal_Unicode) 0x01
57
58 // DEF_METRIC: Bei meinem Pool sollte immer die DefMetric bei
59 // GetMetric( nWhich ) ankommen!
60 // => Zum ermitteln der DefMetrik einfach ein GetMetric( 0 )
61 #define DEF_METRIC 0
62
63 // -------------------------------------------------------------------------
64 // class EditAttrib
65 // -------------------------------------------------------------------------
66 class EditAttrib
67 {
68 private:
EditAttrib()69 EditAttrib() {;}
EditAttrib(const EditAttrib &)70 EditAttrib( const EditAttrib & ) {;}
71
72 protected:
73 const SfxPoolItem* pItem;
74
75 EditAttrib( const SfxPoolItem& rAttr );
76 virtual ~EditAttrib();
77
78 public:
79 // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!!
80 void RemoveFromPool( SfxItemPool& rPool );
81
Which() const82 sal_uInt16 Which() const { return pItem->Which(); }
GetItem() const83 const SfxPoolItem* GetItem() const { return pItem; }
84 };
85
86 // -------------------------------------------------------------------------
87 // class EditCharAttrib
88 // -------------------------------------------------------------------------
89 // bFeature: Attribut darf nicht expandieren/schrumfen, Laenge immer 1
90 // bEdge: Attribut expandiert nicht, wenn genau an der Kante expandiert werden soll
91 class EditCharAttrib : public EditAttrib
92 {
93 protected:
94
95 sal_uInt16 nStart;
96 sal_uInt16 nEnd;
97 sal_Bool bFeature :1;
98 sal_Bool bEdge :1;
99
100 public:
101 EditCharAttrib( const SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
102
GetStart()103 sal_uInt16& GetStart() { return nStart; }
GetEnd()104 sal_uInt16& GetEnd() { return nEnd; }
105
GetStart() const106 sal_uInt16 GetStart() const { return nStart; }
GetEnd() const107 sal_uInt16 GetEnd() const { return nEnd; }
108
109 inline sal_uInt16 GetLen() const;
110
111 inline void MoveForward( sal_uInt16 nDiff );
112 inline void MoveBackward( sal_uInt16 nDiff );
113
114 inline void Expand( sal_uInt16 nDiff );
115 inline void Collaps( sal_uInt16 nDiff );
116
117 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
118
IsIn(sal_uInt16 nIndex)119 sal_Bool IsIn( sal_uInt16 nIndex )
120 { return ( ( nStart <= nIndex ) && ( nEnd >= nIndex ) ); }
IsInside(sal_uInt16 nIndex)121 sal_Bool IsInside( sal_uInt16 nIndex )
122 { return ( ( nStart < nIndex ) && ( nEnd > nIndex ) ); }
IsEmpty()123 sal_Bool IsEmpty()
124 { return nStart == nEnd; }
125
IsFeature() const126 sal_Bool IsFeature() const { return bFeature; }
SetFeature(sal_Bool b)127 void SetFeature( sal_Bool b) { bFeature = b; }
128
IsEdge() const129 sal_Bool IsEdge() const { return bEdge; }
SetEdge(sal_Bool b)130 void SetEdge( sal_Bool b ) { bEdge = b; }
131 };
132
GetLen() const133 inline sal_uInt16 EditCharAttrib::GetLen() const
134 {
135 DBG_ASSERT( nEnd >= nStart, "EditCharAttrib: nEnd < nStart!" );
136 return nEnd-nStart;
137 }
138
MoveForward(sal_uInt16 nDiff)139 inline void EditCharAttrib::MoveForward( sal_uInt16 nDiff )
140 {
141 DBG_ASSERT( ((long)nEnd + nDiff) <= 0xFFFF, "EditCharAttrib: MoveForward?!" );
142 nStart = nStart + nDiff;
143 nEnd = nEnd + nDiff;
144 }
145
MoveBackward(sal_uInt16 nDiff)146 inline void EditCharAttrib::MoveBackward( sal_uInt16 nDiff )
147 {
148 DBG_ASSERT( ((long)nStart - nDiff) >= 0, "EditCharAttrib: MoveBackward?!" );
149 nStart = nStart - nDiff;
150 nEnd = nEnd - nDiff;
151 }
152
Expand(sal_uInt16 nDiff)153 inline void EditCharAttrib::Expand( sal_uInt16 nDiff )
154 {
155 DBG_ASSERT( ( ((long)nEnd + nDiff) <= (long)0xFFFF ), "EditCharAttrib: Expand?!" );
156 DBG_ASSERT( !bFeature, "Bitte keine Features expandieren!" );
157 nEnd = nEnd + nDiff;
158 }
159
Collaps(sal_uInt16 nDiff)160 inline void EditCharAttrib::Collaps( sal_uInt16 nDiff )
161 {
162 DBG_ASSERT( (long)nEnd - nDiff >= (long)nStart, "EditCharAttrib: Collaps?!" );
163 DBG_ASSERT( !bFeature, "Bitte keine Features schrumpfen!" );
164 nEnd = nEnd - nDiff;
165 }
166
167 // -------------------------------------------------------------------------
168 // class EditCharAttribFont
169 // -------------------------------------------------------------------------
170 class EditCharAttribFont: public EditCharAttrib
171 {
172 public:
173 EditCharAttribFont( const SvxFontItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
174
175 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
176 };
177
178 // -------------------------------------------------------------------------
179 // class EditCharAttribWeight
180 // -------------------------------------------------------------------------
181 class EditCharAttribWeight : public EditCharAttrib
182 {
183 public:
184 EditCharAttribWeight( const SvxWeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
185
186 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
187 };
188 // -------------------------------------------------------------------------
189 // class EditCharAttribItalic
190 // -------------------------------------------------------------------------
191 class EditCharAttribItalic : public EditCharAttrib
192 {
193 public:
194 EditCharAttribItalic( const SvxPostureItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
195
196 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
197 };
198
199 // -------------------------------------------------------------------------
200 // class EditCharAttribShadow
201 // -------------------------------------------------------------------------
202 class EditCharAttribShadow : public EditCharAttrib
203 {
204 public:
205 EditCharAttribShadow( const SvxShadowedItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
206
207 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
208 };
209
210 // -------------------------------------------------------------------------
211 // class EditCharAttribEscapement
212 // -------------------------------------------------------------------------
213 class EditCharAttribEscapement : public EditCharAttrib
214 {
215 public:
216 EditCharAttribEscapement( const SvxEscapementItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
217
218 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
219 };
220
221 // -------------------------------------------------------------------------
222 // class EditCharAttribOutline
223 // -------------------------------------------------------------------------
224 class EditCharAttribOutline : public EditCharAttrib
225 {
226 public:
227 EditCharAttribOutline( const SvxContourItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
228
229 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
230 };
231
232 // -------------------------------------------------------------------------
233 // class EditCharAttribStrikeout
234 // -------------------------------------------------------------------------
235 class EditCharAttribStrikeout : public EditCharAttrib
236 {
237 public:
238 EditCharAttribStrikeout( const SvxCrossedOutItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
239
240 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
241 };
242
243 // -------------------------------------------------------------------------
244 // class EditCharAttribUnderline
245 // -------------------------------------------------------------------------
246 class EditCharAttribUnderline : public EditCharAttrib
247 {
248 public:
249 EditCharAttribUnderline( const SvxUnderlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
250
251 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
252 };
253
254 // -------------------------------------------------------------------------
255 // class EditCharAttribOverline
256 // -------------------------------------------------------------------------
257 class EditCharAttribOverline : public EditCharAttrib
258 {
259 public:
260 EditCharAttribOverline( const SvxOverlineItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
261
262 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
263 };
264
265 // -------------------------------------------------------------------------
266 // class EditCharAttribEmphasisMark
267 // -------------------------------------------------------------------------
268 class EditCharAttribEmphasisMark : public EditCharAttrib
269 {
270 public:
271 EditCharAttribEmphasisMark( const SvxEmphasisMarkItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
272
273 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
274 };
275
276 // -------------------------------------------------------------------------
277 // class EditCharAttribRelief
278 // -------------------------------------------------------------------------
279 class EditCharAttribRelief : public EditCharAttrib
280 {
281 public:
282 EditCharAttribRelief( const SvxCharReliefItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
283
284 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
285 };
286
287 // -------------------------------------------------------------------------
288 // class EditCharAttribFontHeight
289 // -------------------------------------------------------------------------
290 class EditCharAttribFontHeight : public EditCharAttrib
291 {
292 public:
293 EditCharAttribFontHeight( const SvxFontHeightItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
294
295 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
296 };
297
298 // -------------------------------------------------------------------------
299 // class EditCharAttribFontWidth
300 // -------------------------------------------------------------------------
301 class EditCharAttribFontWidth : public EditCharAttrib
302 {
303 public:
304 EditCharAttribFontWidth( const SvxCharScaleWidthItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
305
306 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
307 };
308
309 // -------------------------------------------------------------------------
310 // class EditCharAttribColor
311 // -------------------------------------------------------------------------
312 class EditCharAttribColor : public EditCharAttrib
313 {
314 public:
315 EditCharAttribColor( const SvxColorItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
316
317 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
318 };
319
320 // -------------------------------------------------------------------------
321 // class EditCharAttribLanguage
322 // -------------------------------------------------------------------------
323 class EditCharAttribLanguage : public EditCharAttrib
324 {
325 public:
326 EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
327
328 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
329 };
330
331 // -------------------------------------------------------------------------
332 // class EditCharAttribTab
333 // -------------------------------------------------------------------------
334 class EditCharAttribTab : public EditCharAttrib
335 {
336 public:
337 EditCharAttribTab( const SfxVoidItem& rAttr, sal_uInt16 nPos );
338
339 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
340 };
341
342 // -------------------------------------------------------------------------
343 // class EditCharAttribLineBreak
344 // -------------------------------------------------------------------------
345 class EditCharAttribLineBreak : public EditCharAttrib
346 {
347 public:
348 EditCharAttribLineBreak( const SfxVoidItem& rAttr, sal_uInt16 nPos );
349
350 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
351 };
352
353 // -------------------------------------------------------------------------
354 // class EditCharAttribField
355 // -------------------------------------------------------------------------
356 class EditCharAttribField: public EditCharAttrib
357 {
358 XubString aFieldValue;
359 Color* pTxtColor;
360 Color* pFldColor;
361
362 EditCharAttribField& operator = ( const EditCharAttribField& rAttr ) const;
363
364 public:
365 EditCharAttribField( const SvxFieldItem& rAttr, sal_uInt16 nPos );
366 EditCharAttribField( const EditCharAttribField& rAttr );
367 ~EditCharAttribField();
368
369 sal_Bool operator == ( const EditCharAttribField& rAttr ) const;
operator !=(const EditCharAttribField & rAttr) const370 sal_Bool operator != ( const EditCharAttribField& rAttr ) const
371 { return !(operator == ( rAttr ) ); }
372
373 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
GetTxtColor()374 Color*& GetTxtColor() { return pTxtColor; }
GetFldColor()375 Color*& GetFldColor() { return pFldColor; }
376
GetFieldValue() const377 const XubString& GetFieldValue() const { return aFieldValue; }
GetFieldValue()378 XubString& GetFieldValue() { return aFieldValue; }
379
Reset()380 void Reset()
381 {
382 aFieldValue.Erase();
383 delete pTxtColor; pTxtColor = 0;
384 delete pFldColor; pFldColor = 0;
385 }
386 };
387
388 // -------------------------------------------------------------------------
389 // class EditCharAttribPairKerning
390 // -------------------------------------------------------------------------
391 class EditCharAttribPairKerning : public EditCharAttrib
392 {
393 public:
394 EditCharAttribPairKerning( const SvxAutoKernItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
395
396 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
397 };
398
399 // -------------------------------------------------------------------------
400 // class EditCharAttribKerning
401 // -------------------------------------------------------------------------
402 class EditCharAttribKerning : public EditCharAttrib
403 {
404 public:
405 EditCharAttribKerning( const SvxKerningItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
406
407 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
408 };
409
410 // -------------------------------------------------------------------------
411 // class EditCharAttribWordLineMode
412 // -------------------------------------------------------------------------
413 class EditCharAttribWordLineMode: public EditCharAttrib
414 {
415 public:
416 EditCharAttribWordLineMode( const SvxWordLineModeItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
417
418 virtual void SetFont( SvxFont& rFont, OutputDevice* pOutDev );
419 };
420
421
422 #endif // _EDITATTR_HXX
423