LibreOffice Module editeng (master) 1
adjustitem.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_EDITENG_ADJUSTITEM_HXX
20#define INCLUDED_EDITENG_ADJUSTITEM_HXX
21
22#include <svl/cenumitm.hxx>
23#include <svl/poolitem.hxx>
24#include <editeng/svxenum.hxx>
26
27// class SvxAdjustItem ---------------------------------------------------
28
29/*
30[Description]
31This item describes the row orientation.
32*/
33constexpr sal_uInt16 ADJUST_LASTBLOCK_VERSION = 0x0001;
34
36{
37 bool bLeft : 1;
38 bool bRight : 1;
39 bool bCenter : 1;
40 bool bBlock : 1;
41
42 // only active when bBlock
43 bool bOneBlock : 1;
44 bool bLastCenter : 1;
45 bool bLastBlock : 1;
46
47public:
48 static SfxPoolItem* CreateDefault();
49
50 SvxAdjustItem( const SvxAdjust eAdjst /*= SvxAdjust::Left*/,
51 const sal_uInt16 nId );
52
53 // "pure virtual Methods" from SfxPoolItem
54 virtual bool operator==( const SfxPoolItem& ) const override;
55
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;
58
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;
68
69 void SetOneWord( const SvxAdjust eType )
70 {
71 bOneBlock = eType == SvxAdjust::Block;
72 }
73
74 void SetLastBlock( const SvxAdjust eType )
75 {
76 bLastBlock = eType == SvxAdjust::Block;
77 bLastCenter = eType == SvxAdjust::Center;
78 }
79
80 void SetAdjust( const SvxAdjust eType )
81 {
82 bLeft = eType == SvxAdjust::Left;
83 bRight = eType == SvxAdjust::Right;
84 bCenter = eType == SvxAdjust::Center;
85 bBlock = eType == SvxAdjust::Block;
86 }
87
89 {
91
92 if ( bLastBlock )
93 eRet = SvxAdjust::Block;
94 else if( bLastCenter )
95 eRet = SvxAdjust::Center;
96 return eRet;
97 }
98
100 {
102
103 if ( bBlock && bOneBlock )
104 eRet = SvxAdjust::Block;
105 return eRet;
106 }
107
109 {
111
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;
119 }
120
122 {
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;
131 }
132
133 void SetAsFlags(sal_Int8 nFlags)
134 {
135 bOneBlock = 0 != (nFlags & 0x0001);
136 bLastCenter = 0 != (nFlags & 0x0002);
137 bLastBlock = 0 != (nFlags & 0x0004);
138 }
139};
140
141#endif
142
143/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr sal_uInt16 ADJUST_LASTBLOCK_VERSION
Definition: adjustitem.hxx:33
virtual sal_uInt16 GetValueCount() const=0
virtual sal_uInt16 GetEnumValue() const=0
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8) override
virtual bool operator==(const SfxPoolItem &rItem) const override
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8=0) const override
virtual bool GetPresentation(SfxItemPresentation, MapUnit, MapUnit, OUString &rText, const IntlWrapper &) const override
virtual void SetEnumValue(sal_uInt16 nValue)=0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const=0
SvxAdjust GetLastBlock() const
Definition: adjustitem.hxx:88
SvxAdjust GetAdjust() const
Definition: adjustitem.hxx:108
SvxAdjust GetOneWord() const
Definition: adjustitem.hxx:99
void SetAdjust(const SvxAdjust eType)
Definition: adjustitem.hxx:80
void SetOneWord(const SvxAdjust eType)
Definition: adjustitem.hxx:69
void SetAsFlags(sal_Int8 nFlags)
Definition: adjustitem.hxx:133
void SetLastBlock(const SvxAdjust eType)
Definition: adjustitem.hxx:74
sal_Int8 GetAsFlags() const
Definition: adjustitem.hxx:121
#define EDITENG_DLLPUBLIC
Definition: editengdllapi.h:28
DocumentType eType
MapUnit
SfxItemPresentation
SvxAdjust
Definition: svxenum.hxx:77
unsigned char sal_uInt8
signed char sal_Int8