Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / editeng / adjustitem.hxx
blobe2793907736ceb81634acbc5b575db70e13c9479
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_ADJUSTITEM_HXX
20 #define INCLUDED_EDITENG_ADJUSTITEM_HXX
22 #include <svl/cenumitm.hxx>
23 #include <svl/poolitem.hxx>
24 #include <editeng/svxenum.hxx>
25 #include <editeng/editengdllapi.h>
27 // class SvxAdjustItem ---------------------------------------------------
30 [Description]
31 This item describes the row orientation.
33 constexpr sal_uInt16 ADJUST_LASTBLOCK_VERSION = 0x0001;
35 class EDITENG_DLLPUBLIC SvxAdjustItem final : public SfxEnumItemInterface
37 bool bLeft : 1;
38 bool bRight : 1;
39 bool bCenter : 1;
40 bool bBlock : 1;
42 // only active when bBlock
43 bool bOneBlock : 1;
44 bool bLastCenter : 1;
45 bool bLastBlock : 1;
47 public:
48 static SfxPoolItem* CreateDefault();
50 SvxAdjustItem( const SvxAdjust eAdjst /*= SvxAdjust::Left*/,
51 const sal_uInt16 nId );
53 // "pure virtual Methods" from SfxPoolItem
54 virtual bool operator==( const SfxPoolItem& ) const override;
56 virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override;
57 virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override;
59 virtual bool GetPresentation( SfxItemPresentation ePres,
60 MapUnit eCoreMetric,
61 MapUnit ePresMetric,
62 OUString &rText, const IntlWrapper& ) const override;
63 virtual sal_uInt16 GetValueCount() const override;
64 static OUString GetValueTextByPos( sal_uInt16 nPos );
65 virtual sal_uInt16 GetEnumValue() const override;
66 virtual void SetEnumValue( sal_uInt16 nNewVal ) override;
67 virtual SvxAdjustItem* Clone( SfxItemPool *pPool = nullptr ) const override;
69 void SetOneWord( const SvxAdjust eType )
71 bOneBlock = eType == SvxAdjust::Block;
74 void SetLastBlock( const SvxAdjust eType )
76 bLastBlock = eType == SvxAdjust::Block;
77 bLastCenter = eType == SvxAdjust::Center;
80 void SetAdjust( const SvxAdjust eType )
82 bLeft = eType == SvxAdjust::Left;
83 bRight = eType == SvxAdjust::Right;
84 bCenter = eType == SvxAdjust::Center;
85 bBlock = eType == SvxAdjust::Block;
88 SvxAdjust GetLastBlock() const
90 SvxAdjust eRet = SvxAdjust::Left;
92 if ( bLastBlock )
93 eRet = SvxAdjust::Block;
94 else if( bLastCenter )
95 eRet = SvxAdjust::Center;
96 return eRet;
99 SvxAdjust GetOneWord() const
101 SvxAdjust eRet = SvxAdjust::Left;
103 if ( bBlock && bOneBlock )
104 eRet = SvxAdjust::Block;
105 return eRet;
108 SvxAdjust GetAdjust() const
110 SvxAdjust eRet = SvxAdjust::Left;
112 if ( bRight )
113 eRet = SvxAdjust::Right;
114 else if ( bCenter )
115 eRet = SvxAdjust::Center;
116 else if ( bBlock )
117 eRet = SvxAdjust::Block;
118 return eRet;
121 sal_Int8 GetAsFlags() const
123 sal_Int8 nFlags = 0;
124 if ( bOneBlock )
125 nFlags |= 0x0001;
126 if ( bLastCenter )
127 nFlags |= 0x0002;
128 if ( bLastBlock )
129 nFlags |= 0x0004;
130 return nFlags;
133 void SetAsFlags(sal_Int8 nFlags)
135 bOneBlock = 0 != (nFlags & 0x0001);
136 bLastCenter = 0 != (nFlags & 0x0002);
137 bLastBlock = 0 != (nFlags & 0x0004);
141 #endif
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */