Line data Source code
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 (sal_Unicode(0x00)) // Get from IntlWrapper
33 : #define cDfltFillChar (sal_Unicode(' '))
34 :
35 : class EDITENG_DLLPUBLIC SvxTabStop
36 : {
37 : private:
38 : sal_Int32 nTabPos;
39 :
40 : SvxTabAdjust eAdjustment;
41 : mutable sal_Unicode m_cDecimal;
42 : sal_Unicode cFill;
43 :
44 : EDITENG_DLLPRIVATE friend SvStream& WriteSvxTabStop( SvStream&, SvxTabStop& );
45 :
46 : void fillDecimal() const;
47 :
48 : public:
49 : SvxTabStop();
50 : explicit SvxTabStop( const sal_Int32 nPos,
51 : const SvxTabAdjust eAdjst = SVX_TAB_ADJUST_LEFT,
52 : const sal_Unicode cDec = cDfltDecimalChar,
53 : const sal_Unicode cFil = cDfltFillChar );
54 :
55 0 : sal_Int32& GetTabPos() { return nTabPos; }
56 0 : sal_Int32 GetTabPos() const { return nTabPos; }
57 :
58 0 : SvxTabAdjust& GetAdjustment() { return eAdjustment; }
59 0 : SvxTabAdjust GetAdjustment() const { return eAdjustment; }
60 :
61 0 : sal_Unicode& GetDecimal() { fillDecimal(); return m_cDecimal; }
62 0 : sal_Unicode GetDecimal() const { fillDecimal(); return m_cDecimal; }
63 :
64 0 : sal_Unicode& GetFill() { return cFill; }
65 0 : sal_Unicode GetFill() const { return cFill; }
66 :
67 : OUString GetValueString() const;
68 :
69 : // the "old" operator==()
70 0 : bool IsEqual( const SvxTabStop& rTS ) const
71 : {
72 0 : return ( nTabPos == rTS.nTabPos &&
73 0 : eAdjustment == rTS.eAdjustment &&
74 0 : m_cDecimal == rTS.m_cDecimal &&
75 0 : cFill == rTS.cFill );
76 : }
77 :
78 : // For the SortedArray:
79 : bool operator==( const SvxTabStop& rTS ) const
80 : { return nTabPos == rTS.nTabPos; }
81 0 : bool operator <( const SvxTabStop& rTS ) const
82 0 : { return nTabPos < rTS.nTabPos; }
83 :
84 0 : SvxTabStop& operator=( const SvxTabStop& rTS )
85 : {
86 0 : nTabPos = rTS.nTabPos;
87 0 : eAdjustment = rTS.eAdjustment;
88 0 : m_cDecimal = rTS.m_cDecimal;
89 0 : cFill = rTS.cFill;
90 0 : return *this;
91 : }
92 : };
93 :
94 : // class SvxTabStopItem --------------------------------------------------
95 :
96 : typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
97 :
98 : /* [Description]
99 :
100 : This item describes a list of TabStops.
101 : */
102 :
103 0 : class EDITENG_DLLPUBLIC SvxTabStopItem : public SfxPoolItem
104 : {
105 : SvxTabStopArr maTabStops;
106 :
107 : public:
108 : TYPEINFO_OVERRIDE();
109 :
110 : explicit SvxTabStopItem( sal_uInt16 nWhich );
111 : SvxTabStopItem( const sal_uInt16 nTabs,
112 : const sal_uInt16 nDist,
113 : const SvxTabAdjust eAdjst /*= SVX_TAB_ADJUST_DEFAULT*/,
114 : sal_uInt16 nWhich );
115 : SvxTabStopItem( const SvxTabStopItem& rTSI );
116 :
117 : // Returns index of the tab or TAB_NOTFOUND
118 : sal_uInt16 GetPos( const SvxTabStop& rTab ) const;
119 :
120 : // Returns index of the tab at nPos, or TAB_NOTFOUND
121 : sal_uInt16 GetPos( const sal_Int32 nPos ) const;
122 :
123 : // unprivatized:
124 0 : sal_uInt16 Count() const { return maTabStops.size(); }
125 : bool Insert( const SvxTabStop& rTab );
126 : void Insert( const SvxTabStopItem* pTabs, sal_uInt16 nStart = 0,
127 : sal_uInt16 nEnd = USHRT_MAX );
128 : void Remove( SvxTabStop& rTab )
129 : { maTabStops.erase( rTab ); }
130 0 : void Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
131 0 : { maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); }
132 :
133 : // Assignment operator, equality operator (caution: expensive!)
134 : SvxTabStopItem& operator=( const SvxTabStopItem& rTSI );
135 :
136 : // this is already included in SfxPoolItem declaration
137 : //int operator!=( const SvxTabStopItem& rTSI ) const
138 : // { return !( operator==( rTSI ) ); }
139 :
140 0 : const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
141 0 : { return maTabStops[nPos]; }
142 :
143 0 : const SvxTabStop& At( const sal_uInt16 nPos ) const
144 : {
145 0 : return maTabStops[nPos];
146 : }
147 :
148 : // "pure virtual Methods" from SfxPoolItem
149 : virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
150 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
151 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
152 :
153 : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
154 : SfxMapUnit eCoreMetric,
155 : SfxMapUnit ePresMetric,
156 : OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
157 :
158 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
159 : virtual SfxPoolItem* Create( SvStream&, sal_uInt16 ) const SAL_OVERRIDE;
160 : virtual SvStream& Store( SvStream& , sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
161 :
162 : };
163 :
164 : #endif
165 :
166 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|