/src/libreoffice/sw/inc/fmtfsize.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
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/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
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 . |
18 | | */ |
19 | | #ifndef INCLUDED_SW_INC_FMTFSIZE_HXX |
20 | | #define INCLUDED_SW_INC_FMTFSIZE_HXX |
21 | | |
22 | | #include <sal/config.h> |
23 | | |
24 | | #include <editeng/sizeitem.hxx> |
25 | | #include <svl/poolitem.hxx> |
26 | | #include "swdllapi.h" |
27 | | #include "hintids.hxx" |
28 | | #include "swtypes.hxx" |
29 | | #include "format.hxx" |
30 | | |
31 | | //Frame size. |
32 | | |
33 | | enum class SwFrameSize |
34 | | { |
35 | | Variable, ///< Frame is variable in Var-direction. |
36 | | Fixed, ///< Frame cannot be moved in Var-direction. |
37 | | Minimum /**< Value in Var-direction gives minimum |
38 | | (can be exceeded but not be less). */ |
39 | | }; |
40 | | |
41 | | /** |
42 | | * Describes the size of a Writer frame, for example a table, table row, table cell, TextFrame, |
43 | | * page, etc. |
44 | | * |
45 | | * The height and width can be either relative or absolute, see SwFrameSize. |
46 | | * |
47 | | * If the size is relative, then the "relation" decides what 100% means, e.g. it may be relative to |
48 | | * the page size of the parent frame size. |
49 | | */ |
50 | | class SW_DLLPUBLIC SwFormatFrameSize final : public SvxSizeItem |
51 | | { |
52 | | SwFrameSize m_eFrameHeightType; |
53 | | SwFrameSize m_eFrameWidthType; |
54 | | sal_uInt8 m_nWidthPercent; |
55 | | sal_Int16 m_eWidthPercentRelation; |
56 | | sal_uInt8 m_nHeightPercent; |
57 | | sal_Int16 m_eHeightPercentRelation; |
58 | | |
59 | | // For tables: width can be given in percent. |
60 | | |
61 | | // For frames: height and/or width may be given in percent. |
62 | | // If only one of these percentage values is given, the value 0xFF |
63 | | // used instead of the missing percentage value indicates this side |
64 | | // being proportional to the given one. |
65 | | // The calculation in this case is based upon the values in Size. |
66 | | // Percentages are always related to the environment in which |
67 | | // the object is placed (PrtArea) and to the screen width |
68 | | // minus borders in BrowseView if the environment is the page. |
69 | | |
70 | | void ScaleMetrics(tools::Long lMult, tools::Long lDiv) override; |
71 | | bool HasMetrics() const override; |
72 | | |
73 | | public: |
74 | | DECLARE_ITEM_TYPE_FUNCTION(SwFormatFrameSize) |
75 | | SwFormatFrameSize( SwFrameSize eSize = SwFrameSize::Variable, |
76 | | SwTwips nWidth = 0, SwTwips nHeight = 0 ); |
77 | | |
78 | | virtual bool operator==( const SfxPoolItem& ) const override; |
79 | | virtual size_t hashCode() const override; |
80 | | virtual SwFormatFrameSize* Clone( SfxItemPool *pPool = nullptr ) const override; |
81 | | virtual bool GetPresentation( SfxItemPresentation ePres, |
82 | | MapUnit eCoreMetric, |
83 | | MapUnit ePresMetric, |
84 | | OUString &rText, |
85 | | const IntlWrapper& rIntl ) const override; |
86 | | virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; |
87 | | virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; |
88 | | |
89 | 2.76M | SwFrameSize GetHeightSizeType() const { return m_eFrameHeightType; } |
90 | | void SetHeightSizeType( SwFrameSize eSize ) |
91 | 17.8k | { ASSERT_CHANGE_REFCOUNTED_ITEM; m_eFrameHeightType = eSize; } |
92 | | |
93 | 2.41M | SwFrameSize GetWidthSizeType() const { return m_eFrameWidthType; } |
94 | | void SetWidthSizeType( SwFrameSize eSize ) |
95 | 17.9k | { ASSERT_CHANGE_REFCOUNTED_ITEM; m_eFrameWidthType = eSize; } |
96 | | |
97 | | enum PercentFlags { SYNCED = 0xff }; |
98 | | //0xff is reserved to indicate height is synced to width |
99 | 4.64M | sal_uInt8 GetHeightPercent() const{ return m_nHeightPercent; } |
100 | 4.64M | sal_Int16 GetHeightPercentRelation() const { return m_eHeightPercentRelation; } |
101 | | //0xff is reserved to indicate width is synced to height |
102 | 4.66M | sal_uInt8 GetWidthPercent() const { return m_nWidthPercent; } |
103 | 4.64M | sal_Int16 GetWidthPercentRelation() const { return m_eWidthPercentRelation; } |
104 | | void SetHeightPercent( sal_uInt8 n ) |
105 | 85.5k | { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nHeightPercent = n; } |
106 | | void SetHeightPercentRelation ( sal_Int16 n ) |
107 | 94 | { ASSERT_CHANGE_REFCOUNTED_ITEM; m_eHeightPercentRelation = n; } |
108 | | void SetWidthPercent ( sal_uInt8 n ) |
109 | 166k | { ASSERT_CHANGE_REFCOUNTED_ITEM; m_nWidthPercent = n; } |
110 | | void SetWidthPercentRelation ( sal_Int16 n ) |
111 | 94 | { ASSERT_CHANGE_REFCOUNTED_ITEM; m_eWidthPercentRelation = n; } |
112 | | |
113 | | void dumpAsXml(xmlTextWriterPtr pWriter) const override; |
114 | | |
115 | | protected: |
116 | | virtual ItemInstanceManager* getItemInstanceManager() const override; |
117 | | }; |
118 | | |
119 | | inline const SwFormatFrameSize &SwAttrSet::GetFrameSize(bool bInP) const |
120 | 2.22M | { return Get( RES_FRM_SIZE,bInP); } |
121 | | |
122 | | inline const SwFormatFrameSize &SwFormat::GetFrameSize(bool bInP) const |
123 | 2.11M | { return m_aSet.GetFrameSize(bInP); } |
124 | | |
125 | | #endif |
126 | | |
127 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |