update dev300-m57
[ooovba.git] / sw / inc / txatbase.hxx
blob503812085c078cc2289083a1a78216bdd9a3e569
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: txatbase.hxx,v $
10 * $Revision: 1.22.210.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _TXATBASE_HXX
31 #define _TXATBASE_HXX
33 #include <tools/solar.h>
34 #include <svtools/poolitem.hxx>
35 #include <hintids.hxx>
36 #include <errhdl.hxx>
38 #include <boost/utility.hpp>
41 class SfxItemPool;
42 class SvxBrushItem;
43 class SvxFontItem;
44 class SvxPostureItem;
45 class SvxWeightItem;
46 class SvxUnderlineItem;
47 class SvxOverlineItem;
48 class SvxFontHeightItem;
49 class SvxPropSizeItem;
50 class SvxShadowedItem;
51 class SvxAutoKernItem;
52 class SvxWordLineModeItem;
53 class SvxContourItem;
54 class SvxCrossedOutItem;
55 class SvxColorItem;
56 class SvxCharSetColorItem;
57 class SvXMLAttrContainerItem;
58 class SwFmtRuby;
59 class SvxTwoLinesItem;
60 class SvxEmphasisMarkItem;
61 class SvxCharScaleWidthItem;
62 class SvxCharRotateItem;
63 class SvxCharReliefItem;
64 class SvxCharHiddenItem;
66 class SwFmtCharFmt;
67 class SwFmtAutoFmt;
68 class SwFmtINetFmt;
69 class SvxKerningItem;
70 class SvxCaseMapItem;
71 class SvxLanguageItem;
72 class SvxEscapementItem;
73 class SvxBlinkItem;
74 class SvxNoHyphenItem;
75 class SwFmtSoftHyph;
76 class SwFmtHardBlank;
77 class SwFmtFld;
78 class SwFmtFtn;
79 class SwFmtFlyCnt;
80 class SwTOXMark;
81 class SwFmtRefMark;
83 class SwTxtAttr : private boost::noncopyable
85 const SfxPoolItem* m_pAttr;
86 xub_StrLen m_nStart;
87 bool m_bDontExpand : 1;
88 bool m_bLockExpandFlag : 1;
90 bool m_bDontMergeAttr : 1; // refmarks, toxmarks, ruby
91 bool m_bDontMoveAttr : 1; // refmarks, toxmarks
92 bool m_bCharFmtAttr : 1; // charfmt, inet
93 bool m_bOverlapAllowedAttr : 1; // refmarks, toxmarks
94 bool m_bPriorityAttr : 1; // attribute has priority (redlining)
95 bool m_bDontExpandStart : 1; // don't expand start at paragraph start (ruby)
97 protected:
98 SwTxtAttr( const SfxPoolItem& rAttr, xub_StrLen nStart );
100 void SetLockExpandFlag( bool bFlag ) { m_bLockExpandFlag = bFlag; }
101 void SetDontMergeAttr( bool bFlag ) { m_bDontMergeAttr = bFlag; }
102 void SetDontMoveAttr( bool bFlag ) { m_bDontMoveAttr = bFlag; }
103 void SetCharFmtAttr( bool bFlag ) { m_bCharFmtAttr = bFlag; }
104 void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; }
105 void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
107 public:
108 virtual ~SwTxtAttr();
110 // RemoveFromPool muss immer vorm DTOR Aufruf erfolgen!!
111 void RemoveFromPool( SfxItemPool& rPool );
113 /// start position
114 xub_StrLen* GetStart() { return & m_nStart; }
115 const xub_StrLen* GetStart() const { return & m_nStart; }
117 /// end position
118 virtual xub_StrLen* GetEnd();
119 inline const xub_StrLen* GetEnd() const;
120 /// end (if available), else start
121 inline const xub_StrLen* GetAnyEnd() const;
123 inline void SetDontExpand( bool bDontExpand );
124 bool DontExpand() const { return m_bDontExpand; }
125 bool IsLockExpandFlag() const { return m_bLockExpandFlag; }
126 bool IsDontMergeAttr() const { return m_bDontMergeAttr; }
127 bool IsDontMoveAttr() const { return m_bDontMoveAttr; }
128 bool IsCharFmtAttr() const { return m_bCharFmtAttr; }
129 bool IsOverlapAllowedAttr() const { return m_bOverlapAllowedAttr; }
130 bool IsPriorityAttr() const { return m_bPriorityAttr; }
131 void SetPriorityAttr( bool bFlag ) { m_bPriorityAttr = bFlag; }
132 bool IsDontExpandStartAttr() const { return m_bDontExpandStart; }
134 inline const SfxPoolItem& GetAttr() const;
135 inline USHORT Which() const { return GetAttr().Which(); }
137 virtual int operator==( const SwTxtAttr& ) const;
139 inline const SvxFontItem &GetFont() const;
140 inline const SvxPostureItem &GetPosture() const;
141 inline const SvxWeightItem &GetWeight() const;
142 inline const SvxUnderlineItem &GetUnderline() const;
143 inline const SvxOverlineItem &GetOverline() const;
144 inline const SvxFontHeightItem &GetFontSize() const;
145 inline const SvxPropSizeItem &GetPropSize() const;
146 inline const SvxShadowedItem &GetShadowed() const;
147 inline const SvxAutoKernItem &GetAutoKern() const;
148 inline const SvxWordLineModeItem &GetWordLineMode() const;
149 inline const SvxContourItem &GetContour() const;
150 inline const SvxCrossedOutItem &GetCrossedOut() const;
151 inline const SvxColorItem &GetColor() const;
152 inline const SvxCharSetColorItem &GetCharSetColor() const;
153 inline const SwFmtCharFmt &GetCharFmt() const;
154 inline const SwFmtAutoFmt &GetAutoFmt() const;
155 inline const SvxKerningItem &GetKerning() const;
156 inline const SvxCaseMapItem &GetCaseMap() const;
157 inline const SvxLanguageItem &GetLanguage() const;
158 inline const SvxEscapementItem &GetEscapement() const;
159 inline const SvxBlinkItem &GetBlink() const;
160 inline const SvxBrushItem &GetChrBackground() const;
161 inline const SvxNoHyphenItem &GetNoHyphenHere() const;
162 inline const SwFmtSoftHyph &GetSoftHyph() const;
163 inline const SwFmtHardBlank &GetHardBlank() const;
164 inline const SwFmtFld &GetFld() const;
165 inline const SwFmtFtn &GetFtn() const;
166 inline const SwFmtFlyCnt &GetFlyCnt() const;
167 inline const SwTOXMark &GetTOXMark() const;
168 inline const SwFmtRefMark &GetRefMark() const;
169 inline const SwFmtINetFmt &GetINetFmt() const;
170 inline const SvXMLAttrContainerItem &GetXMLAttrContainer() const;
171 inline const SwFmtRuby &GetRuby() const;
172 inline const SvxTwoLinesItem &Get2Lines() const;
173 inline const SvxEmphasisMarkItem &GetEmphasisMark() const;
174 inline const SvxCharScaleWidthItem &GetCharScaleW() const;
175 inline const SvxCharRotateItem &GetCharRotate() const;
176 inline const SvxCharReliefItem &GetCharRelief() const;
177 inline const SvxCharHiddenItem &GetCharHidden() const;
181 class SwTxtAttrEnd : public SwTxtAttr
183 using SwTxtAttr::GetEnd;
185 protected:
186 xub_StrLen m_nEnd;
188 public:
189 SwTxtAttrEnd( const SfxPoolItem& rAttr, USHORT nStart, USHORT nEnd );
191 virtual xub_StrLen* GetEnd();
195 // --------------- Inline Implementierungen ------------------------
197 inline const xub_StrLen* SwTxtAttr::GetEnd() const
199 return const_cast<SwTxtAttr * >(this)->GetEnd();
202 inline const xub_StrLen* SwTxtAttr::GetAnyEnd() const
204 const xub_StrLen* pEnd = GetEnd();
205 return pEnd ? pEnd : GetStart();
208 inline const SfxPoolItem& SwTxtAttr::GetAttr() const
210 ASSERT( m_pAttr, "SwTxtAttr: where is my attribute?" );
211 return *m_pAttr;
214 inline void SwTxtAttr::SetDontExpand( bool bDontExpand )
216 if ( !m_bLockExpandFlag )
218 m_bDontExpand = bDontExpand;
222 inline const SvxFontItem& SwTxtAttr::GetFont() const
224 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONT, "Wrong attribute" );
225 return (const SvxFontItem&)(*m_pAttr);
228 inline const SvxPostureItem& SwTxtAttr::GetPosture() const
230 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_POSTURE,
231 "Wrong attribute" );
232 return (const SvxPostureItem&)(*m_pAttr);
235 inline const SvxWeightItem& SwTxtAttr::GetWeight() const
237 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WEIGHT,
238 "Wrong attribute" );
239 return (const SvxWeightItem&)(*m_pAttr);
242 inline const SvxUnderlineItem& SwTxtAttr::GetUnderline() const
244 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_UNDERLINE,
245 "Wrong attribute" );
246 return (const SvxUnderlineItem&)(*m_pAttr);
249 inline const SvxOverlineItem& SwTxtAttr::GetOverline() const
251 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_OVERLINE,
252 "Wrong attribute" );
253 return (const SvxOverlineItem&)(*m_pAttr);
256 inline const SvxFontHeightItem& SwTxtAttr::GetFontSize() const
258 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_FONTSIZE,
259 "Wrong attribute" );
260 return (const SvxFontHeightItem&)(*m_pAttr);
263 inline const SvxPropSizeItem& SwTxtAttr::GetPropSize() const
265 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_PROPORTIONALFONTSIZE,
266 "Wrong attribute" );
267 return (const SvxPropSizeItem&)(*m_pAttr);
270 inline const SvxShadowedItem& SwTxtAttr::GetShadowed() const
272 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SHADOWED,
273 "Wrong attribute" );
274 return (const SvxShadowedItem&)(*m_pAttr);
277 inline const SvxAutoKernItem& SwTxtAttr::GetAutoKern() const
279 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_AUTOKERN,
280 "Wrong attribute" );
281 return (const SvxAutoKernItem&)(*m_pAttr);
284 inline const SvxWordLineModeItem& SwTxtAttr::GetWordLineMode() const
286 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_WORDLINEMODE,
287 "Wrong attribute" );
288 return (const SvxWordLineModeItem&)(*m_pAttr);
291 inline const SvxContourItem& SwTxtAttr::GetContour() const
293 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CONTOUR,
294 "Wrong attribute" );
295 return (const SvxContourItem&)(*m_pAttr);
298 inline const SvxCrossedOutItem& SwTxtAttr::GetCrossedOut() const
300 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CROSSEDOUT,
301 "Wrong attribute" );
302 return (const SvxCrossedOutItem&)(*m_pAttr);
305 inline const SvxColorItem& SwTxtAttr::GetColor() const
307 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_COLOR,
308 "Wrong attribute" );
309 return (const SvxColorItem&)(*m_pAttr);
312 inline const SvxCharSetColorItem& SwTxtAttr::GetCharSetColor() const
314 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CHARSETCOLOR,
315 "Wrong attribute" );
316 return (const SvxCharSetColorItem&)(*m_pAttr);
319 inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const
321 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT,
322 "Wrong attribute" );
323 return (const SwFmtCharFmt&)(*m_pAttr);
326 inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const
328 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT,
329 "Wrong attribute" );
330 return (const SwFmtAutoFmt&)(*m_pAttr);
333 inline const SvxKerningItem& SwTxtAttr::GetKerning() const
335 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_KERNING,
336 "Wrong attribute" );
337 return (const SvxKerningItem&)(*m_pAttr);
340 inline const SvxCaseMapItem& SwTxtAttr::GetCaseMap() const
342 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_CASEMAP,
343 "Wrong attribute" );
344 return (const SvxCaseMapItem&)(*m_pAttr);
347 inline const SvxLanguageItem& SwTxtAttr::GetLanguage() const
349 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_LANGUAGE,
350 "Wrong attribute" );
351 return (const SvxLanguageItem&)(*m_pAttr);
354 inline const SvxEscapementItem& SwTxtAttr::GetEscapement() const
356 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ESCAPEMENT,
357 "Wrong attribute" );
358 return (const SvxEscapementItem&)(*m_pAttr);
361 inline const SvxBlinkItem& SwTxtAttr::GetBlink() const
363 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BLINK,
364 "Wrong attribute" );
365 return (const SvxBlinkItem&)(*m_pAttr);
368 inline const SvxBrushItem& SwTxtAttr::GetChrBackground() const
370 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_BACKGROUND,
371 "Wrong attribute" );
372 return (const SvxBrushItem&)(*m_pAttr);
375 inline const SvxNoHyphenItem& SwTxtAttr::GetNoHyphenHere() const
377 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_NOHYPHEN,
378 "Wrong attribute" );
379 return (const SvxNoHyphenItem&)(*m_pAttr);
382 inline const SwFmtSoftHyph& SwTxtAttr::GetSoftHyph() const
384 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_SOFTHYPH,
385 "Wrong attribute" );
386 return (const SwFmtSoftHyph&)(*m_pAttr);
389 inline const SwFmtHardBlank& SwTxtAttr::GetHardBlank() const
391 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_HARDBLANK,
392 "Wrong attribute" );
393 return (const SwFmtHardBlank&)(*m_pAttr);
396 inline const SwFmtFld& SwTxtAttr::GetFld() const
398 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD,
399 "Wrong attribute" );
400 return (const SwFmtFld&)(*m_pAttr);
403 inline const SwFmtFtn& SwTxtAttr::GetFtn() const
405 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN, "Wrong attribute" );
406 return (const SwFmtFtn&)(*m_pAttr);
409 inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const
411 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT,
412 "Wrong attribute" );
413 return (const SwFmtFlyCnt&)(*m_pAttr);
416 inline const SwTOXMark& SwTxtAttr::GetTOXMark() const
418 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK,
419 "Wrong attribute" );
420 return (const SwTOXMark&)(*m_pAttr);
423 inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const
425 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK,
426 "Wrong attribute" );
427 return (const SwFmtRefMark&)(*m_pAttr);
430 inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const
432 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT,
433 "Wrong attribute" );
434 return (const SwFmtINetFmt&)(*m_pAttr);
437 inline const SvXMLAttrContainerItem& SwTxtAttr::GetXMLAttrContainer() const
439 ASSERT( m_pAttr && m_pAttr->Which() == RES_UNKNOWNATR_CONTAINER,
440 "Wrong attribute" );
441 return (const SvXMLAttrContainerItem&)(*m_pAttr);
444 inline const SwFmtRuby& SwTxtAttr::GetRuby() const
446 ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY,
447 "Wrong attribute" );
448 return (const SwFmtRuby&)(*m_pAttr);
450 inline const SvxTwoLinesItem& SwTxtAttr::Get2Lines() const
452 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_TWO_LINES,
453 "Wrong attribute" );
454 return (const SvxTwoLinesItem&)(*m_pAttr);
457 inline const SvxEmphasisMarkItem& SwTxtAttr::GetEmphasisMark() const
459 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_EMPHASIS_MARK,
460 "Wrong attribute" );
461 return (const SvxEmphasisMarkItem&)(*m_pAttr);
464 inline const SvxCharScaleWidthItem& SwTxtAttr::GetCharScaleW() const
466 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_SCALEW,
467 "Wrong attribute" );
468 return (const SvxCharScaleWidthItem&)(*m_pAttr);
471 inline const SvxCharRotateItem& SwTxtAttr::GetCharRotate() const
473 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_ROTATE,
474 "Wrong attribute" );
475 return (const SvxCharRotateItem&)(*m_pAttr);
478 inline const SvxCharReliefItem& SwTxtAttr::GetCharRelief() const
480 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_RELIEF,
481 "Wrong attribute" );
482 return (const SvxCharReliefItem&)(*m_pAttr);
485 inline const SvxCharHiddenItem& SwTxtAttr::GetCharHidden() const
487 ASSERT( m_pAttr && m_pAttr->Which() == RES_CHRATR_HIDDEN,
488 "Wrong attribute" );
489 return (const SvxCharHiddenItem&)(*m_pAttr);
492 #endif