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 <swtypes.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>
46 #define DROP_WHOLEWORD ((sal_uInt16)0x0001)
48 /** If SwFormatDrop is a Client, it is the CharFormat that describes the font for the
49 DropCaps. If it is not a Client, formatting uses the CharFormat of the paragraph.
50 If the CharFormat is modified, this change is propagated to the paragraphs
51 via the Modify of SwFormatDrop. */
52 class SW_DLLPUBLIC SwFormatDrop
: public SfxPoolItem
, public SwClient
54 SwModify
* pDefinedIn
; /**< Modify-Object, that contains DropCaps.
55 Can only be TextFormatCollection/TextNode. */
56 sal_uInt16 nDistance
; ///< Distance to beginning of text.
57 sal_uInt8 nLines
; ///< Line count.
58 sal_uInt8 nChars
; ///< Character count.
59 bool bWholeWord
; ///< First word with initials.
61 static SfxPoolItem
* CreateDefault();
64 virtual ~SwFormatDrop() override
;
66 // @@@ public copy ctor, but no copy assignment?
67 SwFormatDrop( const SwFormatDrop
& );
69 // @@@ public copy ctor, but no copy assignment?
70 SwFormatDrop
& operator= (const SwFormatDrop
&) = delete;
73 virtual void Modify( const SfxPoolItem
*, const SfxPoolItem
* ) override
;
77 /// "pure virtual methods" of SfxPoolItem
78 virtual bool operator==( const SfxPoolItem
& ) const override
;
79 virtual SfxPoolItem
* Clone( SfxItemPool
* pPool
= nullptr ) const override
;
80 virtual bool GetPresentation( SfxItemPresentation ePres
,
84 const IntlWrapper
* pIntl
= nullptr) const override
;
85 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
86 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
88 sal_uInt8
GetLines() const { return nLines
; }
89 sal_uInt8
&GetLines() { return nLines
; }
91 sal_uInt8
GetChars() const { return nChars
; }
92 sal_uInt8
&GetChars() { return nChars
; }
94 bool GetWholeWord() const { return bWholeWord
; }
95 bool &GetWholeWord() { return bWholeWord
; }
97 sal_uInt16
GetDistance() const { return nDistance
; }
98 sal_uInt16
&GetDistance() { return nDistance
; }
100 const SwCharFormat
*GetCharFormat() const { return static_cast<const SwCharFormat
*>(GetRegisteredIn()); }
101 SwCharFormat
*GetCharFormat() { return static_cast<SwCharFormat
*>(GetRegisteredIn()); }
102 void SetCharFormat( SwCharFormat
*pNew
);
103 /// Get information from Client.
104 virtual bool GetInfo( SfxPoolItem
& ) const override
;
106 /// Get and set Modify pointer.
107 const SwModify
* GetDefinedIn() const { return pDefinedIn
; }
108 void ChgDefinedIn( const SwModify
* pNew
)
109 { pDefinedIn
= const_cast<SwModify
*>(pNew
); }
112 class SwRegisterItem
: public SfxBoolItem
115 static SfxPoolItem
* CreateDefault();
117 inline SwRegisterItem( const bool bRegister
= false );
119 /// @@@ public copy assignment, but no copy ctor?
120 inline SwRegisterItem
& operator=( const SwRegisterItem
& rRegister
);
122 /// "pure virtual methods" of SfxPoolItem
123 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
124 virtual bool GetPresentation( SfxItemPresentation ePres
,
128 const IntlWrapper
* pIntl
= nullptr ) const override
;
131 inline SwRegisterItem::SwRegisterItem( const bool bRegister
) :
132 SfxBoolItem( RES_PARATR_REGISTER
, bRegister
)
135 inline SwRegisterItem
& SwRegisterItem::operator=(
136 const SwRegisterItem
& rRegister
)
138 SetValue( rRegister
.GetValue() );
142 class SW_DLLPUBLIC SwNumRuleItem
: public SfxStringItem
145 static SfxPoolItem
* CreateDefault();
148 : SfxStringItem( RES_PARATR_NUMRULE
, OUString() ) {}
150 SwNumRuleItem( const OUString
& rRuleName
)
151 : SfxStringItem( RES_PARATR_NUMRULE
, rRuleName
) {}
153 SwNumRuleItem( const SwNumRuleItem
& rCpy
)
154 : SfxStringItem( RES_PARATR_NUMRULE
, rCpy
.GetValue() ) {}
156 SwNumRuleItem
& operator=( const SwNumRuleItem
& rCpy
)
157 { SetValue( rCpy
.GetValue() ); return *this; }
159 /// "pure virtual methods" of SfxPoolItem
160 virtual bool operator==( const SfxPoolItem
& ) const override
;
161 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
162 virtual bool GetPresentation( SfxItemPresentation ePres
,
166 const IntlWrapper
* pIntl
= nullptr ) const override
;
168 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
169 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
171 void dumpAsXml(struct _xmlTextWriter
* pWriter
) const override
;
174 class SwParaConnectBorderItem
: public SfxBoolItem
178 inline SwParaConnectBorderItem( const bool bConnect
= true );
180 /// @@@ public copy assignment, but no copy ctor?
181 inline SwParaConnectBorderItem
& operator=( const SwParaConnectBorderItem
& rConnect
);
183 /// "pure virtual methods" of SfxPoolItem
184 virtual SfxPoolItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
185 virtual bool GetPresentation( SfxItemPresentation ePres
,
189 const IntlWrapper
* pIntl
= nullptr ) const override
;
192 inline SwParaConnectBorderItem::SwParaConnectBorderItem( const bool bConnect
) :
193 SfxBoolItem( RES_PARATR_CONNECT_BORDER
, bConnect
)
196 inline SwParaConnectBorderItem
& SwParaConnectBorderItem::operator=(
197 const SwParaConnectBorderItem
& rConnect
)
199 SetValue( rConnect
.GetValue() );
203 // Implementation of paragraph-attributes methods of SwAttrSet
204 inline const SvxLineSpacingItem
&SwAttrSet::GetLineSpacing(bool bInP
) const
205 { return static_cast<const SvxLineSpacingItem
&>(Get( RES_PARATR_LINESPACING
,bInP
)); }
206 inline const SvxAdjustItem
&SwAttrSet::GetAdjust(bool bInP
) const
207 { return static_cast<const SvxAdjustItem
&>(Get( RES_PARATR_ADJUST
,bInP
)); }
208 inline const SvxFormatSplitItem
&SwAttrSet::GetSplit(bool bInP
) const
209 { return static_cast<const SvxFormatSplitItem
&>(Get( RES_PARATR_SPLIT
,bInP
)); }
210 inline const SwRegisterItem
&SwAttrSet::GetRegister(bool bInP
) const
211 { return static_cast<const SwRegisterItem
&>(Get( RES_PARATR_REGISTER
,bInP
)); }
212 inline const SvxWidowsItem
&SwAttrSet::GetWidows(bool bInP
) const
213 { return static_cast<const SvxWidowsItem
&>(Get( RES_PARATR_WIDOWS
,bInP
)); }
214 inline const SvxOrphansItem
&SwAttrSet::GetOrphans(bool bInP
) const
215 { return static_cast<const SvxOrphansItem
&>(Get( RES_PARATR_ORPHANS
,bInP
)); }
216 inline const SvxTabStopItem
&SwAttrSet::GetTabStops(bool bInP
) const
217 { return static_cast<const SvxTabStopItem
&>(Get( RES_PARATR_TABSTOP
,bInP
)); }
218 inline const SvxHyphenZoneItem
&SwAttrSet::GetHyphenZone(bool bInP
) const
219 { return static_cast<const SvxHyphenZoneItem
&>(Get(RES_PARATR_HYPHENZONE
,bInP
)); }
220 inline const SwFormatDrop
&SwAttrSet::GetDrop(bool bInP
) const
221 { return static_cast<const SwFormatDrop
&>(Get(RES_PARATR_DROP
,bInP
)); }
222 inline const SwNumRuleItem
&SwAttrSet::GetNumRule(bool bInP
) const
223 { return static_cast<const SwNumRuleItem
&>(Get(RES_PARATR_NUMRULE
,bInP
)); }
224 inline const SvxScriptSpaceItem
& SwAttrSet::GetScriptSpace(bool bInP
) const
225 { return static_cast<const SvxScriptSpaceItem
&>(Get(RES_PARATR_SCRIPTSPACE
,bInP
)); }
226 inline const SvxHangingPunctuationItem
&SwAttrSet::GetHangingPunctuation(bool bInP
) const
227 { return static_cast<const SvxHangingPunctuationItem
&>(Get(RES_PARATR_HANGINGPUNCTUATION
,bInP
)); }
228 inline const SvxForbiddenRuleItem
&SwAttrSet::GetForbiddenRule(bool bInP
) const
229 { return static_cast<const SvxForbiddenRuleItem
&>(Get(RES_PARATR_FORBIDDEN_RULES
, bInP
)); }
230 inline const SvxParaVertAlignItem
&SwAttrSet::GetParaVertAlign(bool bInP
) const
231 { return static_cast<const SvxParaVertAlignItem
&>(Get( RES_PARATR_VERTALIGN
, bInP
)); }
232 inline const SvxParaGridItem
&SwAttrSet::GetParaGrid(bool bInP
) const
233 { return static_cast<const SvxParaGridItem
&>(Get( RES_PARATR_SNAPTOGRID
, bInP
)); }
234 inline const SwParaConnectBorderItem
&SwAttrSet::GetParaConnectBorder(bool bInP
) const
235 { return static_cast<const SwParaConnectBorderItem
&>(Get( RES_PARATR_CONNECT_BORDER
, bInP
)); }
237 // Implementation of paragraph-attributes methods of SwFormat
238 inline const SvxLineSpacingItem
&SwFormat::GetLineSpacing(bool bInP
) const
239 { return m_aSet
.GetLineSpacing(bInP
); }
240 inline const SvxTabStopItem
&SwFormat::GetTabStops(bool bInP
) const
241 { return m_aSet
.GetTabStops(bInP
); }
242 inline const SwFormatDrop
&SwFormat::GetDrop(bool bInP
) const
243 { return m_aSet
.GetDrop(bInP
); }
244 inline const SwNumRuleItem
&SwFormat::GetNumRule(bool bInP
) const
245 { return m_aSet
.GetNumRule(bInP
); }
249 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */