tdf#130857 qt weld: Support mail merge "Server Auth" dialog
[LibreOffice.git] / include / editeng / lrspitem.hxx
blobf5b4d105405604e073218dcb7746e08bb9fe39bf
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>
24 #include <com/sun/star/util/MeasureUnit.hpp>
27 // class SvxLRSpaceItem --------------------------------------------------
29 /* [Description]
31 Left/Right margin and first line indent
33 SvxLRSpaceItem offers two interfaces to get the left margin and first line
34 indent.
35 - The Get* methods return the member in the way the layout used to expect:
36 with a negative first line indent, the left margin shifts to the left.
37 - The SetText*,GetText* methods assume that the left margin represents
38 the 0 coordinate for the first line indent:
40 UI UI LAYOUT UI/TEXT UI/TEXT (Where?)
41 SetTextLeft SetTextFirst GetLeft GetTextLeft GetTextFirst (What?)
42 500 -500 0 500 -500 (How much?)
43 500 0 500 500 0
44 500 +500 500 500 +500
45 700 -500 200 700 -500
48 class SvxFirstLineIndentItem;
50 /// helper struct used for resolving font-relative indentation
51 struct SvxFontUnitMetrics
53 double m_dEmTwips = 0.0;
54 double m_dIcTwips = 0.0;
55 bool m_bInitialized = false;
57 SvxFontUnitMetrics() = default;
58 SvxFontUnitMetrics(double dEmTwips, double dIcTwips)
59 : m_dEmTwips(dEmTwips)
60 , m_dIcTwips(dIcTwips)
61 , m_bInitialized(true)
66 /// helper struct for passing indentation along with units
67 struct SvxIndentValue
69 double m_dValue;
70 sal_Int16 m_nUnit;
72 SvxIndentValue() = delete;
73 SvxIndentValue(double dValue, sal_Int16 nUnit)
74 : m_dValue(dValue)
75 , m_nUnit(nUnit)
79 static SvxIndentValue twips(double dValue) { return { dValue, css::util::MeasureUnit::TWIP }; }
81 static SvxIndentValue zero() { return twips(0.0); }
83 double ResolveDouble(const SvxFontUnitMetrics& rMetrics) const;
84 sal_Int32 Resolve(const SvxFontUnitMetrics& rMetrics) const;
85 sal_Int32 ResolveFixedPart() const;
86 sal_Int32 ResolveVariablePart(const SvxFontUnitMetrics& rMetrics) const;
88 void ScaleMetrics(tools::Long nMult, tools::Long nDiv);
90 size_t hashCode() const;
91 bool operator==(SvxIndentValue const&) const = default;
94 /// GetLeft() - for everything that's not applied to a paragraph
95 class EDITENG_DLLPUBLIC SvxLeftMarginItem final : public SfxPoolItem
97 private:
98 /// left margin: nothing special
99 tools::Long m_nLeftMargin = 0;
100 sal_uInt16 m_nPropLeftMargin = 100;
102 public:
103 // The "layout interface":
104 void SetLeft(const tools::Long nL, const sal_uInt16 nProp = 100);
106 // Query/direct setting of the absolute values
107 tools::Long GetLeft() const { return m_nLeftMargin; }
109 sal_uInt16 GetPropLeft() const { return m_nPropLeftMargin; }
111 explicit SvxLeftMarginItem(const sal_uInt16 nId);
112 SvxLeftMarginItem(const tools::Long nLeft, const sal_uInt16 nId);
113 SvxLeftMarginItem(SvxLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
115 // "pure virtual Methods" from SfxPoolItem
116 virtual bool operator==(const SfxPoolItem&) const override;
118 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
119 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
121 virtual bool GetPresentation(SfxItemPresentation ePres,
122 MapUnit eCoreMetric,
123 MapUnit ePresMetric,
124 OUString &rText, const IntlWrapper&) const override;
126 virtual SvxLeftMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
127 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
128 virtual bool HasMetrics() const override;
130 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
131 virtual boost::property_tree::ptree dumpAsJSON() const override;
134 /// GetTextLeft() - for everything that's applied to a paragraph
135 class EDITENG_DLLPUBLIC SvxTextLeftMarginItem final : public SfxPoolItem
137 private:
138 friend class SvxFirstLineIndentItem;
139 /// left margin including negative first-line indent
140 SvxIndentValue m_stTextLeftMargin = SvxIndentValue::zero();
141 sal_uInt16 m_nPropLeftMargin = 100;
143 public:
144 /// get left margin without negative first-line indent
145 sal_Int32 ResolveLeft(const SvxFirstLineIndentItem& rFirstLine,
146 const SvxFontUnitMetrics& rMetrics) const;
147 sal_Int32 ResolveLeftFixedPart(const SvxFirstLineIndentItem& rFirstLine) const;
148 sal_Int32 ResolveLeftVariablePart(const SvxFirstLineIndentItem& rFirstLine,
149 const SvxFontUnitMetrics& rMetrics) const;
150 sal_uInt16 GetPropLeft() const;
152 void SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp = 100);
153 sal_Int32 ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const;
154 SvxIndentValue GetTextLeft() const;
156 explicit SvxTextLeftMarginItem(const sal_uInt16 nId);
157 SvxTextLeftMarginItem(SvxIndentValue stLeft, const sal_uInt16 nId);
158 SvxTextLeftMarginItem(SvxTextLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
160 // "pure virtual Methods" from SfxPoolItem
161 virtual bool operator==(const SfxPoolItem&) const override;
162 virtual bool supportsHashCode() const override { return true; }
163 virtual size_t hashCode() const override;
165 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
166 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
168 virtual bool GetPresentation(SfxItemPresentation ePres,
169 MapUnit eCoreMetric,
170 MapUnit ePresMetric,
171 OUString &rText, const IntlWrapper&) const override;
173 virtual SvxTextLeftMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
174 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
175 virtual bool HasMetrics() const override;
177 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
178 virtual boost::property_tree::ptree dumpAsJSON() const override;
181 /// first line indent that may be applied to paragraphs
182 class EDITENG_DLLPUBLIC SvxFirstLineIndentItem final : public SfxPoolItem
184 private:
185 /// First-line indent always relative to GetTextLeft()
186 SvxIndentValue m_stFirstLineOffset = SvxIndentValue::zero();
187 sal_uInt16 m_nPropFirstLineOffset = 100;
188 /// Automatic calculation of the first line indent
189 bool m_bAutoFirst = false;
191 public:
192 bool IsAutoFirst() const;
193 void SetAutoFirst(const bool bNew);
195 void SetPropTextFirstLineOffset(sal_uInt16 nProp);
196 sal_uInt16 GetPropTextFirstLineOffset() const;
198 void SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp = 100);
199 SvxIndentValue GetTextFirstLineOffset() const;
200 sal_Int32 ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const;
202 explicit SvxFirstLineIndentItem(const sal_uInt16 nId);
203 SvxFirstLineIndentItem(SvxIndentValue stValue, const sal_uInt16 nId);
204 SvxFirstLineIndentItem(SvxFirstLineIndentItem const &) = default; // SfxPoolItem copy function dichotomy
206 // "pure virtual Methods" from SfxPoolItem
207 virtual bool operator==(const SfxPoolItem&) const override;
208 virtual bool supportsHashCode() const override { return true; }
209 virtual size_t hashCode() const override;
211 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
212 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
214 virtual bool GetPresentation(SfxItemPresentation ePres,
215 MapUnit eCoreMetric,
216 MapUnit ePresMetric,
217 OUString &rText, const IntlWrapper&) const override;
219 virtual SvxFirstLineIndentItem* Clone(SfxItemPool *pPool = nullptr) const override;
220 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
221 virtual bool HasMetrics() const override;
223 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
224 virtual boost::property_tree::ptree dumpAsJSON() const override;
227 class EDITENG_DLLPUBLIC SvxRightMarginItem final : public SfxPoolItem
229 private:
230 /// right margin: nothing special
231 SvxIndentValue m_stRightMargin = SvxIndentValue::zero();
232 sal_uInt16 m_nPropRightMargin = 100;
234 public:
235 // The "layout interface":
236 void SetRight(SvxIndentValue stR, const sal_uInt16 nProp = 100);
238 // Query/direct setting of the absolute values
239 SvxIndentValue GetRight() const;
240 sal_Int32 ResolveRight(const SvxFontUnitMetrics& rMetrics) const;
241 sal_Int32 ResolveRightFixedPart() const;
242 sal_Int32 ResolveRightVariablePart(const SvxFontUnitMetrics& rMetrics) const;
244 sal_uInt16 GetPropRight() const;
246 explicit SvxRightMarginItem(const sal_uInt16 nId);
247 SvxRightMarginItem(SvxIndentValue stRight, const sal_uInt16 nId);
248 SvxRightMarginItem(SvxRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy
250 // "pure virtual Methods" from SfxPoolItem
251 virtual bool operator==(const SfxPoolItem&) const override;
252 virtual bool supportsHashCode() const override { return true; }
253 virtual size_t hashCode() const override;
255 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
256 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
258 virtual bool GetPresentation(SfxItemPresentation ePres,
259 MapUnit eCoreMetric,
260 MapUnit ePresMetric,
261 OUString &rText, const IntlWrapper&) const override;
263 virtual SvxRightMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
264 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
265 virtual bool HasMetrics() const override;
267 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
268 virtual boost::property_tree::ptree dumpAsJSON() const override;
271 /// gutter margin - for page styles
272 class EDITENG_DLLPUBLIC SvxGutterLeftMarginItem final : public SfxPoolItem
274 private:
275 /// The amount of extra space added to the left margin.
276 tools::Long m_nGutterMargin = 0;
278 public:
279 void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
280 tools::Long GetGutterMargin() const { return m_nGutterMargin; }
282 explicit SvxGutterLeftMarginItem(const sal_uInt16 nId);
283 SvxGutterLeftMarginItem(SvxGutterLeftMarginItem const &) = default; // SfxPoolItem copy function dichotomy
285 // "pure virtual Methods" from SfxPoolItem
286 virtual bool operator==(const SfxPoolItem&) const override;
288 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
289 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
291 virtual bool GetPresentation(SfxItemPresentation ePres,
292 MapUnit eCoreMetric,
293 MapUnit ePresMetric,
294 OUString &rText, const IntlWrapper&) const override;
296 virtual SvxGutterLeftMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
297 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
298 virtual bool HasMetrics() const override;
300 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
301 virtual boost::property_tree::ptree dumpAsJSON() const override;
304 /// gutter margin - for page styles
305 class EDITENG_DLLPUBLIC SvxGutterRightMarginItem final : public SfxPoolItem
307 private:
308 /// The amount of extra space added to the right margin, on mirrored pages.
309 tools::Long m_nRightGutterMargin = 0;
311 public:
312 tools::Long GetRightGutterMargin() const { return m_nRightGutterMargin; }
314 explicit SvxGutterRightMarginItem(const sal_uInt16 nId);
315 SvxGutterRightMarginItem(SvxGutterRightMarginItem const &) = default; // SfxPoolItem copy function dichotomy
317 // "pure virtual Methods" from SfxPoolItem
318 virtual bool operator==(const SfxPoolItem&) const override;
320 virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const override;
321 virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) override;
323 virtual bool GetPresentation(SfxItemPresentation ePres,
324 MapUnit eCoreMetric,
325 MapUnit ePresMetric,
326 OUString &rText, const IntlWrapper&) const override;
328 virtual SvxGutterRightMarginItem* Clone(SfxItemPool *pPool = nullptr) const override;
329 virtual void ScaleMetrics(tools::Long nMult, tools::Long nDiv) override;
330 virtual bool HasMetrics() const override;
332 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
333 virtual boost::property_tree::ptree dumpAsJSON() const override;
336 class EDITENG_DLLPUBLIC SvxLRSpaceItem final : public SfxPoolItem
338 /// First-line indent always relative to GetTextLeft()
339 SvxIndentValue m_stFirstLineOffset = SvxIndentValue::zero();
340 SvxIndentValue m_stLeftMargin
341 = SvxIndentValue::zero(); // nLeft or the negative first-line indent
342 SvxIndentValue m_stRightMargin = SvxIndentValue::zero();
343 /// The amount of extra space added to the left margin.
344 tools::Long m_nGutterMargin;
345 /// The amount of extra space added to the right margin, on mirrored pages.
346 tools::Long m_nRightGutterMargin;
348 sal_uInt16 nPropFirstLineOffset, nPropLeftMargin, nPropRightMargin;
349 bool bAutoFirst; // Automatic calculation of the first line indent
350 bool bExplicitZeroMarginValRight;
351 bool bExplicitZeroMarginValLeft;
353 public:
355 static SfxPoolItem* CreateDefault();
357 explicit SvxLRSpaceItem( const sal_uInt16 nId );
358 SvxLRSpaceItem(SvxIndentValue stLeft, SvxIndentValue stRight, SvxIndentValue stValue,
359 const sal_uInt16 nId);
360 SvxLRSpaceItem(SvxLRSpaceItem const &) = default; // SfxPoolItem copy function dichotomy
362 // "pure virtual Methods" from SfxPoolItem
363 virtual bool operator==( const SfxPoolItem& ) const override;
365 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
366 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
368 virtual bool GetPresentation( SfxItemPresentation ePres,
369 MapUnit eCoreMetric,
370 MapUnit ePresMetric,
371 OUString &rText, const IntlWrapper& ) const override;
373 virtual SvxLRSpaceItem* Clone( SfxItemPool *pPool = nullptr ) const override;
374 virtual void ScaleMetrics( tools::Long nMult, tools::Long nDiv ) override;
375 virtual bool HasMetrics() const override;
377 // The "layout interface":
378 void SetLeft(SvxIndentValue stL, const sal_uInt16 nProp = 100);
379 void SetRight(SvxIndentValue stR, const sal_uInt16 nProp = 100);
381 // Query/direct setting of the absolute values
382 SvxIndentValue GetLeft() const;
383 sal_Int32 ResolveLeft(const SvxFontUnitMetrics& rMetrics) const;
384 SvxIndentValue GetRight() const;
385 sal_Int32 ResolveRight(const SvxFontUnitMetrics& rMetrics) const;
386 bool IsAutoFirst() const { return bAutoFirst; }
387 void SetAutoFirst( const bool bNew ) { bAutoFirst = bNew; }
389 bool IsExplicitZeroMarginValRight() const { return bExplicitZeroMarginValRight; }
390 bool IsExplicitZeroMarginValLeft() const { return bExplicitZeroMarginValLeft; }
391 void SetExplicitZeroMarginValRight( const bool eR ) { bExplicitZeroMarginValRight = eR; }
392 void SetExplicitZeroMarginValLeft( const bool eL ) { bExplicitZeroMarginValLeft = eL; }
393 sal_uInt16 GetPropLeft() const { return nPropLeftMargin; }
394 sal_uInt16 GetPropRight() const { return nPropRightMargin;}
396 // The UI/text interface:
397 void SetTextLeft(SvxIndentValue stL, const sal_uInt16 nProp = 100);
398 SvxIndentValue GetTextLeft() const;
399 sal_Int32 ResolveTextLeft(const SvxFontUnitMetrics& rMetrics) const;
401 void SetTextFirstLineOffset(SvxIndentValue stValue, sal_uInt16 nProp = 100);
402 SvxIndentValue GetTextFirstLineOffset() const;
403 sal_Int32 ResolveTextFirstLineOffset(const SvxFontUnitMetrics& rMetrics) const;
405 void SetPropTextFirstLineOffset( const sal_uInt16 nProp )
406 { nPropFirstLineOffset = nProp; }
407 sal_uInt16 GetPropTextFirstLineOffset() const
408 { return nPropFirstLineOffset; }
409 void SetGutterMargin(const tools::Long nGutterMargin) { m_nGutterMargin = nGutterMargin; }
410 tools::Long GetGutterMargin() const { return m_nGutterMargin; }
411 void SetRightGutterMargin(const tools::Long nRightGutterMargin) { m_nRightGutterMargin = nRightGutterMargin; }
412 tools::Long GetRightGutterMargin() const { return m_nRightGutterMargin; }
414 void dumpAsXml(xmlTextWriterPtr pWriter) const override;
415 virtual boost::property_tree::ptree dumpAsJSON() const override;
418 #endif
420 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */