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