/src/libreoffice/sw/inc/paratr.hxx
Line | Count | Source |
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_SW_INC_PARATR_HXX |
20 | | #define INCLUDED_SW_INC_PARATR_HXX |
21 | | #include <svl/eitem.hxx> |
22 | | #include <svl/stritem.hxx> |
23 | | #include "swdllapi.h" |
24 | | #include "hintids.hxx" |
25 | | #include "calbck.hxx" |
26 | | #include "swatrset.hxx" |
27 | | #include "format.hxx" |
28 | | #include "charfmt.hxx" |
29 | | #include <editeng/autodiritem.hxx> |
30 | | #include <editeng/adjustitem.hxx> |
31 | | #include <editeng/lspcitem.hxx> |
32 | | #include <editeng/spltitem.hxx> |
33 | | #include <editeng/widwitem.hxx> |
34 | | #include <editeng/orphitem.hxx> |
35 | | #include <editeng/tstpitem.hxx> |
36 | | #include <editeng/hyphenzoneitem.hxx> |
37 | | #include <editeng/scriptspaceitem.hxx> |
38 | | #include <editeng/hngpnctitem.hxx> |
39 | | #include <editeng/forbiddenruleitem.hxx> |
40 | | #include <editeng/paravertalignitem.hxx> |
41 | | #include <editeng/pgrditem.hxx> |
42 | | #include <o3tl/typed_flags_set.hxx> |
43 | | |
44 | | class SwFormatDrop; |
45 | | |
46 | | namespace sw { |
47 | | |
48 | | enum class ListLevelIndents { No, FirstLine, LeftMargin }; |
49 | | |
50 | | class SW_DLLPUBLIC FormatDropDefiner { |
51 | | protected: |
52 | 5.75M | virtual ~FormatDropDefiner() {}; |
53 | | public: |
54 | | virtual void FormatDropNotify(const SwFormatDrop&) =0; |
55 | | }; |
56 | | } |
57 | | |
58 | | namespace o3tl |
59 | | { |
60 | | template<> struct typed_flags<sw::ListLevelIndents> : is_typed_flags<sw::ListLevelIndents, 0x03> {}; |
61 | | } |
62 | | |
63 | | /** |
64 | | This pool item is in the item set of a text node, for the Drop Caps feature. |
65 | | |
66 | | Format -> Paragraph -> Drop Caps on the UI. |
67 | | |
68 | | If SwFormatDrop is a Client, it is the CharFormat that describes the font for the |
69 | | DropCaps. If it is not a Client, formatting uses the CharFormat of the paragraph. |
70 | | If the CharFormat is modified, this change is propagated to the paragraphs |
71 | | via the Modify of SwFormatDrop. */ |
72 | | class SW_DLLPUBLIC SwFormatDrop final : public SfxPoolItem, public SwClient |
73 | | { |
74 | | sw::FormatDropDefiner* m_pDefinedIn; ///< TextNode or FormatColl that contains the CapDrops. |
75 | | sal_uInt16 m_nDistance; ///< Distance to beginning of text. |
76 | | sal_uInt8 m_nLines; ///< Line count. |
77 | | sal_uInt8 m_nChars; ///< Character count. |
78 | | bool m_bWholeWord; ///< First word with initials. |
79 | | public: |
80 | | static SfxPoolItem* CreateDefault(); |
81 | | |
82 | | DECLARE_ITEM_TYPE_FUNCTION(SwFormatDrop) |
83 | | SwFormatDrop(); |
84 | | virtual ~SwFormatDrop() override; |
85 | | |
86 | | // @@@ public copy ctor, but no copy assignment? |
87 | | SwFormatDrop( const SwFormatDrop & ); |
88 | | private: |
89 | | // @@@ public copy ctor, but no copy assignment? |
90 | | SwFormatDrop & operator= (const SwFormatDrop &) = delete; |
91 | | |
92 | | virtual void SwClientNotify(const SwModify&, const SfxHint&) override |
93 | 251 | { |
94 | 251 | if (!m_pDefinedIn) |
95 | 205 | return; |
96 | 46 | m_pDefinedIn->FormatDropNotify(*this); |
97 | 46 | } |
98 | | |
99 | | public: |
100 | | |
101 | | /// "pure virtual methods" of SfxPoolItem |
102 | | virtual bool operator==( const SfxPoolItem& ) const override; |
103 | 0 | virtual bool supportsHashCode() const override { return true; } |
104 | | virtual size_t hashCode() const override; |
105 | | virtual SwFormatDrop* Clone( SfxItemPool* pPool = nullptr ) const override; |
106 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
107 | | MapUnit eCoreMetric, |
108 | | MapUnit ePresMetric, |
109 | | OUString &rText, |
110 | | const IntlWrapper& rIntl ) const override; |
111 | | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
112 | | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
113 | | |
114 | 367k | sal_uInt8 GetLines() const { return m_nLines; } |
115 | 1.44k | void SetLines(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nLines = n; } |
116 | | |
117 | 184k | sal_uInt8 GetChars() const { return m_nChars; } |
118 | 3.01k | void SetChars(sal_uInt8 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nChars = n; } |
119 | | |
120 | 182k | bool GetWholeWord() const { return m_bWholeWord; } |
121 | 1.02k | void SetWholeWord(bool b) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_bWholeWord = b; } |
122 | | |
123 | 182k | sal_uInt16 GetDistance() const { return m_nDistance; } |
124 | 1.02k | void SetDistance(sal_uInt16 n) { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nDistance = n; } |
125 | | |
126 | 183k | const SwCharFormat *GetCharFormat() const { return static_cast<const SwCharFormat*>(GetRegisteredIn()); } |
127 | 60.1k | SwCharFormat *GetCharFormat() { return static_cast<SwCharFormat*>(GetRegisteredIn()); } |
128 | | void SetCharFormat( SwCharFormat *pNew ); |
129 | | /// Get information from Client. |
130 | | virtual bool GetInfo( SwFindNearestNode& ) const override; |
131 | | |
132 | | /// Get and set Modify pointer. |
133 | | void ChgDefinedIn( const sw::FormatDropDefiner* pDefiner ) |
134 | 60.1k | { m_pDefinedIn = const_cast<sw::FormatDropDefiner*>(pDefiner); }; |
135 | | }; |
136 | | |
137 | | class SW_DLLPUBLIC SwRegisterItem final : public SfxBoolItem |
138 | | { |
139 | | public: |
140 | | static SfxPoolItem* CreateDefault(); |
141 | | DECLARE_ITEM_TYPE_FUNCTION(SwRegisterItem) |
142 | | inline SwRegisterItem( const bool bRegister = false ); |
143 | | |
144 | | /// "pure virtual methods" of SfxPoolItem |
145 | | virtual SwRegisterItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
146 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
147 | | MapUnit eCoreMetric, |
148 | | MapUnit ePresMetric, |
149 | | OUString &rText, |
150 | | const IntlWrapper& rIntl ) const override; |
151 | | }; |
152 | | |
153 | | inline SwRegisterItem::SwRegisterItem( const bool bRegister ) : |
154 | 200k | SfxBoolItem( RES_PARATR_REGISTER, bRegister ) |
155 | 200k | {} |
156 | | |
157 | | class SW_DLLPUBLIC SwNumRuleItem final : public SfxStringItem |
158 | | { |
159 | | public: |
160 | | static SfxPoolItem* CreateDefault(); |
161 | | DECLARE_ITEM_TYPE_FUNCTION(SwNumRuleItem) |
162 | | SwNumRuleItem() |
163 | 14.1k | : SfxStringItem( RES_PARATR_NUMRULE, OUString() ) {} |
164 | | |
165 | | SwNumRuleItem( const UIName& rRuleName ) |
166 | 250k | : SfxStringItem( RES_PARATR_NUMRULE, rRuleName.toString() ) {} |
167 | | |
168 | 524k | SwNumRuleItem(SwNumRuleItem const &) = default; // SfxPoolItem copy function dichotomy |
169 | | |
170 | | /// "pure virtual methods" of SfxPoolItem |
171 | | virtual SwNumRuleItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
172 | | // Marked as false since the SfxStringItem superclass supports hashing, but |
173 | | // this class has not been checked for safety under hashing yet. |
174 | 3 | virtual bool supportsHashCode() const override { return false; } |
175 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
176 | | MapUnit eCoreMetric, |
177 | | MapUnit ePresMetric, |
178 | | OUString &rText, |
179 | | const IntlWrapper& rIntl ) const override; |
180 | | |
181 | | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
182 | | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
183 | 26.2M | UIName GetValue() const { return UIName(SfxStringItem::GetValue()); } |
184 | | |
185 | | void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
186 | | }; |
187 | | |
188 | | class SwParaConnectBorderItem final : public SfxBoolItem |
189 | | { |
190 | | public: |
191 | | DECLARE_ITEM_TYPE_FUNCTION(SwParaConnectBorderItem) |
192 | | inline SwParaConnectBorderItem( const bool bConnect = true ); |
193 | | |
194 | | /// "pure virtual methods" of SfxPoolItem |
195 | | virtual SwParaConnectBorderItem* Clone( SfxItemPool *pPool = nullptr ) const override; |
196 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
197 | | MapUnit eCoreMetric, |
198 | | MapUnit ePresMetric, |
199 | | OUString &rText, |
200 | | const IntlWrapper& rIntl ) const override; |
201 | | }; |
202 | | |
203 | | inline SwParaConnectBorderItem::SwParaConnectBorderItem( const bool bConnect ) : |
204 | 1.72k | SfxBoolItem( RES_PARATR_CONNECT_BORDER, bConnect ) |
205 | 1.72k | {} |
206 | | |
207 | | // Implementation of paragraph-attributes methods of SwAttrSet |
208 | | inline const SvxLineSpacingItem &SwAttrSet::GetLineSpacing(bool bInP) const |
209 | 731k | { return Get( RES_PARATR_LINESPACING,bInP); } |
210 | | inline const SvxAdjustItem &SwAttrSet::GetAdjust(bool bInP) const |
211 | 1.88M | { return Get( RES_PARATR_ADJUST,bInP); } |
212 | | inline const SvxFormatSplitItem &SwAttrSet::GetSplit(bool bInP) const |
213 | 176k | { return Get( RES_PARATR_SPLIT,bInP); } |
214 | | inline const SwRegisterItem &SwAttrSet::GetRegister(bool bInP) const |
215 | 561k | { return Get( RES_PARATR_REGISTER,bInP); } |
216 | | inline const SvxWidowsItem &SwAttrSet::GetWidows(bool bInP) const |
217 | 162k | { return Get( RES_PARATR_WIDOWS,bInP); } |
218 | | inline const SvxOrphansItem &SwAttrSet::GetOrphans(bool bInP) const |
219 | 175k | { return Get( RES_PARATR_ORPHANS,bInP); } |
220 | | inline const SvxTabStopItem &SwAttrSet::GetTabStops(bool bInP) const |
221 | 530k | { return Get( RES_PARATR_TABSTOP,bInP); } |
222 | | inline const SvxHyphenZoneItem &SwAttrSet::GetHyphenZone(bool bInP) const |
223 | 426k | { return Get(RES_PARATR_HYPHENZONE,bInP); } |
224 | | inline const SwFormatDrop &SwAttrSet::GetDrop(bool bInP) const |
225 | 179k | { return Get(RES_PARATR_DROP,bInP); } |
226 | | inline const SwNumRuleItem &SwAttrSet::GetNumRule(bool bInP) const |
227 | 2.83M | { return Get(RES_PARATR_NUMRULE,bInP); } |
228 | | inline const SvxScriptSpaceItem& SwAttrSet::GetScriptSpace(bool bInP) const |
229 | 179k | { return Get(RES_PARATR_SCRIPTSPACE,bInP); } |
230 | | inline const SvxHangingPunctuationItem &SwAttrSet::GetHangingPunctuation(bool bInP) const |
231 | 179k | { return Get(RES_PARATR_HANGINGPUNCTUATION,bInP); } |
232 | | inline const SvxForbiddenRuleItem &SwAttrSet::GetForbiddenRule(bool bInP) const |
233 | 179k | { return Get(RES_PARATR_FORBIDDEN_RULES, bInP); } |
234 | | inline const SvxParaVertAlignItem &SwAttrSet::GetParaVertAlign(bool bInP) const |
235 | 510k | { return Get( RES_PARATR_VERTALIGN, bInP ); } |
236 | | inline const SvxParaGridItem &SwAttrSet::GetParaGrid(bool bInP) const |
237 | 524k | { return Get( RES_PARATR_SNAPTOGRID, bInP ); } |
238 | | inline const SwParaConnectBorderItem &SwAttrSet::GetParaConnectBorder(bool bInP) const |
239 | 64.8k | { return Get( RES_PARATR_CONNECT_BORDER, bInP ); } |
240 | | inline const SvxAutoFrameDirectionItem &SwAttrSet::GetAutoFrameDirection(bool bInP) const |
241 | 0 | { return Get( RES_PARATR_AUTOFRAMEDIR, bInP ); } |
242 | | |
243 | | // Implementation of paragraph-attributes methods of SwFormat |
244 | | inline const SvxLineSpacingItem &SwFormat::GetLineSpacing(bool bInP) const |
245 | 0 | { return m_aSet.GetLineSpacing(bInP); } |
246 | | inline const SvxTabStopItem &SwFormat::GetTabStops(bool bInP) const |
247 | 37 | { return m_aSet.GetTabStops(bInP); } |
248 | | inline const SwFormatDrop &SwFormat::GetDrop(bool bInP) const |
249 | 102 | { return m_aSet.GetDrop(bInP); } |
250 | | inline const SwNumRuleItem &SwFormat::GetNumRule(bool bInP) const |
251 | 2.83M | { return m_aSet.GetNumRule(bInP); } |
252 | | |
253 | | #endif |
254 | | |
255 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |