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 _SVX_ADJITEM_HXX
20 : #define _SVX_ADJITEM_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 35103 : class EDITENG_DLLPUBLIC SvxAdjustItem : public SfxEnumItemInterface
38 : {
39 : sal_Bool bLeft : 1;
40 : sal_Bool bRight : 1;
41 : sal_Bool bCenter : 1;
42 : sal_Bool bBlock : 1;
43 :
44 : // only activ when bBlock
45 : sal_Bool bOneBlock : 1;
46 : sal_Bool bLastCenter : 1;
47 : sal_Bool bLastBlock : 1;
48 :
49 : friend SvStream& operator<<( SvStream&, SvxAdjustItem& ); //$ ostream
50 : public:
51 : TYPEINFO();
52 :
53 : SvxAdjustItem( const SvxAdjust eAdjst /*= SVX_ADJUST_LEFT*/,
54 : const sal_uInt16 nId );
55 :
56 : // "pure virtual Methods" from SfxPoolItem
57 : virtual int operator==( const SfxPoolItem& ) const;
58 :
59 : virtual bool QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
60 : virtual bool PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
61 :
62 : virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
63 : SfxMapUnit eCoreMetric,
64 : SfxMapUnit ePresMetric,
65 : OUString &rText, const IntlWrapper * = 0 ) const;
66 : virtual sal_uInt16 GetValueCount() const;
67 : virtual OUString GetValueTextByPos( sal_uInt16 nPos ) const;
68 : virtual sal_uInt16 GetEnumValue() const;
69 : virtual void SetEnumValue( sal_uInt16 nNewVal );
70 : virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
71 : virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const;
72 : virtual SvStream& Store(SvStream &, sal_uInt16 nItemVersion ) const;
73 : virtual sal_uInt16 GetVersion( sal_uInt16 nFileVersion ) const;
74 :
75 256 : inline void SetOneWord( const SvxAdjust eType )
76 : {
77 256 : bOneBlock = eType == SVX_ADJUST_BLOCK;
78 256 : }
79 :
80 532 : inline void SetLastBlock( const SvxAdjust eType )
81 : {
82 532 : bLastBlock = eType == SVX_ADJUST_BLOCK;
83 532 : bLastCenter = eType == SVX_ADJUST_CENTER;
84 532 : }
85 :
86 22133 : inline void SetAdjust( const SvxAdjust eType )
87 : {
88 22133 : bLeft = eType == SVX_ADJUST_LEFT;
89 22133 : bRight = eType == SVX_ADJUST_RIGHT;
90 22133 : bCenter = eType == SVX_ADJUST_CENTER;
91 22133 : bBlock = eType == SVX_ADJUST_BLOCK;
92 22133 : }
93 :
94 97324 : inline SvxAdjust GetLastBlock() const
95 : {
96 97324 : SvxAdjust eRet = SVX_ADJUST_LEFT;
97 :
98 97324 : if ( bLastBlock )
99 0 : eRet = SVX_ADJUST_BLOCK;
100 97324 : else if( bLastCenter )
101 0 : eRet = SVX_ADJUST_CENTER;
102 97324 : return eRet;
103 : }
104 :
105 48704 : inline SvxAdjust GetOneWord() const
106 : {
107 48704 : SvxAdjust eRet = SVX_ADJUST_LEFT;
108 :
109 48704 : if ( bBlock && bOneBlock )
110 0 : eRet = SVX_ADJUST_BLOCK;
111 48704 : return eRet;
112 : }
113 :
114 668498 : inline SvxAdjust GetAdjust() const
115 : {
116 668498 : SvxAdjust eRet = SVX_ADJUST_LEFT;
117 :
118 668498 : if ( bRight )
119 6376 : eRet = SVX_ADJUST_RIGHT;
120 662122 : else if ( bCenter )
121 149646 : eRet = SVX_ADJUST_CENTER;
122 512476 : else if ( bBlock )
123 5978 : eRet = SVX_ADJUST_BLOCK;
124 668498 : return eRet;
125 : }
126 : };
127 :
128 : #endif
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|