Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / editeng / lrspitem.hxx
blobedab3ef23d737a0f9dee2b35a2eaaab4f7447584
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 to get the left margin and first line
33 indent.
34 - The Get* methods return the member in the way the layout used to expect:
35 with a negative first line indent, the left margin shifts to the left.
36 - The SetText*,GetText* methods assume that the left margin represents
37 the 0 coordinate for the first line indent:
39 UI UI LAYOUT UI/TEXT UI/TEXT (Where?)
40 SetTextLeft SetTextFirst GetLeft GetTextLeft GetTextFirst (What?)
41 500 -500 0 500 -500 (How much?)
42 500 0 500 500 0
43 500 +500 500 500 +500
44 700 -500 200 700 -500
47 class SvxFirstLineIndentItem;
49 /// GetLeft() - for everything that's not applied to a paragraph
50 class EDITENG_DLLPUBLIC SvxLeftMarginItem final : public SfxPoolItem
52 private:
53 /// left margin: nothing special
54 tools::Long m_nLeftMargin = 0;
55 sal_uInt16 m_nPropLeftMargin = 100;
57 public:
58 // The "layout interface":
59 void SetLeft(const tools::Long nL, const sal_uInt16 nProp = 100);
61 // Query/direct setting of the absolute values
62 tools::Long GetLeft() const { return m_nLeftMargin; }
64 sal_uInt16 GetPropLeft() const { return m_nPropLeftMargin; }
66 explicit SvxLeftMarginItem(const sal_uInt16 nId);
67 SvxLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId);
68 SvxLeftMarginItem(SvxLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
70 // "pure virtual Methods" from SfxPoolItem
71 virtual bool operator==(const SfxPoolItem&) const override;
73 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
74 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
76 virtual bool GetPresentation(SfxItemPresentation ePres,
77 MapUnit eCoreMetric,
78 MapUnit ePresMetric,
79 OUString &rText, const IntlWrapper&) const override;
81 virtual SvxLeftMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
82 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
83 virtual bool HasMetrics() const override;
85 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
86 virtual boost::property_tree::ptree dumpAsJSON() const override;
89 /// GetTextLeft() - for everything that's applied to a paragraph
90 class EDITENG_DLLPUBLIC SvxTextLeftMarginItem final : public SfxPoolItem
92 private:
93 friend class SvxFirstLineIndentItem;
94 /// left margin including negative first-line indent
95 tools::Long m_nTextLeftMargin = 0;
96 sal_uInt16 m_nPropLeftMargin = 100;
98 public:
99 //TODO: need this?
100 //void SetLeft(SvxFirstLineIndentItem const& rFirstLine, const tools::Long nL, const sal_uInt16 nProp = 100);
101 /// get left margin without negative first-line indent
102 tools::Long GetLeft(SvxFirstLineIndentItem const& rFirstLine) const;
103 sal_uInt16 GetPropLeft() const { return m_nPropLeftMargin; }
105 void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp = 100);
106 tools::Long GetTextLeft() const;
108 explicit SvxTextLeftMarginItem(const sal_uInt16 nId);
109 SvxTextLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId);
110 SvxTextLeftMarginItem(SvxTextLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
112 // "pure virtual Methods" from SfxPoolItem
113 virtual bool operator==(const SfxPoolItem&) const override;
115 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
116 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
118 virtual bool GetPresentation(SfxItemPresentation ePres,
119 MapUnit eCoreMetric,
120 MapUnit ePresMetric,
121 OUString &rText, const IntlWrapper&) const override;
123 virtual SvxTextLeftMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
124 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
125 virtual bool HasMetrics() const override;
127 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
128 virtual boost::property_tree::ptree dumpAsJSON() const override;
131 /// first line indent that may be applied to paragraphs
132 class EDITENG_DLLPUBLIC SvxFirstLineIndentItem final : public SfxPoolItem
134 private:
135 /// First-line indent always relative to GetTextLeft()
136 short m_nFirstLineOffset = 0;
137 sal_uInt16 m_nPropFirstLineOffset = 100;
138 /// Automatic calculation of the first line indent
139 bool m_bAutoFirst = false;
141 public:
142 bool IsAutoFirst() const { return m_bAutoFirst; }
143 void SetAutoFirst(const bool bNew) { m_bAutoFirst = bNew; }
145 void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
146 short GetTextFirstLineOffset() const { return m_nFirstLineOffset; }
147 void SetPropTextFirstLineOffset(const sal_uInt16 nProp)
148 { m_nPropFirstLineOffset = nProp; }
149 sal_uInt16 GetPropTextFirstLineOffset() const
150 { return m_nPropFirstLineOffset; }
151 void SetTextFirstLineOffsetValue(const short nValue)
152 { m_nFirstLineOffset = nValue; }
154 explicit SvxFirstLineIndentItem(const sal_uInt16 nId);
155 SvxFirstLineIndentItem(const short nOffset, const sal_uInt16 nId);
156 SvxFirstLineIndentItem(SvxFirstLineIndentItem const &) = default; // SfxPoolItem copy function dichotomy
158 // "pure virtual Methods" from SfxPoolItem
159 virtual bool operator==(const SfxPoolItem&) const override;
161 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
162 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
164 virtual bool GetPresentation(SfxItemPresentation ePres,
165 MapUnit eCoreMetric,
166 MapUnit ePresMetric,
167 OUString &rText, const IntlWrapper&) const override;
169 virtual SvxFirstLineIndentItem* Clone(SfxItemPool *pPool = nullptr) const override;
170 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
171 virtual bool HasMetrics() const override;
173 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
174 virtual boost::property_tree::ptree dumpAsJSON() const override;
177 class EDITENG_DLLPUBLIC SvxRightMarginItem final : public SfxPoolItem
179 private:
180 /// right margin: nothing special
181 tools::Long m_nRightMargin = 0;
182 sal_uInt16 m_nPropRightMargin = 100;
184 public:
185 // The "layout interface":
186 void SetRight(const tools::Long nR, const sal_uInt16 nProp = 100);
188 // Query/direct setting of the absolute values
189 tools::Long GetRight() const { return m_nRightMargin;}
191 sal_uInt16 GetPropRight() const { return m_nPropRightMargin; }
193 explicit SvxRightMarginItem(const sal_uInt16 nId);
194 SvxRightMarginItem(const tools::Long nRight, const sal_uInt16 nId);
195 SvxRightMarginItem(SvxRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy
197 // "pure virtual Methods" from SfxPoolItem
198 virtual bool operator==(const SfxPoolItem&) const override;
200 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
201 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
203 virtual bool GetPresentation(SfxItemPresentation ePres,
204 MapUnit eCoreMetric,
205 MapUnit ePresMetric,
206 OUString &rText, const IntlWrapper&) const override;
208 virtual SvxRightMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
209 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
210 virtual bool HasMetrics() const override;
212 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
213 virtual boost::property_tree::ptree dumpAsJSON() const override;
216 /// gutter margin - for page styles
217 class EDITENG_DLLPUBLIC SvxGutterLeftMarginItem final : public SfxPoolItem
219 private:
220 /// The amount of extra space added to the left margin.
221 tools::Long m_nGutterMargin = 0;
223 public:
224 void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
225 tools::Long GetGutterMargin() const { return m_nGutterMargin; }
227 explicit SvxGutterLeftMarginItem(const sal_uInt16 nId);
228 SvxGutterLeftMarginItem(SvxGutterLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
230 // "pure virtual Methods" from SfxPoolItem
231 virtual bool operator==(const SfxPoolItem&) const override;
233 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
234 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
236 virtual bool GetPresentation(SfxItemPresentation ePres,
237 MapUnit eCoreMetric,
238 MapUnit ePresMetric,
239 OUString &rText, const IntlWrapper&) const override;
241 virtual SvxGutterLeftMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
242 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
243 virtual bool HasMetrics() const override;
245 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
246 virtual boost::property_tree::ptree dumpAsJSON() const override;
249 /// gutter margin - for page styles
250 class EDITENG_DLLPUBLIC SvxGutterRightMarginItem final : public SfxPoolItem
252 private:
253 /// The amount of extra space added to the right margin, on mirrored pages.
254 tools::Long m_nRightGutterMargin = 0;
256 public:
257 tools::Long GetRightGutterMargin() const { return m_nRightGutterMargin; }
259 explicit SvxGutterRightMarginItem(const sal_uInt16 nId);
260 SvxGutterRightMarginItem(SvxGutterRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy
262 // "pure virtual Methods" from SfxPoolItem
263 virtual bool operator==(const SfxPoolItem&) const override;
265 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
266 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
268 virtual bool GetPresentation(SfxItemPresentation ePres,
269 MapUnit eCoreMetric,
270 MapUnit ePresMetric,
271 OUString &rText, const IntlWrapper&) const override;
273 virtual SvxGutterRightMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
274 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
275 virtual bool HasMetrics() const override;
277 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
278 virtual boost::property_tree::ptree dumpAsJSON() const override;
281 class EDITENG_DLLPUBLIC SvxLRSpaceItem final : public SfxPoolItem
283 /// First-line indent always relative to GetTextLeft()
284 short nFirstLineOffset;
285 tools::Long nLeftMargin; // nLeft or the negative first-line indent
286 tools::Long nRightMargin; // The unproblematic right edge
287 /// The amount of extra space added to the left margin.
288 tools::Long m_nGutterMargin;
289 /// The amount of extra space added to the right margin, on mirrored pages.
290 tools::Long m_nRightGutterMargin;
292 sal_uInt16 nPropFirstLineOffset, nPropLeftMargin, nPropRightMargin;
293 bool bAutoFirst; // Automatic calculation of the first line indent
294 bool bExplicitZeroMarginValRight;
295 bool bExplicitZeroMarginValLeft;
297 public:
299 static SfxPoolItem* CreateDefault();
301 explicit SvxLRSpaceItem( const sal_uInt16 nId );
302 SvxLRSpaceItem( const tools::Long nLeft, const tools::Long nRight,
303 const short nOfset /*= 0*/,
304 const sal_uInt16 nId );
305 SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy function dichotomy
307 // "pure virtual Methods" from SfxPoolItem
308 virtual bool operator==( const SfxPoolItem& ) const override;
310 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
311 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
313 virtual bool GetPresentation( SfxItemPresentation ePres,
314 MapUnit eCoreMetric,
315 MapUnit ePresMetric,
316 OUString &rText, const IntlWrapper& ) const override;
318 virtual SvxLRSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override;
319 virtual void ScaleMetrics( tools::Long nMult, tools::Long nDiv ) override;
320 virtual bool HasMetrics() const override;
322 // The "layout interface":
323 void SetLeft (const tools::Long nL, const sal_uInt16 nProp = 100);
324 void SetRight(const tools::Long nR, const sal_uInt16 nProp = 100);
326 // Query/direct setting of the absolute values
327 tools::Long GetLeft() const { return nLeftMargin; }
328 tools::Long GetRight() const { return nRightMargin;}
329 void SetLeftValue( const tools::Long nL ) { assert(nFirstLineOffset == 0); nLeftMargin = nL; }
330 void SetRightValue( const tools::Long nR ) { nRightMargin = nR; }
331 bool IsAutoFirst() const { return bAutoFirst; }
332 void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
334 bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; }
335 bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; }
336 void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; }
337 void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; }
338 sal_uInt16 GetPropLeft() const { return nPropLeftMargin; }
339 sal_uInt16 GetPropRight() const { return nPropRightMargin;}
341 // The UI/text interface:
342 void SetTextLeft(const tools::Long nL, const sal_uInt16 nProp = 100);
343 tools::Long GetTextLeft() const;
345 void SetTextFirstLineOffset(const short nF, const sal_uInt16 nProp = 100);
346 short GetTextFirstLineOffset() const { return nFirstLineOffset; }
347 void SetPropTextFirstLineOffset( const sal_uInt16 nProp )
348 { nPropFirstLineOffset = nProp; }
349 sal_uInt16 GetPropTextFirstLineOffset() const
350 { return nPropFirstLineOffset; }
351 void SetTextFirstLineOffsetValue( const short nValue )
352 { nFirstLineOffset = nValue; }
353 void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
354 tools::Long GetGutterMargin() const { return m_nGutterMargin; }
355 void SetRightGutterMargin(const tools::Long nRightGutterMargin) { m_nRightGutterMargin = nRightGutterMargin; }
356 tools::Long GetRightGutterMargin() const { return m_nRightGutterMargin; }
358 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
359 virtual boost::property_tree::ptree dumpAsJSON() const override;
362 #endif
364 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */