Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / fmtfsize.hxx
blob2a5cf5558c2959a44a86d6cb899a9e1c49bc0fff
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_SW_INC_FMTFSIZE_HXX
20 #define INCLUDED_SW_INC_FMTFSIZE_HXX
22 #include <tools/gen.hxx>
23 #include <svl/poolitem.hxx>
24 #include "swdllapi.h"
25 #include <hintids.hxx>
26 #include <swtypes.hxx>
27 #include <format.hxx>
29 class IntlWrapper;
31 //Frame size.
33 enum SwFrmSize
35 ATT_VAR_SIZE, ///< Frame is variable in Var-direction.
36 ATT_FIX_SIZE, ///< Frame cannot be moved in Var-direction.
37 ATT_MIN_SIZE /**< Value in Var-direction gives minimum
38 (can be exceeded but not be less). */
41 class SW_DLLPUBLIC SwFormatFrmSize: public SfxPoolItem
43 Size m_aSize;
44 SwFrmSize m_eFrmHeightType;
45 SwFrmSize m_eFrmWidthType;
46 sal_uInt8 m_nWidthPercent;
47 sal_Int16 m_eWidthPercentRelation;
48 sal_uInt8 m_nHeightPercent;
49 sal_Int16 m_eHeightPercentRelation;
51 // For tables: width can be given in percent.
53 // For frames: height and/or width may be given in percent.
54 // If only one of these percentage values is given, the value 0xFF
55 // used instead of the missing percentage value indicates this side
56 // being proportional to the given one.
57 // The calculation in this case is based upon the values in Size.
58 // Percentages are always related to the environment in which
59 // the object is placed (PrtArea) and to the screen width
60 // minus borders in BrowseView if the environment is the page.
62 public:
63 SwFormatFrmSize( SwFrmSize eSize = ATT_VAR_SIZE,
64 SwTwips nWidth = 0, SwTwips nHeight = 0 );
65 SwFormatFrmSize& operator=( const SwFormatFrmSize& rCpy );
67 /// "Pure virtual methods" of SfxPoolItem.
68 virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
69 virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
70 virtual bool GetPresentation( SfxItemPresentation ePres,
71 SfxMapUnit eCoreMetric,
72 SfxMapUnit ePresMetric,
73 OUString &rText,
74 const IntlWrapper* pIntl = 0 ) const SAL_OVERRIDE;
75 virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
76 virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
78 SwFrmSize GetHeightSizeType() const { return m_eFrmHeightType; }
79 void SetHeightSizeType( SwFrmSize eSize ) { m_eFrmHeightType = eSize; }
81 SwFrmSize GetWidthSizeType() const { return m_eFrmWidthType; }
82 void SetWidthSizeType( SwFrmSize eSize ) { m_eFrmWidthType = eSize; }
84 const Size& GetSize() const { return m_aSize; }
85 void SetSize( const Size &rNew ) { m_aSize = rNew; }
87 SwTwips GetHeight() const { return m_aSize.Height(); }
88 SwTwips GetWidth() const { return m_aSize.Width(); }
89 void SetHeight( const SwTwips nNew ) { m_aSize.Height() = nNew; }
90 void SetWidth ( const SwTwips nNew ) { m_aSize.Width() = nNew; }
92 sal_uInt8 GetHeightPercent() const{ return m_nHeightPercent; }
93 sal_Int16 GetHeightPercentRelation() const { return m_eHeightPercentRelation; }
94 sal_uInt8 GetWidthPercent() const { return m_nWidthPercent; }
95 sal_Int16 GetWidthPercentRelation() const { return m_eWidthPercentRelation; }
96 void SetHeightPercent( sal_uInt8 n ) { m_nHeightPercent = n; }
97 void SetHeightPercentRelation ( sal_Int16 n ) { m_eHeightPercentRelation = n; }
98 void SetWidthPercent ( sal_uInt8 n ) { m_nWidthPercent = n; }
99 void SetWidthPercentRelation ( sal_Int16 n ) { m_eWidthPercentRelation = n; }
101 void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE;
104 inline const SwFormatFrmSize &SwAttrSet::GetFrmSize(bool bInP) const
105 { return static_cast<const SwFormatFrmSize&>(Get( RES_FRM_SIZE,bInP)); }
107 inline const SwFormatFrmSize &SwFormat::GetFrmSize(bool bInP) const
108 { return m_aSet.GetFrmSize(bInP); }
110 #endif
112 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */