1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 INCLUDED_EDITENG_TSTPITEM_HXX
20 #define INCLUDED_EDITENG_TSTPITEM_HXX
22 #include <svl/poolitem.hxx>
23 #include <editeng/svxenum.hxx>
24 #include <editeng/editengdllapi.h>
25 #include <o3tl/sorted_vector.hxx>
27 // class SvxTabStop ------------------------------------------------------
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' '
35 class EDITENG_DLLPUBLIC SvxTabStop
40 SvxTabAdjust eAdjustment
;
41 mutable sal_Unicode m_cDecimal
;
44 void fillDecimal() const;
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
);
53 sal_Int32
& GetTabPos() { return nTabPos
; }
54 sal_Int32
GetTabPos() const { return nTabPos
; }
56 SvxTabAdjust
& GetAdjustment() { return eAdjustment
; }
57 SvxTabAdjust
GetAdjustment() const { return eAdjustment
; }
59 sal_Unicode
& GetDecimal() { fillDecimal(); return m_cDecimal
; }
60 sal_Unicode
GetDecimal() const { fillDecimal(); return m_cDecimal
; }
62 sal_Unicode
& GetFill() { return cFill
; }
63 sal_Unicode
GetFill() const { return cFill
; }
65 // the "old" operator==()
66 bool IsEqual( const SvxTabStop
& rTS
) const
68 return ( nTabPos
== rTS
.nTabPos
&&
69 eAdjustment
== rTS
.eAdjustment
&&
70 m_cDecimal
== rTS
.m_cDecimal
&&
74 // For the SortedArray:
75 bool operator <( const SvxTabStop
& rTS
) const
76 { return nTabPos
< rTS
.nTabPos
; }
78 SvxTabStop
& operator=( const SvxTabStop
& rTS
)
80 nTabPos
= rTS
.nTabPos
;
81 eAdjustment
= rTS
.eAdjustment
;
82 m_cDecimal
= rTS
.m_cDecimal
;
88 // class SvxTabStopItem --------------------------------------------------
90 typedef o3tl::sorted_vector
<SvxTabStop
> SvxTabStopArr
;
94 This item describes a list of TabStops.
97 class EDITENG_DLLPUBLIC SvxTabStopItem
: public SfxPoolItem
99 SvxTabStopArr maTabStops
;
102 static SfxPoolItem
* CreateDefault();
104 explicit SvxTabStopItem( sal_uInt16 nWhich
);
105 SvxTabStopItem( const sal_uInt16 nTabs
,
106 const sal_uInt16 nDist
,
107 const SvxTabAdjust eAdjst
/*= SvxTabAdjust::Default*/,
109 SvxTabStopItem( const SvxTabStopItem
& rTSI
);
111 // Returns index of the tab or TAB_NOTFOUND
112 sal_uInt16
GetPos( const SvxTabStop
& rTab
) const;
114 // Returns index of the tab at nPos, or TAB_NOTFOUND
115 sal_uInt16
GetPos( const sal_Int32 nPos
) const;
118 sal_uInt16
Count() const { return maTabStops
.size(); }
119 bool Insert( const SvxTabStop
& rTab
);
120 void Insert( const SvxTabStopItem
* pTabs
);
121 void Remove( const sal_uInt16 nPos
, const sal_uInt16 nLen
= 1 )
122 { maTabStops
.erase( maTabStops
.begin() + nPos
, maTabStops
.begin() + nPos
+ nLen
); }
124 // Assignment operator, equality operator (caution: expensive!)
125 SvxTabStopItem
& operator=( const SvxTabStopItem
& rTSI
);
127 // this is already included in SfxPoolItem declaration
128 //int operator!=( const SvxTabStopItem& rTSI ) const
129 // { return !( operator==( rTSI ) ); }
131 const SvxTabStop
& operator[]( const sal_uInt16 nPos
) const
132 { return maTabStops
[nPos
]; }
134 const SvxTabStop
& At( const sal_uInt16 nPos
) const
136 return maTabStops
[nPos
];
139 // "pure virtual Methods" from SfxPoolItem
140 virtual bool operator==( const SfxPoolItem
& ) const override
;
141 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
142 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
144 virtual bool GetPresentation( SfxItemPresentation ePres
,
147 OUString
&rText
, const IntlWrapper
* = nullptr ) const override
;
149 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
150 virtual SfxPoolItem
* Create( SvStream
&, sal_uInt16
) const override
;
151 virtual SvStream
& Store( SvStream
& , sal_uInt16 nItemVersion
) const override
;
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */