11d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 31d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 41d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 51d2dbeb0SAndrew Rist * distributed with this work for additional information 61d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 71d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 81d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 91d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 101d2dbeb0SAndrew Rist * 111d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 121d2dbeb0SAndrew Rist * 131d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 141d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 151d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 161d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 171d2dbeb0SAndrew Rist * specific language governing permissions and limitations 181d2dbeb0SAndrew Rist * under the License. 191d2dbeb0SAndrew Rist * 201d2dbeb0SAndrew Rist *************************************************************/ 211d2dbeb0SAndrew Rist 221d2dbeb0SAndrew Rist 23cdf0e10cSrcweir #ifndef _TXATBASE_HXX 24cdf0e10cSrcweir #define _TXATBASE_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include <tools/solar.h> 27cdf0e10cSrcweir #include <svl/poolitem.hxx> 28cdf0e10cSrcweir #include <hintids.hxx> 29cdf0e10cSrcweir #include <errhdl.hxx> 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <boost/utility.hpp> 32cdf0e10cSrcweir 33cdf0e10cSrcweir 34cdf0e10cSrcweir class SfxItemPool; 35cdf0e10cSrcweir class SvXMLAttrContainerItem; 36cdf0e10cSrcweir class SwFmtRuby; 37cdf0e10cSrcweir class SwFmtCharFmt; 38cdf0e10cSrcweir class SwFmtAutoFmt; 39cdf0e10cSrcweir class SwFmtINetFmt; 40cdf0e10cSrcweir class SwFmtFld; 41cdf0e10cSrcweir class SwFmtFtn; 42cdf0e10cSrcweir class SwFmtFlyCnt; 43cdf0e10cSrcweir class SwTOXMark; 44cdf0e10cSrcweir class SwFmtRefMark; 45cdf0e10cSrcweir class SwFmtMeta; 46cdf0e10cSrcweir 47cdf0e10cSrcweir 48cdf0e10cSrcweir class SwTxtAttr : private boost::noncopyable 49cdf0e10cSrcweir { 50cdf0e10cSrcweir private: 51cdf0e10cSrcweir SfxPoolItem * const m_pAttr; 52cdf0e10cSrcweir xub_StrLen m_nStart; 53cdf0e10cSrcweir bool m_bDontExpand : 1; 54cdf0e10cSrcweir bool m_bLockExpandFlag : 1; 55cdf0e10cSrcweir 56cdf0e10cSrcweir bool m_bDontMoveAttr : 1; // refmarks, toxmarks 57cdf0e10cSrcweir bool m_bCharFmtAttr : 1; // charfmt, inet 58cdf0e10cSrcweir bool m_bOverlapAllowedAttr : 1; // refmarks, toxmarks 59cdf0e10cSrcweir bool m_bPriorityAttr : 1; // attribute has priority (redlining) 60cdf0e10cSrcweir bool m_bDontExpandStart : 1; // don't expand start at paragraph start (ruby) 61cdf0e10cSrcweir bool m_bNesting : 1; // SwTxtAttrNesting 62cdf0e10cSrcweir bool m_bHasDummyChar : 1; // without end + meta 63cdf0e10cSrcweir 64cdf0e10cSrcweir protected: 65cdf0e10cSrcweir SwTxtAttr( SfxPoolItem& rAttr, xub_StrLen nStart ); 66cdf0e10cSrcweir virtual ~SwTxtAttr(); 67cdf0e10cSrcweir 68cdf0e10cSrcweir void SetLockExpandFlag( bool bFlag ) { m_bLockExpandFlag = bFlag; } 69cdf0e10cSrcweir void SetDontMoveAttr( bool bFlag ) { m_bDontMoveAttr = bFlag; } 70cdf0e10cSrcweir void SetCharFmtAttr( bool bFlag ) { m_bCharFmtAttr = bFlag; } 71cdf0e10cSrcweir void SetOverlapAllowedAttr( bool bFlag ){ m_bOverlapAllowedAttr = bFlag; } 72cdf0e10cSrcweir void SetDontExpandStartAttr(bool bFlag) { m_bDontExpandStart = bFlag; } 73cdf0e10cSrcweir void SetNesting(const bool bFlag) { m_bNesting = bFlag; } 74cdf0e10cSrcweir void SetHasDummyChar(const bool bFlag) { m_bHasDummyChar = bFlag; } 75cdf0e10cSrcweir 76cdf0e10cSrcweir public: 77cdf0e10cSrcweir 78cdf0e10cSrcweir /// destroy instance 79cdf0e10cSrcweir static void Destroy( SwTxtAttr * pToDestroy, SfxItemPool& rPool ); 80cdf0e10cSrcweir 81cdf0e10cSrcweir /// start position 82cdf0e10cSrcweir xub_StrLen* GetStart() { return & m_nStart; } 83cdf0e10cSrcweir const xub_StrLen* GetStart() const { return & m_nStart; } 84cdf0e10cSrcweir 85cdf0e10cSrcweir /// end position 86cdf0e10cSrcweir virtual xub_StrLen* GetEnd(); 87cdf0e10cSrcweir inline const xub_StrLen* GetEnd() const; 88cdf0e10cSrcweir /// end (if available), else start 89cdf0e10cSrcweir inline const xub_StrLen* GetAnyEnd() const; 90cdf0e10cSrcweir 91cdf0e10cSrcweir inline void SetDontExpand( bool bDontExpand ); 92cdf0e10cSrcweir bool DontExpand() const { return m_bDontExpand; } 93cdf0e10cSrcweir bool IsLockExpandFlag() const { return m_bLockExpandFlag; } 94cdf0e10cSrcweir bool IsDontMoveAttr() const { return m_bDontMoveAttr; } 95cdf0e10cSrcweir bool IsCharFmtAttr() const { return m_bCharFmtAttr; } 96cdf0e10cSrcweir bool IsOverlapAllowedAttr() const { return m_bOverlapAllowedAttr; } 97cdf0e10cSrcweir bool IsPriorityAttr() const { return m_bPriorityAttr; } 98cdf0e10cSrcweir void SetPriorityAttr( bool bFlag ) { m_bPriorityAttr = bFlag; } 99cdf0e10cSrcweir bool IsDontExpandStartAttr() const { return m_bDontExpandStart; } 100cdf0e10cSrcweir bool IsNesting() const { return m_bNesting; } 101cdf0e10cSrcweir bool HasDummyChar() const { return m_bHasDummyChar; } 102cdf0e10cSrcweir 103cdf0e10cSrcweir inline const SfxPoolItem& GetAttr() const; 104cdf0e10cSrcweir inline SfxPoolItem& GetAttr(); 105cdf0e10cSrcweir inline sal_uInt16 Which() const { return GetAttr().Which(); } 106cdf0e10cSrcweir 107cdf0e10cSrcweir virtual int operator==( const SwTxtAttr& ) const; 108cdf0e10cSrcweir 109cdf0e10cSrcweir inline const SwFmtCharFmt &GetCharFmt() const; 110cdf0e10cSrcweir inline const SwFmtAutoFmt &GetAutoFmt() const; 111*c0286415SOliver-Rainer Wittmann inline const SwFmtFld &GetFmtFld() const; 112cdf0e10cSrcweir inline const SwFmtFtn &GetFtn() const; 113cdf0e10cSrcweir inline const SwFmtFlyCnt &GetFlyCnt() const; 114cdf0e10cSrcweir inline const SwTOXMark &GetTOXMark() const; 115cdf0e10cSrcweir inline const SwFmtRefMark &GetRefMark() const; 116cdf0e10cSrcweir inline const SwFmtINetFmt &GetINetFmt() const; 117cdf0e10cSrcweir inline const SwFmtRuby &GetRuby() const; 118cdf0e10cSrcweir inline const SwFmtMeta &GetMeta() const; 119cdf0e10cSrcweir 120cdf0e10cSrcweir }; 121cdf0e10cSrcweir 122cdf0e10cSrcweir class SwTxtAttrEnd : public SwTxtAttr 123cdf0e10cSrcweir { 124cdf0e10cSrcweir protected: 125cdf0e10cSrcweir xub_StrLen m_nEnd; 126cdf0e10cSrcweir 127cdf0e10cSrcweir public: 128cdf0e10cSrcweir SwTxtAttrEnd( SfxPoolItem& rAttr, sal_uInt16 nStart, sal_uInt16 nEnd ); 129cdf0e10cSrcweir 130cdf0e10cSrcweir using SwTxtAttr::GetEnd; 131cdf0e10cSrcweir virtual xub_StrLen* GetEnd(); 132cdf0e10cSrcweir }; 133cdf0e10cSrcweir 134cdf0e10cSrcweir 135cdf0e10cSrcweir // --------------- Inline Implementierungen ------------------------ 136cdf0e10cSrcweir 137cdf0e10cSrcweir inline const xub_StrLen* SwTxtAttr::GetEnd() const 138cdf0e10cSrcweir { 139cdf0e10cSrcweir return const_cast<SwTxtAttr * >(this)->GetEnd(); 140cdf0e10cSrcweir } 141cdf0e10cSrcweir 142cdf0e10cSrcweir inline const xub_StrLen* SwTxtAttr::GetAnyEnd() const 143cdf0e10cSrcweir { 144cdf0e10cSrcweir const xub_StrLen* pEnd = GetEnd(); 145cdf0e10cSrcweir return pEnd ? pEnd : GetStart(); 146cdf0e10cSrcweir } 147cdf0e10cSrcweir 148cdf0e10cSrcweir inline const SfxPoolItem& SwTxtAttr::GetAttr() const 149cdf0e10cSrcweir { 150cdf0e10cSrcweir ASSERT( m_pAttr, "SwTxtAttr: where is my attribute?" ); 151cdf0e10cSrcweir return *m_pAttr; 152cdf0e10cSrcweir } 153cdf0e10cSrcweir 154cdf0e10cSrcweir inline SfxPoolItem& SwTxtAttr::GetAttr() 155cdf0e10cSrcweir { 156cdf0e10cSrcweir return const_cast<SfxPoolItem&>( 157cdf0e10cSrcweir const_cast<const SwTxtAttr*>(this)->GetAttr()); 158cdf0e10cSrcweir } 159cdf0e10cSrcweir 160cdf0e10cSrcweir inline void SwTxtAttr::SetDontExpand( bool bDontExpand ) 161cdf0e10cSrcweir { 162cdf0e10cSrcweir if ( !m_bLockExpandFlag ) 163cdf0e10cSrcweir { 164cdf0e10cSrcweir m_bDontExpand = bDontExpand; 165cdf0e10cSrcweir } 166cdf0e10cSrcweir } 167cdf0e10cSrcweir 168cdf0e10cSrcweir //------------------------------------------------------------------------ 169cdf0e10cSrcweir 170cdf0e10cSrcweir inline const SwFmtCharFmt& SwTxtAttr::GetCharFmt() const 171cdf0e10cSrcweir { 172cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CHARFMT, 173cdf0e10cSrcweir "Wrong attribute" ); 174cdf0e10cSrcweir return (const SwFmtCharFmt&)(*m_pAttr); 175cdf0e10cSrcweir } 176cdf0e10cSrcweir 177cdf0e10cSrcweir inline const SwFmtAutoFmt& SwTxtAttr::GetAutoFmt() const 178cdf0e10cSrcweir { 179cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_AUTOFMT, 180cdf0e10cSrcweir "Wrong attribute" ); 181cdf0e10cSrcweir return (const SwFmtAutoFmt&)(*m_pAttr); 182cdf0e10cSrcweir } 183cdf0e10cSrcweir 184*c0286415SOliver-Rainer Wittmann inline const SwFmtFld& SwTxtAttr::GetFmtFld() const 185cdf0e10cSrcweir { 186cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FIELD, 187cdf0e10cSrcweir "Wrong attribute" ); 188cdf0e10cSrcweir return (const SwFmtFld&)(*m_pAttr); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir 191cdf0e10cSrcweir inline const SwFmtFtn& SwTxtAttr::GetFtn() const 192cdf0e10cSrcweir { 193cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FTN, "Wrong attribute" ); 194cdf0e10cSrcweir return (const SwFmtFtn&)(*m_pAttr); 195cdf0e10cSrcweir } 196cdf0e10cSrcweir 197cdf0e10cSrcweir inline const SwFmtFlyCnt& SwTxtAttr::GetFlyCnt() const 198cdf0e10cSrcweir { 199cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_FLYCNT, 200cdf0e10cSrcweir "Wrong attribute" ); 201cdf0e10cSrcweir return (const SwFmtFlyCnt&)(*m_pAttr); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir inline const SwTOXMark& SwTxtAttr::GetTOXMark() const 205cdf0e10cSrcweir { 206cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_TOXMARK, 207cdf0e10cSrcweir "Wrong attribute" ); 208cdf0e10cSrcweir return (const SwTOXMark&)(*m_pAttr); 209cdf0e10cSrcweir } 210cdf0e10cSrcweir 211cdf0e10cSrcweir inline const SwFmtRefMark& SwTxtAttr::GetRefMark() const 212cdf0e10cSrcweir { 213cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_REFMARK, 214cdf0e10cSrcweir "Wrong attribute" ); 215cdf0e10cSrcweir return (const SwFmtRefMark&)(*m_pAttr); 216cdf0e10cSrcweir } 217cdf0e10cSrcweir 218cdf0e10cSrcweir inline const SwFmtINetFmt& SwTxtAttr::GetINetFmt() const 219cdf0e10cSrcweir { 220cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_INETFMT, 221cdf0e10cSrcweir "Wrong attribute" ); 222cdf0e10cSrcweir return (const SwFmtINetFmt&)(*m_pAttr); 223cdf0e10cSrcweir } 224cdf0e10cSrcweir 225cdf0e10cSrcweir inline const SwFmtRuby& SwTxtAttr::GetRuby() const 226cdf0e10cSrcweir { 227cdf0e10cSrcweir ASSERT( m_pAttr && m_pAttr->Which() == RES_TXTATR_CJK_RUBY, 228cdf0e10cSrcweir "Wrong attribute" ); 229cdf0e10cSrcweir return (const SwFmtRuby&)(*m_pAttr); 230cdf0e10cSrcweir } 231cdf0e10cSrcweir 232cdf0e10cSrcweir inline const SwFmtMeta& SwTxtAttr::GetMeta() const 233cdf0e10cSrcweir { 234cdf0e10cSrcweir ASSERT( m_pAttr && (m_pAttr->Which() == RES_TXTATR_META || 235cdf0e10cSrcweir m_pAttr->Which() == RES_TXTATR_METAFIELD), 236cdf0e10cSrcweir "Wrong attribute" ); 237cdf0e10cSrcweir return (const SwFmtMeta&)(*m_pAttr); 238cdf0e10cSrcweir } 239cdf0e10cSrcweir 240cdf0e10cSrcweir #endif 241