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
39 SvxTabAdjust eAdjustment
;
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 bool operator==( const SvxTabStop
& rTS
) const
67 return ( nTabPos
== rTS
.nTabPos
&&
68 eAdjustment
== rTS
.eAdjustment
&&
69 m_cDecimal
== rTS
.m_cDecimal
&&
72 bool operator!=( const SvxTabStop
& rTS
) const
74 return !operator==(rTS
);
76 // For the SortedArray:
77 bool operator <( const SvxTabStop
& rTS
) const
78 { return nTabPos
< rTS
.nTabPos
; }
80 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
83 // class SvxTabStopItem --------------------------------------------------
85 typedef o3tl::sorted_vector
<SvxTabStop
> SvxTabStopArr
;
89 This item describes a list of TabStops.
92 class EDITENG_DLLPUBLIC SvxTabStopItem final
: public SfxPoolItem
94 SvxTabStopArr maTabStops
;
97 static SfxPoolItem
* CreateDefault();
99 explicit SvxTabStopItem( sal_uInt16 nWhich
);
100 SvxTabStopItem( const sal_uInt16 nTabs
,
101 const sal_uInt16 nDist
,
102 const SvxTabAdjust eAdjst
/*= SvxTabAdjust::Default*/,
105 // Returns index of the tab or TAB_NOTFOUND
106 sal_uInt16
GetPos( const SvxTabStop
& rTab
) const;
108 // Returns index of the tab at nPos, or TAB_NOTFOUND
109 sal_uInt16
GetPos( const sal_Int32 nPos
) const;
112 sal_uInt16
Count() const { return maTabStops
.size(); }
113 bool Insert( const SvxTabStop
& rTab
);
114 void Insert( const SvxTabStopItem
* pTabs
);
115 void Remove( const sal_uInt16 nPos
, const sal_uInt16 nLen
= 1 )
116 { maTabStops
.erase( maTabStops
.begin() + nPos
, maTabStops
.begin() + nPos
+ nLen
); }
118 // Assignment operator, equality operator (caution: expensive!)
120 // this is already included in SfxPoolItem declaration
121 //int operator!=( const SvxTabStopItem& rTSI ) const
122 // { return !( operator==( rTSI ) ); }
124 const SvxTabStop
& operator[]( const sal_uInt16 nPos
) const
125 { return maTabStops
[nPos
]; }
127 const SvxTabStop
& At( const sal_uInt16 nPos
) const
129 return maTabStops
[nPos
];
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
;
137 virtual bool GetPresentation( SfxItemPresentation ePres
,
140 OUString
&rText
, const IntlWrapper
& ) const override
;
142 virtual SvxTabStopItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
144 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
149 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */