LibreOffice Module sw (master)  1
fmtfsize.hxx
Go to the documentation of this file.
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 class IntlWrapper;
32 
33 //Frame size.
34 
36 {
41 };
42 
44 {
51 
52  // For tables: width can be given in percent.
53 
54  // For frames: height and/or width may be given in percent.
55  // If only one of these percentage values is given, the value 0xFF
56  // used instead of the missing percentage value indicates this side
57  // being proportional to the given one.
58  // The calculation in this case is based upon the values in Size.
59  // Percentages are always related to the environment in which
60  // the object is placed (PrtArea) and to the screen width
61  // minus borders in BrowseView if the environment is the page.
62 
63  void ScaleMetrics(long lMult, long lDiv) override;
64  bool HasMetrics() const override;
65 
66 public:
68  SwTwips nWidth = 0, SwTwips nHeight = 0 );
69 
70  virtual bool operator==( const SfxPoolItem& ) const override;
71  virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const override;
72  virtual bool GetPresentation( SfxItemPresentation ePres,
73  MapUnit eCoreMetric,
74  MapUnit ePresMetric,
75  OUString &rText,
76  const IntlWrapper& rIntl ) const override;
77  virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
78  virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
79 
80  SwFrameSize GetHeightSizeType() const { return m_eFrameHeightType; }
81  void SetHeightSizeType( SwFrameSize eSize ) { m_eFrameHeightType = eSize; }
82 
83  SwFrameSize GetWidthSizeType() const { return m_eFrameWidthType; }
84  void SetWidthSizeType( SwFrameSize eSize ) { m_eFrameWidthType = eSize; }
85 
86  enum PercentFlags { SYNCED = 0xff };
87  //0xff is reserved to indicate height is synced to width
88  sal_uInt8 GetHeightPercent() const{ return m_nHeightPercent; }
89  sal_Int16 GetHeightPercentRelation() const { return m_eHeightPercentRelation; }
90  //0xff is reserved to indicate width is synced to height
91  sal_uInt8 GetWidthPercent() const { return m_nWidthPercent; }
92  sal_Int16 GetWidthPercentRelation() const { return m_eWidthPercentRelation; }
93  void SetHeightPercent( sal_uInt8 n ) { m_nHeightPercent = n; }
94  void SetHeightPercentRelation ( sal_Int16 n ) { m_eHeightPercentRelation = n; }
95  void SetWidthPercent ( sal_uInt8 n ) { m_nWidthPercent = n; }
96  void SetWidthPercentRelation ( sal_Int16 n ) { m_eWidthPercentRelation = n; }
97 
98  void dumpAsXml(xmlTextWriterPtr pWriter) const override;
99 };
100 
101 inline const SwFormatFrameSize &SwAttrSet::GetFrameSize(bool bInP) const
102  { return Get( RES_FRM_SIZE,bInP); }
103 
104 inline const SwFormatFrameSize &SwFormat::GetFrameSize(bool bInP) const
105  { return m_aSet.GetFrameSize(bInP); }
106 
107 #endif
108 
109 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void ScaleMetrics(long nMult, long nDiv) override
#define RES_FRM_SIZE
Definition: hintids.hxx:196
void SetWidthPercentRelation(sal_Int16 n)
Definition: fmtfsize.hxx:96
SwFrameSize m_eFrameWidthType
Definition: fmtfsize.hxx:46
sal_uInt8 m_nHeightPercent
Definition: fmtfsize.hxx:49
virtual bool operator==(const SfxPoolItem &) const override
long SwTwips
Definition: swtypes.hxx:49
SwFrameSize m_eFrameHeightType
Definition: fmtfsize.hxx:45
SwAttrSet m_aSet
Definition: format.hxx:48
Frame cannot be moved in Var-direction.
Definition: fmtfsize.hxx:38
Value in Var-direction gives minimum (can be exceeded but not be less).
Definition: fmtfsize.hxx:39
sal_Int16 m_eWidthPercentRelation
Definition: fmtfsize.hxx:48
void SetHeightPercentRelation(sal_Int16 n)
Definition: fmtfsize.hxx:94
struct _xmlTextWriter * xmlTextWriterPtr
SfxItemPresentation
void SetWidthSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:84
sal_uInt8 GetHeightPercent() const
Definition: fmtfsize.hxx:88
SwFrameSize GetWidthSizeType() const
Definition: fmtfsize.hxx:83
SwFrameSize
Definition: fmtfsize.hxx:35
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
sal_uInt8 GetWidthPercent() const
Definition: fmtfsize.hxx:91
#define SW_DLLPUBLIC
Definition: swdllapi.h:28
sal_Int16 GetHeightPercentRelation() const
Definition: fmtfsize.hxx:89
void SetHeightPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:93
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual bool HasMetrics() const override
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
unsigned char sal_uInt8
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:104
virtual bool GetPresentation(SfxItemPresentation ePres, MapUnit eCoreMetric, MapUnit ePresMetric, OUString &rText, const IntlWrapper &) const override
MapUnit
sal_uInt8 m_nWidthPercent
Definition: fmtfsize.hxx:47
sal_Int16 m_eHeightPercentRelation
Definition: fmtfsize.hxx:50
void SetHeightSizeType(SwFrameSize eSize)
Definition: fmtfsize.hxx:81
Frame is variable in Var-direction.
Definition: fmtfsize.hxx:37
sal_Int16 GetWidthPercentRelation() const
Definition: fmtfsize.hxx:92
const SwFormatFrameSize & GetFrameSize(bool=true) const
Definition: fmtfsize.hxx:101
SwFrameSize GetHeightSizeType() const
Definition: fmtfsize.hxx:80