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_EDITENG_ULSPITEM_HXX
20 #define INCLUDED_EDITENG_ULSPITEM_HXX
22 #include <svl/poolitem.hxx>
23 #include <editeng/editengdllapi.h>
26 // class SvxULSpaceItem --------------------------------------------------
30 This item describes the Upper- and Lower space of a page or paragraph.
33 class EDITENG_DLLPUBLIC SvxULSpaceItem final
: public SfxPoolItem
35 sal_uInt16 nUpper
; // Upper space
36 sal_uInt16 nLower
; // Lower space
37 bool bContext
; // Contextual spacing?
38 sal_uInt16 nPropUpper
, nPropLower
; // relative or absolute (=100%)
40 static SfxPoolItem
* CreateDefault();
42 explicit SvxULSpaceItem( const sal_uInt16 nId
);
43 SvxULSpaceItem( const sal_uInt16 nUp
, const sal_uInt16 nLow
,
44 const sal_uInt16 nId
);
46 // "pure virtual Methods" from SfxPoolItem
47 virtual bool operator==( const SfxPoolItem
& ) const override
;
48 virtual bool supportsHashCode() const override
{ return true; }
49 virtual size_t hashCode() const override
;
51 virtual bool QueryValue( css::uno::Any
& rVal
, sal_uInt8 nMemberId
= 0 ) const override
;
52 virtual bool PutValue( const css::uno::Any
& rVal
, sal_uInt8 nMemberId
) override
;
54 virtual bool GetPresentation( SfxItemPresentation ePres
,
57 OUString
&rText
, const IntlWrapper
& ) const override
;
59 virtual SvxULSpaceItem
* Clone( SfxItemPool
*pPool
= nullptr ) const override
;
60 virtual void ScaleMetrics( tools::Long nMult
, tools::Long nDiv
) override
;
61 virtual bool HasMetrics() const override
;
63 inline void SetUpper( const sal_uInt16 nU
, const sal_uInt16 nProp
= 100 );
64 inline void SetLower( const sal_uInt16 nL
, const sal_uInt16 nProp
= 100 );
66 void SetUpperValue( const sal_uInt16 nU
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; nUpper
= nU
; }
67 void SetLowerValue( const sal_uInt16 nL
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; nLower
= nL
; }
68 void SetContextValue( const bool bC
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; bContext
= bC
; }
69 void SetPropUpper( const sal_uInt16 nU
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; nPropUpper
= nU
; }
70 void SetPropLower( const sal_uInt16 nL
) { ASSERT_CHANGE_REFCOUNTED_ITEM
; nPropLower
= nL
; }
72 sal_uInt16
GetUpper() const { return nUpper
; }
73 sal_uInt16
GetLower() const { return nLower
; }
74 bool GetContext() const { return bContext
; }
75 sal_uInt16
GetPropUpper() const { return nPropUpper
; }
76 sal_uInt16
GetPropLower() const { return nPropLower
; }
78 void dumpAsXml(xmlTextWriterPtr pWriter
) const override
;
79 virtual boost::property_tree::ptree
dumpAsJSON() const override
;
82 inline void SvxULSpaceItem::SetUpper( const sal_uInt16 nU
, const sal_uInt16 nProp
)
84 ASSERT_CHANGE_REFCOUNTED_ITEM
;
85 nUpper
= sal_uInt16((sal_uInt32(nU
) * nProp
) / 100); nPropUpper
= nProp
;
87 inline void SvxULSpaceItem::SetLower( const sal_uInt16 nL
, const sal_uInt16 nProp
)
89 ASSERT_CHANGE_REFCOUNTED_ITEM
;
90 nLower
= sal_uInt16((sal_uInt32(nL
) * nProp
) / 100); nPropLower
= nProp
;
95 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */