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 #ifndef INCLUDED_EDITENG_TSTPITEM_HXX 20 #define INCLUDED_EDITENG_TSTPITEM_HXX 21 22 #include <svl/poolitem.hxx> 23 #include <editeng/svxenum.hxx> 24 #include <editeng/editengdllapi.h> 25 #include <o3tl/sorted_vector.hxx> 26 27 // class SvxTabStop ------------------------------------------------------ 28 29 #define SVX_TAB_DEFCOUNT 10 30 #define SVX_TAB_DEFDIST 1134 // 2cm in twips 31 #define SVX_TAB_NOTFOUND USHRT_MAX 32 #define cDfltDecimalChar u'\0' // Get from IntlWrapper 33 #define cDfltFillChar u' ' 34 35 class EDITENG_DLLPUBLIC SvxTabStop 36 { 37 private: 38 sal_Int32 nTabPos; 39 SvxTabAdjust eAdjustment; 40 mutable sal_Unicode 41 m_cDecimal; 42 sal_Unicode cFill; 43 44 void fillDecimal() const; 45 46 public: 47 SvxTabStop(); 48 explicit SvxTabStop( const sal_Int32 nPos, 49 const SvxTabAdjust eAdjst = SvxTabAdjust::Left, 50 const sal_Unicode cDec = cDfltDecimalChar, 51 const sal_Unicode cFil = cDfltFillChar ); 52 GetTabPos()53 sal_Int32& GetTabPos() { return nTabPos; } GetTabPos() const54 sal_Int32 GetTabPos() const { return nTabPos; } 55 GetAdjustment()56 SvxTabAdjust& GetAdjustment() { return eAdjustment; } GetAdjustment() const57 SvxTabAdjust GetAdjustment() const { return eAdjustment; } 58 GetDecimal()59 sal_Unicode& GetDecimal() { fillDecimal(); return m_cDecimal; } GetDecimal() const60 sal_Unicode GetDecimal() const { fillDecimal(); return m_cDecimal; } 61 GetFill()62 sal_Unicode& GetFill() { return cFill; } GetFill() const63 sal_Unicode GetFill() const { return cFill; } 64 operator ==(const SvxTabStop & rTS) const65 bool operator==( const SvxTabStop& rTS ) const 66 { 67 return ( nTabPos == rTS.nTabPos && 68 eAdjustment == rTS.eAdjustment && 69 m_cDecimal == rTS.m_cDecimal && 70 cFill == rTS.cFill ); 71 } operator !=(const SvxTabStop & rTS) const72 bool operator!=( const SvxTabStop& rTS ) const 73 { 74 return !operator==(rTS); 75 } 76 // For the SortedArray: operator <(const SvxTabStop & rTS) const77 bool operator <( const SvxTabStop& rTS ) const 78 { return nTabPos < rTS.nTabPos; } 79 80 void dumpAsXml(xmlTextWriterPtr pWriter) const; 81 }; 82 83 // class SvxTabStopItem -------------------------------------------------- 84 85 typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr; 86 87 /* [Description] 88 89 This item describes a list of TabStops. 90 */ 91 92 class EDITENG_DLLPUBLIC SvxTabStopItem final : public SfxPoolItem 93 { 94 SvxTabStopArr maTabStops; 95 96 public: 97 static SfxPoolItem* CreateDefault(); 98 99 explicit SvxTabStopItem( sal_uInt16 nWhich ); 100 SvxTabStopItem( const sal_uInt16 nTabs, 101 const sal_uInt16 nDist, 102 const SvxTabAdjust eAdjst /*= SvxTabAdjust::Default*/, 103 sal_uInt16 nWhich ); 104 105 // Returns index of the tab or TAB_NOTFOUND 106 sal_uInt16 GetPos( const SvxTabStop& rTab ) const; 107 108 // Returns index of the tab at nPos, or TAB_NOTFOUND 109 sal_uInt16 GetPos( const sal_Int32 nPos ) const; 110 111 // unprivatized: Count() const112 sal_uInt16 Count() const { return maTabStops.size(); } 113 bool Insert( const SvxTabStop& rTab ); 114 void Insert( const SvxTabStopItem* pTabs ); Remove(const sal_uInt16 nPos,const sal_uInt16 nLen=1)115 void Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 ) 116 { maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); } 117 118 // Assignment operator, equality operator (caution: expensive!) 119 120 // this is already included in SfxPoolItem declaration 121 //int operator!=( const SvxTabStopItem& rTSI ) const 122 // { return !( operator==( rTSI ) ); } 123 operator [](const sal_uInt16 nPos) const124 const SvxTabStop& operator[]( const sal_uInt16 nPos ) const 125 { return maTabStops[nPos]; } 126 At(const sal_uInt16 nPos) const127 const SvxTabStop& At( const sal_uInt16 nPos ) const 128 { 129 return maTabStops[nPos]; 130 } 131 132 // "pure virtual Methods" from SfxPoolItem 133 virtual bool operator==( const SfxPoolItem& ) const override; 134 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; 135 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; 136 137 virtual bool GetPresentation( SfxItemPresentation ePres, 138 MapUnit eCoreMetric, 139 MapUnit ePresMetric, 140 OUString &rText, const IntlWrapper& ) const override; 141 142 virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override; 143 144 void dumpAsXml(xmlTextWriterPtr pWriter) const override; 145 }; 146 147 #endif 148 149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 150