nss: upgrade to release 3.73
[LibreOffice.git] / include / editeng / lrspitem.hxx
blobb04944326407118bfd906dcd3c7aabe8062e61dd
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_LRSPITEM_HXX
20 #define INCLUDED_EDITENG_LRSPITEM_HXX
22 #include <svl/poolitem.hxx>
23 #include <editeng/editengdllapi.h>
26 // class SvxLRSpaceItem --------------------------------------------------
28 /* [Description]
30 Left/Right margin and first line indent
32 SvxLRSpaceItem offers two interfaces for views from the left margin and
33 first line indent. The get methods return the member, with the layout also
34 as expected: the left edge shifts to the negative first line indent to the
35 left. The SetTxt/Gettxt methods assume that the left side represents the
36 0 coordinate for the first line indent:
38 UI UI LAYOUT UI/TEXT UI/TEXT (Where?)
39 SetTextLeft SetTxtFirst GetLeft GetTextLeft GetTxtFirst (What?)
40 500 -500 0 500 -500 (How much?)
41 500 0 500 500 0
42 500 +500 500 500 +500
43 700 -500 200 700 -500
46 #define LRSPACE_TXTLEFT_VERSION (sal_uInt16(0x0002))
47 #define LRSPACE_NEGATIVE_VERSION (sal_uInt16(0x0004))
49 class EDITENG_DLLPUBLIC SvxLRSpaceItem final : public SfxPoolItem
51 tools::Long nTxtLeft; // We spend a sal_uInt16
52 tools::Long nLeftMargin; // nLeft or the negative first-line indent
53 tools::Long nRightMargin; // The unproblematic right edge
55 sal_uInt16 nPropFirstLineOffset, nPropLeftMargin, nPropRightMargin;
56 short nFirstLineOffset; // First-line indent _always_ relative to nTxtLeft
57 bool bAutoFirst; // Automatic calculation of the first line indent
58 bool bExplicitZeroMarginValRight;
59 bool bExplicitZeroMarginValLeft;
61 void AdjustLeft(); // nLeftMargin and nTxtLeft are being adjusted.
63 public:
65 static SfxPoolItem* CreateDefault();
67 explicit SvxLRSpaceItem( const sal_uInt16 nId );
68 SvxLRSpaceItem( const tools::Long nLeft, const tools::Long nRight,
69 const tools::Long nTLeft /*= 0*/, const short nOfset /*= 0*/,
70 const sal_uInt16 nId );
71 SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy function dichotomy
73 // "pure virtual Methods" from SfxPoolItem
74 virtual bool operator==( const SfxPoolItem& ) const override;
76 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
77 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
79 virtual bool GetPresentation( SfxItemPresentation ePres,
80 MapUnit eCoreMetric,
81 MapUnit ePresMetric,
82 OUString &rText, const IntlWrapper& ) const override;
84 virtual SvxLRSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override;
85 virtual void ScaleMetrics( tools::Long nMult, tools::Long nDiv ) override;
86 virtual bool HasMetrics() const override;
88 // The "layout interface":
89 inline void SetLeft ( const tools::Long nL, const sal_uInt16 nProp = 100 );
90 inline void SetRight( const tools::Long nR, const sal_uInt16 nProp = 100 );
92 // Query/direct setting of the absolute values
93 tools::Long GetLeft() const { return nLeftMargin; }
94 tools::Long GetRight() const { return nRightMargin;}
95 void SetLeftValue( const tools::Long nL ) { nTxtLeft = nLeftMargin = nL; }
96 void SetRightValue( const tools::Long nR ) { nRightMargin = nR; }
97 bool IsAutoFirst() const { return bAutoFirst; }
98 void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
100 bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; }
101 bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; }
102 void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; }
103 void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; }
104 sal_uInt16 GetPropLeft() const { return nPropLeftMargin; }
105 sal_uInt16 GetPropRight() const { return nPropRightMargin;}
107 // The UI/text interface:
108 inline void SetTextLeft( const tools::Long nL, const sal_uInt16 nProp = 100 );
109 tools::Long GetTextLeft() const { return nTxtLeft; }
111 inline void SetTextFirstLineOffset( const short nF, const sal_uInt16 nProp = 100 );
112 short GetTextFirstLineOffset() const { return nFirstLineOffset; }
113 void SetPropTextFirstLineOffset( const sal_uInt16 nProp )
114 { nPropFirstLineOffset = nProp; }
115 sal_uInt16 GetPropTextFirstLineOffset() const
116 { return nPropFirstLineOffset; }
117 void SetTextFirstLineOffsetValue( const short nValue )
118 { nFirstLineOffset = nValue; }
120 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
121 virtual boost::property_tree::ptree dumpAsJSON() const override;
124 inline void SvxLRSpaceItem::SetLeft( const tools::Long nL, const sal_uInt16 nProp )
126 nLeftMargin = (nL * nProp) / 100;
127 nTxtLeft = nLeftMargin;
128 nPropLeftMargin = nProp;
130 inline void SvxLRSpaceItem::SetRight( const tools::Long nR, const sal_uInt16 nProp )
132 if (0 == nR)
134 SetExplicitZeroMarginValRight(true);
136 nRightMargin = (nR * nProp) / 100;
137 nPropRightMargin = nProp;
139 inline void SvxLRSpaceItem::SetTextFirstLineOffset( const short nF,
140 const sal_uInt16 nProp )
142 nFirstLineOffset = short((tools::Long(nF) * nProp ) / 100);
143 nPropFirstLineOffset = nProp;
144 AdjustLeft();
147 inline void SvxLRSpaceItem::SetTextLeft( const tools::Long nL, const sal_uInt16 nProp )
149 if (0 == nL)
151 SetExplicitZeroMarginValLeft(true);
153 nTxtLeft = (nL * nProp) / 100;
154 nPropLeftMargin = nProp;
155 AdjustLeft();
158 #endif
160 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */