Line data Source code
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/eitem.hxx>
23 : #include <editeng/svxenum.hxx>
24 : #include <editeng/eeitem.hxx>
25 : #include <editeng/editengdllapi.h>
26 :
27 : class SvXMLUnitConverter;
28 :
29 : // class SvxAdjustItem ---------------------------------------------------
30 :
31 : /*
32 : [Description]
33 : This item describes the row orientation.
34 : */
35 : #define ADJUST_LASTBLOCK_VERSION ((sal_uInt16)0x0001)
36 :
37 179669 : class EDITENG_DLLPUBLIC SvxAdjustItem : public SfxEnumItemInterface
38 : {
39 : bool bLeft : 1;
40 : bool bRight : 1;
41 : bool bCenter : 1;
42 : bool bBlock : 1;
43 :
44 : // only activ when bBlock
45 : bool bOneBlock : 1;
46 : bool bLastCenter : 1;
47 : bool bLastBlock : 1;
48 :
49 : friend SvStream& WriteSvxAdjustItem( SvStream&, SvxAdjustItem& ); //$ ostream
50 : public:
51 : TYPEINFO_OVERRIDE();
52 :
53 : SvxAdjustItem( const SvxAdjust eAdjst /*= SVX_ADJUST_LEFT*/,
54 : const sal_uInt16 nId );
55 :
56 : // "pure virtual Methods" from SfxPoolItem
57 : virtual bool operator==( const SfxPoolItem& ) const SAL_OVERRIDE;
58 :
59 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const SAL_OVERRIDE;
60 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) SAL_OVERRIDE;
61 :
62 : virtual bool GetPresentation( SfxItemPresentation ePres,
63 : SfxMapUnit eCoreMetric,
64 : SfxMapUnit ePresMetric,
65 : OUString &rText, const IntlWrapper * = 0 ) const SAL_OVERRIDE;
66 : virtual sal_uInt16 GetValueCount() const SAL_OVERRIDE;
67 : virtual OUString GetValueTextByPos( sal_uInt16 nPos ) const SAL_OVERRIDE;
68 : virtual sal_uInt16 GetEnumValue() const SAL_OVERRIDE;
69 : virtual void SetEnumValue( sal_uInt16 nNewVal ) SAL_OVERRIDE;
70 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
71 : virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
72 : virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const SAL_OVERRIDE;
73 : virtual sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const SAL_OVERRIDE;
74 :
75 512 : inline void SetOneWord( const SvxAdjust eType )
76 : {
77 512 : bOneBlock = eType == SVX_ADJUST_BLOCK;
78 512 : }
79 :
80 10271 : inline void SetLastBlock( const SvxAdjust eType )
81 : {
82 10271 : bLastBlock = eType == SVX_ADJUST_BLOCK;
83 10271 : bLastCenter = eType == SVX_ADJUST_CENTER;
84 10271 : }
85 :
86 65480 : inline void SetAdjust( const SvxAdjust eType )
87 : {
88 65480 : bLeft = eType == SVX_ADJUST_LEFT;
89 65480 : bRight = eType == SVX_ADJUST_RIGHT;
90 65480 : bCenter = eType == SVX_ADJUST_CENTER;
91 65480 : bBlock = eType == SVX_ADJUST_BLOCK;
92 65480 : }
93 :
94 369762 : inline SvxAdjust GetLastBlock() const
95 : {
96 369762 : SvxAdjust eRet = SVX_ADJUST_LEFT;
97 :
98 369762 : if ( bLastBlock )
99 10 : eRet = SVX_ADJUST_BLOCK;
100 369752 : else if( bLastCenter )
101 0 : eRet = SVX_ADJUST_CENTER;
102 369762 : return eRet;
103 : }
104 :
105 184833 : inline SvxAdjust GetOneWord() const
106 : {
107 184833 : SvxAdjust eRet = SVX_ADJUST_LEFT;
108 :
109 184833 : if ( bBlock && bOneBlock )
110 0 : eRet = SVX_ADJUST_BLOCK;
111 184833 : return eRet;
112 : }
113 :
114 1190843 : inline SvxAdjust GetAdjust() const
115 : {
116 1190843 : SvxAdjust eRet = SVX_ADJUST_LEFT;
117 :
118 1190843 : if ( bRight )
119 28237 : eRet = SVX_ADJUST_RIGHT;
120 1162606 : else if ( bCenter )
121 217883 : eRet = SVX_ADJUST_CENTER;
122 944723 : else if ( bBlock )
123 72830 : eRet = SVX_ADJUST_BLOCK;
124 1190843 : return eRet;
125 : }
126 : };
127 :
128 : #endif
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|