tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / include / editeng / tstpitem.hxx
blob840b294243f91133a9e35ce320f535c8caaf6d55
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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
37 private:
38 sal_Int32 nTabPos;
39 SvxTabAdjust eAdjustment;
40 sal_Unicode m_cDecimal;
41 sal_Unicode cFill;
43 void fillDecimal();
45 public:
46 SvxTabStop();
47 explicit SvxTabStop( const sal_Int32 nPos,
48 const SvxTabAdjust eAdjst = SvxTabAdjust::Left,
49 const sal_Unicode cDec = cDfltDecimalChar,
50 const sal_Unicode cFil = cDfltFillChar );
52 sal_Int32& GetTabPos() { return nTabPos; }
53 sal_Int32 GetTabPos() const { return nTabPos; }
55 SvxTabAdjust& GetAdjustment() { return eAdjustment; }
56 SvxTabAdjust GetAdjustment() const { return eAdjustment; }
58 sal_Unicode& GetDecimal() { return m_cDecimal; }
59 sal_Unicode GetDecimal() const { return m_cDecimal; }
61 sal_Unicode& GetFill() { return cFill; }
62 sal_Unicode GetFill() const { return cFill; }
64 bool operator==( const SvxTabStop& rTS ) const
66 return ( nTabPos == rTS.nTabPos &&
67 eAdjustment == rTS.eAdjustment &&
68 m_cDecimal == rTS.m_cDecimal &&
69 cFill == rTS.cFill );
71 bool operator!=( const SvxTabStop& rTS ) const
73 return !operator==(rTS);
75 // For the SortedArray:
76 bool operator <( const SvxTabStop& rTS ) const
77 { return nTabPos < rTS.nTabPos; }
79 void dumpAsXml(xmlTextWriterPtr pWriter) const;
82 // class SvxTabStopItem --------------------------------------------------
84 typedef o3tl::sorted_vector<SvxTabStop> SvxTabStopArr;
86 /* [Description]
88 This item describes a list of TabStops.
91 class EDITENG_DLLPUBLIC SvxTabStopItem final : public SfxPoolItem
93 SvxTabStopArr maTabStops;
94 /// Defines default tab width for tabs without dedicated tab stop in the paragraph.
95 sal_Int32 mnDefaultDistance = 0;
97 public:
98 static SfxPoolItem* CreateDefault();
100 explicit SvxTabStopItem( sal_uInt16 nWhich );
101 SvxTabStopItem( const sal_uInt16 nTabs,
102 const sal_uInt16 nDist,
103 const SvxTabAdjust eAdjst /*= SvxTabAdjust::Default*/,
104 sal_uInt16 nWhich );
106 // Returns index of the tab or TAB_NOTFOUND
107 sal_uInt16 GetPos( const SvxTabStop& rTab ) const;
109 // Returns index of the tab at nPos, or TAB_NOTFOUND
110 sal_uInt16 GetPos( const sal_Int32 nPos ) const;
111 void SetDefaultDistance(sal_Int32 nDefaultDistancenDefTabSize);
112 sal_Int32 GetDefaultDistance() const;
114 // unprivatized:
115 sal_uInt16 Count() const { return maTabStops.size(); }
116 bool Insert( const SvxTabStop& rTab );
117 void Insert( const SvxTabStopItem* pTabs );
118 void Remove( const sal_uInt16 nPos, const sal_uInt16 nLen = 1 )
119 { ASSERT_CHANGE_REFCOUNTED_ITEM; maTabStops.erase( maTabStops.begin() + nPos, maTabStops.begin() + nPos + nLen ); }
121 // Assignment operator, equality operator (caution: expensive!)
123 // this is already included in SfxPoolItem declaration
124 //int operator!=( const SvxTabStopItem& rTSI ) const
125 // { return !( operator==( rTSI ) ); }
127 const SvxTabStop& operator[]( const sal_uInt16 nPos ) const
128 { return maTabStops[nPos]; }
130 const SvxTabStop& At( const sal_uInt16 nPos ) const
132 return maTabStops[nPos];
135 // "pure virtual Methods" from SfxPoolItem
136 virtual bool operator==( const SfxPoolItem& ) const override;
137 virtual bool supportsHashCode() const override { return true; }
138 virtual size_t hashCode() const override final;
139 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
140 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
142 virtual bool GetPresentation( SfxItemPresentation ePres,
143 MapUnit eCoreMetric,
144 MapUnit ePresMetric,
145 OUString &rText, const IntlWrapper& ) const override;
147 virtual SvxTabStopItem* Clone( SfxItemPool *pPool = nullptr ) const override;
149 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
152 #endif
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */