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_SW_INC_PARATR_HXX
20 #define INCLUDED_SW_INC_PARATR_HXX
21 #include <svl/eitem.hxx>
22 #include <svl/stritem.hxx>
24 #include "hintids.hxx"
26 #include "swatrset.hxx"
28 #include "charfmt.hxx"
29 #include <editeng/adjustitem.hxx>
30 #include <editeng/lspcitem.hxx>
31 #include <editeng/spltitem.hxx>
32 #include <editeng/widwitem.hxx>
33 #include <editeng/orphitem.hxx>
34 #include <editeng/tstpitem.hxx>
35 #include <editeng/hyphenzoneitem.hxx>
36 #include <editeng/scriptspaceitem.hxx>
37 #include <editeng/hngpnctitem.hxx>
38 #include <editeng/forbiddenruleitem.hxx>
39 #include <editeng/paravertalignitem.hxx>
40 #include <editeng/pgrditem.hxx>
41 #include <o3tl/typed_flags_set.hxx>
49 enum class ListLevelIndents
{ No
, FirstLine
, LeftMargin
};
51 class SW_DLLPUBLIC FormatDropDefiner
{
53 virtual ~FormatDropDefiner() {};
55 virtual void FormatDropNotify(const SwFormatDrop
&) =0;
61 template<> struct typed_flags
<sw::ListLevelIndents
> : is_typed_flags
<sw::ListLevelIndents
, 0x03> {};
64 /** If SwFormatDrop is a Client, it is the CharFormat that describes the font for the
65 DropCaps. If it is not a Client, formatting uses the CharFormat of the paragraph.
66 If the CharFormat is modified, this change is propagated to the paragraphs
67 via the Modify of SwFormatDrop. */
68 class SW_DLLPUBLIC SwFormatDrop final
: public SfxPoolItem
, public SwClient
70 sw::FormatDropDefiner
* m_pDefinedIn
; ///< TextNode or FormatColl that contains the CapDrops.
71 sal_uInt16 m_nDistance
; ///< Distance to beginning of text.
72 sal_uInt8 m_nLines
; ///< Line count.
73 sal_uInt8 m_nChars
; ///< Character count.
74 bool m_bWholeWord
; ///< First word with initials.
76 static SfxPoolItem
* CreateDefault();
79 virtual ~SwFormatDrop() override
;
81 // @@@ public copy ctor, but no copy assignment?
82 SwFormatDrop( const SwFormatDrop
& );
84 // @@@ public copy ctor, but no copy assignment?
85 SwFormatDrop
& operator= (const SwFormatDrop
&) = delete;
87 virtual void SwClientNotify(const SwModify
&, const SfxHint
&) override
91 m_pDefinedIn
->FormatDropNotify(*this);
96 /// "pure virtual methods" of SfxPoolItem
97 virtual bool operator==( const SfxPoolItem
& ) const override
;
98 virtual bool supportsHashCode() const override
{ return true; }
99 virtual size_t hashCode() const override
;
100 virtual SwFormatDrop
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
101 virtual bool GetPresentation( SfxItemPresentation ePres
,
105 const IntlWrapper
& rIntl
) const override
;
106 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
107 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
109 sal_uInt8
GetLines() const { return m_nLines
; }
110 void SetLines(sal_uInt8 n
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_nLines
= n
; }
112 sal_uInt8
GetChars() const { return m_nChars
; }
113 void SetChars(sal_uInt8 n
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_nChars
= n
; }
115 bool GetWholeWord() const { return m_bWholeWord
; }
116 void SetWholeWord(bool b
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_bWholeWord
= b
; }
118 sal_uInt16
GetDistance() const { return m_nDistance
; }
119 void SetDistance(sal_uInt16 n
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; m_nDistance
= n
; }
121 const SwCharFormat
*GetCharFormat() const { return static_cast<const SwCharFormat
*>(GetRegisteredIn()); }
122 SwCharFormat
*GetCharFormat() { return static_cast<SwCharFormat
*>(GetRegisteredIn()); }
123 void SetCharFormat( SwCharFormat
*pNew
);
124 /// Get information from Client.
125 virtual bool GetInfo( SwFindNearestNode
& ) const override
;
127 /// Get and set Modify pointer.
128 void ChgDefinedIn( const sw::FormatDropDefiner
* pDefiner
)
129 { m_pDefinedIn
= const_cast<sw::FormatDropDefiner
*>(pDefiner
); };
132 class SwRegisterItem final
: public SfxBoolItem
135 static SfxPoolItem
* CreateDefault();
137 inline SwRegisterItem( const bool bRegister
= false );
139 /// "pure virtual methods" of SfxPoolItem
140 virtual SwRegisterItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
141 virtual bool GetPresentation( SfxItemPresentation ePres
,
145 const IntlWrapper
& rIntl
) const override
;
148 inline SwRegisterItem::SwRegisterItem( const bool bRegister
) :
149 SfxBoolItem( RES_PARATR_REGISTER
, bRegister
)
152 class SW_DLLPUBLIC SwNumRuleItem final
: public SfxStringItem
155 static SfxPoolItem
* CreateDefault();
158 : SfxStringItem( RES_PARATR_NUMRULE
, OUString(), SfxItemType::SwNumRuleItemType
) {}
160 SwNumRuleItem( const OUString
& rRuleName
)
161 : SfxStringItem( RES_PARATR_NUMRULE
, rRuleName
, SfxItemType::SwNumRuleItemType
) {}
163 SwNumRuleItem(SwNumRuleItem
const &) = default; // SfxPoolItem copy function dichotomy
165 /// "pure virtual methods" of SfxPoolItem
166 virtual bool operator==( const SfxPoolItem
& ) const override
;
167 virtual SwNumRuleItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
168 // Marked as false since the SfxStringItem superclass supports hashing, but
169 // this class has not been checked for safety under hashing yet.
170 virtual bool supportsHashCode() const override
{ return false; }
171 virtual bool GetPresentation( SfxItemPresentation ePres
,
175 const IntlWrapper
& rIntl
) const override
;
177 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
178 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
180 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
183 class SwParaConnectBorderItem final
: public SfxBoolItem
187 inline SwParaConnectBorderItem( const bool bConnect
= true );
189 /// "pure virtual methods" of SfxPoolItem
190 virtual SwParaConnectBorderItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
191 virtual bool GetPresentation( SfxItemPresentation ePres
,
195 const IntlWrapper
& rIntl
) const override
;
198 inline SwParaConnectBorderItem::SwParaConnectBorderItem( const bool bConnect
) :
199 SfxBoolItem( RES_PARATR_CONNECT_BORDER
, bConnect
)
202 // Implementation of paragraph-attributes methods of SwAttrSet
203 inline const SvxLineSpacingItem
&SwAttrSet::GetLineSpacing(bool bInP
) const
204 { return Get( RES_PARATR_LINESPACING
,bInP
); }
205 inline const SvxAdjustItem
&SwAttrSet::GetAdjust(bool bInP
) const
206 { return Get( RES_PARATR_ADJUST
,bInP
); }
207 inline const SvxFormatSplitItem
&SwAttrSet::GetSplit(bool bInP
) const
208 { return Get( RES_PARATR_SPLIT
,bInP
); }
209 inline const SwRegisterItem
&SwAttrSet::GetRegister(bool bInP
) const
210 { return Get( RES_PARATR_REGISTER
,bInP
); }
211 inline const SvxWidowsItem
&SwAttrSet::GetWidows(bool bInP
) const
212 { return Get( RES_PARATR_WIDOWS
,bInP
); }
213 inline const SvxOrphansItem
&SwAttrSet::GetOrphans(bool bInP
) const
214 { return Get( RES_PARATR_ORPHANS
,bInP
); }
215 inline const SvxTabStopItem
&SwAttrSet::GetTabStops(bool bInP
) const
216 { return Get( RES_PARATR_TABSTOP
,bInP
); }
217 inline const SvxHyphenZoneItem
&SwAttrSet::GetHyphenZone(bool bInP
) const
218 { return Get(RES_PARATR_HYPHENZONE
,bInP
); }
219 inline const SwFormatDrop
&SwAttrSet::GetDrop(bool bInP
) const
220 { return Get(RES_PARATR_DROP
,bInP
); }
221 inline const SwNumRuleItem
&SwAttrSet::GetNumRule(bool bInP
) const
222 { return Get(RES_PARATR_NUMRULE
,bInP
); }
223 inline const SvxScriptSpaceItem
& SwAttrSet::GetScriptSpace(bool bInP
) const
224 { return Get(RES_PARATR_SCRIPTSPACE
,bInP
); }
225 inline const SvxHangingPunctuationItem
&SwAttrSet::GetHangingPunctuation(bool bInP
) const
226 { return Get(RES_PARATR_HANGINGPUNCTUATION
,bInP
); }
227 inline const SvxForbiddenRuleItem
&SwAttrSet::GetForbiddenRule(bool bInP
) const
228 { return Get(RES_PARATR_FORBIDDEN_RULES
, bInP
); }
229 inline const SvxParaVertAlignItem
&SwAttrSet::GetParaVertAlign(bool bInP
) const
230 { return Get( RES_PARATR_VERTALIGN
, bInP
); }
231 inline const SvxParaGridItem
&SwAttrSet::GetParaGrid(bool bInP
) const
232 { return Get( RES_PARATR_SNAPTOGRID
, bInP
); }
233 inline const SwParaConnectBorderItem
&SwAttrSet::GetParaConnectBorder(bool bInP
) const
234 { return Get( RES_PARATR_CONNECT_BORDER
, bInP
); }
236 // Implementation of paragraph-attributes methods of SwFormat
237 inline const SvxLineSpacingItem
&SwFormat::GetLineSpacing(bool bInP
) const
238 { return m_aSet
.GetLineSpacing(bInP
); }
239 inline const SvxTabStopItem
&SwFormat::GetTabStops(bool bInP
) const
240 { return m_aSet
.GetTabStops(bInP
); }
241 inline const SwFormatDrop
&SwFormat::GetDrop(bool bInP
) const
242 { return m_aSet
.GetDrop(bInP
); }
243 inline const SwNumRuleItem
&SwFormat::GetNumRule(bool bInP
) const
244 { return m_aSet
.GetNumRule(bInP
); }
248 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */