xref: /AOO41X/main/editeng/inc/editeng/adjitem.hxx (revision 4c5491ea21520f5347760e8fc7d072f082fcde5f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _SVX_ADJITEM_HXX
24 #define _SVX_ADJITEM_HXX
25 
26 // include ---------------------------------------------------------------
27 
28 #include <svl/eitem.hxx>
29 #include <editeng/svxenum.hxx>
30 #include <editeng/eeitem.hxx>
31 #include <editeng/editengdllapi.h>
32 
33 class SvXMLUnitConverter;
34 namespace rtl
35 {
36     class OUString;
37 }
38 
39 // class SvxAdjustItem ---------------------------------------------------
40 
41 /*
42 [Beschreibung]
43 Dieses Item beschreibt die Zeilenausrichtung.
44 */
45 #define ADJUST_LASTBLOCK_VERSION        ((sal_uInt16)0x0001)
46 
47 class EDITENG_DLLPUBLIC SvxAdjustItem : public SfxEnumItemInterface
48 {
49     sal_Bool    bLeft      : 1;
50     sal_Bool    bRight     : 1;
51     sal_Bool    bCenter    : 1;
52     sal_Bool    bBlock     : 1;
53 
54     // nur aktiv, wenn bBlock
55     sal_Bool    bOneBlock : 1;
56     sal_Bool    bLastCenter : 1;
57     sal_Bool    bLastBlock : 1;
58 
59     friend SvStream& operator<<( SvStream&, SvxAdjustItem& ); //$ ostream
60 public:
61     TYPEINFO();
62 
63     SvxAdjustItem( const SvxAdjust eAdjst /*= SVX_ADJUST_LEFT*/,
64                    const sal_uInt16 nId );
65 
66     // "pure virtual Methoden" vom SfxPoolItem
67     virtual int              operator==( const SfxPoolItem& ) const;
68 
69     virtual sal_Bool             QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const;
70     virtual sal_Bool             PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0 );
71 
72     virtual SfxItemPresentation GetPresentation( SfxItemPresentation ePres,
73                                     SfxMapUnit eCoreMetric,
74                                     SfxMapUnit ePresMetric,
75                                     String &rText, const IntlWrapper * = 0 ) const;
76     virtual sal_uInt16           GetValueCount() const;
77     virtual String           GetValueTextByPos( sal_uInt16 nPos ) const;
78     virtual sal_uInt16           GetEnumValue() const;
79     virtual void             SetEnumValue( sal_uInt16 nNewVal );
80     virtual SfxPoolItem*     Clone( SfxItemPool *pPool = 0 ) const;
81     virtual SfxPoolItem*     Create(SvStream &, sal_uInt16) const;
82     virtual SvStream&        Store(SvStream &, sal_uInt16 nItemVersion ) const;
83     virtual sal_uInt16           GetVersion( sal_uInt16 nFileVersion ) const;
84 
SetOneWord(const SvxAdjust eType)85     inline void SetOneWord( const SvxAdjust eType )
86     {
87         bOneBlock  = eType == SVX_ADJUST_BLOCK;
88     }
89 
SetLastBlock(const SvxAdjust eType)90     inline void SetLastBlock( const SvxAdjust eType )
91     {
92         bLastBlock = eType == SVX_ADJUST_BLOCK;
93         bLastCenter = eType == SVX_ADJUST_CENTER;
94     }
95 
SetAdjust(const SvxAdjust eType)96     inline void SetAdjust( const SvxAdjust eType )
97     {
98         bLeft = eType == SVX_ADJUST_LEFT;
99         bRight = eType == SVX_ADJUST_RIGHT;
100         bCenter = eType == SVX_ADJUST_CENTER;
101         bBlock = eType == SVX_ADJUST_BLOCK;
102     }
103 
GetLastBlock() const104     inline SvxAdjust GetLastBlock() const
105     {
106         SvxAdjust eRet = SVX_ADJUST_LEFT;
107 
108         if ( bLastBlock )
109             eRet = SVX_ADJUST_BLOCK;
110         else if( bLastCenter )
111             eRet = SVX_ADJUST_CENTER;
112         return eRet;
113     }
114 
GetOneWord() const115     inline SvxAdjust GetOneWord() const
116     {
117         SvxAdjust eRet = SVX_ADJUST_LEFT;
118 
119         if ( bBlock && bOneBlock )
120             eRet = SVX_ADJUST_BLOCK;
121         return eRet;
122     }
123 
GetAdjust() const124     inline SvxAdjust GetAdjust() const
125     {
126         SvxAdjust eRet = SVX_ADJUST_LEFT;
127 
128         if ( bRight )
129             eRet = SVX_ADJUST_RIGHT;
130         else if ( bCenter )
131             eRet = SVX_ADJUST_CENTER;
132         else if ( bBlock )
133             eRet = SVX_ADJUST_BLOCK;
134         return eRet;
135     }
136 };
137 
138 #endif
139 
140