fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / sw / inc / txatbase.hxx
blobe69b08871fd329da62ef3ec6a6d9e078690ff892
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 .
19 #ifndef _TXATBASE_HXX
20 #define _TXATBASE_HXX
22 #include <tools/solar.h>
23 #include <svl/poolitem.hxx>
24 #include <hintids.hxx>
26 #include <boost/utility.hpp>
29 class SfxItemPool;
30 class SvXMLAttrContainerItem;
31 class SwFmtRuby;
32 class SwFmtCharFmt;
33 class SwFmtAutoFmt;
34 class SwFmtINetFmt;
35 class SwFmtFld;
36 class SwFmtFtn;
37 class SwFmtFlyCnt;
38 class SwTOXMark;
39 class SwFmtRefMark;
40 class SwFmtMeta;
43 class SwTxtAttr : private boost::noncopyable
45 private:
46 SfxPoolItem * const m_pAttr;
47 xub_StrLen m_nStart;
48 bool m_bDontExpand : 1;
49 bool m_bLockExpandFlag : 1;
51 bool m_bDontMoveAttr : 1; // refmarks, toxmarks
52 bool m_bCharFmtAttr : 1; // charfmt, inet
53 bool m_bOverlapAllowedAttr : 1; // refmarks, toxmarks
54 bool m_bPriorityAttr : 1; // attribute has priority (redlining)
55 bool m_bDontExpandStart : 1; // don't expand start at paragraph start (ruby)
56 bool m_bNesting : 1; // SwTxtAttrNesting
57 bool m_bHasDummyChar : 1; // without end + meta
58 bool m_bFormatIgnoreStart : 1; ///< text formatting should ignore start
59 bool m_bFormatIgnoreEnd : 1; ///< text formatting should ignore end
61 protected:
62 SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart );
63 virtual ~SwTxtAttr();
65 void SetLockExpandFlag( bool bFlag ) { m_bLockExpandFlag = bFlag; }
66 void SetDontMoveAttr( bool bFlag ) { m_bDontMoveAttr = bFlag; }
67 void SetCharFmtAttr( bool bFlag ) { m_bCharFmtAttr = bFlag; }
68 void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; }
69 void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; }
70 void SetNesting(const bool bFlag) { m_bNesting = bFlag; }
71 void SetHasDummyChar(const bool bFlag) { m_bHasDummyChar = bFlag; }
73 public:
75 /// destroy instance
76 static void Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool );
78 /// start position
79 xub_StrLen* GetStart() { return & m_nStart; }
80 const xub_StrLen* GetStart() const { return & m_nStart; }
82 /// end position
83 virtual xub_StrLen* GetEnd();
84 inline const xub_StrLen* GetEnd() const;
85 /// end (if available), else start
86 inline const xub_StrLen* GetAnyEnd() const;
88 inline void SetDontExpand( bool bDontExpand );
89 bool DontExpand() const { return m_bDontExpand; }
90 bool IsLockExpandFlag() const { return m_bLockExpandFlag; }
91 bool IsDontMoveAttr() const { return m_bDontMoveAttr; }
92 bool IsCharFmtAttr() const { return m_bCharFmtAttr; }
93 bool IsOverlapAllowedAttr() const { return m_bOverlapAllowedAttr; }
94 bool IsPriorityAttr() const { return m_bPriorityAttr; }
95 void SetPriorityAttr( bool bFlag ) { m_bPriorityAttr = bFlag; }
96 bool IsDontExpandStartAttr() const { return m_bDontExpandStart; }
97 bool IsNesting() const { return m_bNesting; }
98 bool HasDummyChar() const { return m_bHasDummyChar; }
99 bool IsFormatIgnoreStart() const { return m_bFormatIgnoreStart; }
100 bool IsFormatIgnoreEnd () const { return m_bFormatIgnoreEnd ; }
101 void SetFormatIgnoreStart(bool bFlag) { m_bFormatIgnoreStart = bFlag; }
102 void SetFormatIgnoreEnd (bool bFlag) { m_bFormatIgnoreEnd = bFlag; }
104 inline const SfxPoolItem& GetAttr() const;
105 inline SfxPoolItem& GetAttr();
106 inline sal_uInt16 Which() const { return GetAttr().Which(); }
108 virtual int operator==( const SwTxtAttr& ) const;
110 inline const SwFmtCharFmt &GetCharFmt() const;
111 inline const SwFmtAutoFmt &GetAutoFmt() const;
112 inline const SwFmtFld &GetFld() const;
113 inline const SwFmtFtn &GetFtn() const;
114 inline const SwFmtFlyCnt &GetFlyCnt() const;
115 inline const SwTOXMark &GetTOXMark() const;
116 inline const SwFmtRefMark &GetRefMark() const;
117 inline const SwFmtINetFmt &GetINetFmt() const;
118 inline const SwFmtRuby &GetRuby() const;
119 inline const SwFmtMeta &GetMeta() const;
123 class SwTxtAttrEnd : public SwTxtAttr
125 protected:
126 xub_StrLen m_nEnd;
128 public:
129 SwTxtAttrEnd( SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd );
131 using SwTxtAttr::GetEnd;
132 virtual xub_StrLen* GetEnd();
136 // --------------- Inline Implementations ------------------------
138 inline const xub_StrLen* SwTxtAttr::GetEnd() const
140 return const_cast<SwTxtAttr * >(this)->GetEnd();
143 inline const xub_StrLen* SwTxtAttr::GetAnyEnd() const
145 const xub_StrLen* pEnd = GetEnd();
146 return pEnd ? pEnd : GetStart();
149 inline const SfxPoolItem& SwTxtAttr::GetAttr() const
151 OSL_ENSURE( m_pAttr, "SwTxtAttr: where is my attribute?" );
152 return *m_pAttr;
155 inline SfxPoolItem& SwTxtAttr::GetAttr()
157 return const_cast<SfxPoolItem&>(
158 const_cast<const SwTxtAttr*>(this)->GetAttr());
161 inline void SwTxtAttr::SetDontExpand( bool bDontExpand )
163 if ( !m_bLockExpandFlag )
165 m_bDontExpand = bDontExpand;
169 //------------------------------------------------------------------------
171 inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const
173 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT,
174 "Wrong attribute" );
175 return (const SwFmtCharFmt&)(*m_pAttr);
178 inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const
180 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT,
181 "Wrong attribute" );
182 return (const SwFmtAutoFmt&)(*m_pAttr);
185 inline const SwFmtFld& SwTxtAttr::GetFld() const
187 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD,
188 "Wrong attribute" );
189 return (const SwFmtFld&)(*m_pAttr);
192 inline const SwFmtFtn& SwTxtAttr::GetFtn() const
194 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN, "Wrong attribute" );
195 return (const SwFmtFtn&)(*m_pAttr);
198 inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const
200 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT,
201 "Wrong attribute" );
202 return (const SwFmtFlyCnt&)(*m_pAttr);
205 inline const SwTOXMark& SwTxtAttr::GetTOXMark() const
207 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK,
208 "Wrong attribute" );
209 return (const SwTOXMark&)(*m_pAttr);
212 inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const
214 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK,
215 "Wrong attribute" );
216 return (const SwFmtRefMark&)(*m_pAttr);
219 inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const
221 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT,
222 "Wrong attribute" );
223 return (const SwFmtINetFmt&)(*m_pAttr);
226 inline const SwFmtRuby& SwTxtAttr::GetRuby() const
228 OSL_ENSURE( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY,
229 "Wrong attribute" );
230 return (const SwFmtRuby&)(*m_pAttr);
233 inline const SwFmtMeta& SwTxtAttr::GetMeta() const
235 OSL_ENSURE( m_pAttr && (m_pAttr->Which() == RES_TXTATR_META ||
236 m_pAttr->Which() == RES_TXTATR_METAFIELD),
237 "Wrong attribute" );
238 return (const SwFmtMeta&)(*m_pAttr);
241 #endif
243 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */