xref: /aoo42x/main/svl/source/items/flagitem.cxx (revision 40df464e)
1*40df464eSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*40df464eSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*40df464eSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*40df464eSAndrew Rist  * distributed with this work for additional information
6*40df464eSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*40df464eSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*40df464eSAndrew Rist  * "License"); you may not use this file except in compliance
9*40df464eSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*40df464eSAndrew Rist  *
11*40df464eSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*40df464eSAndrew Rist  *
13*40df464eSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*40df464eSAndrew Rist  * software distributed under the License is distributed on an
15*40df464eSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*40df464eSAndrew Rist  * KIND, either express or implied.  See the License for the
17*40df464eSAndrew Rist  * specific language governing permissions and limitations
18*40df464eSAndrew Rist  * under the License.
19*40df464eSAndrew Rist  *
20*40df464eSAndrew Rist  *************************************************************/
21*40df464eSAndrew Rist 
22*40df464eSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svl.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <svl/flagitem.hxx>
28cdf0e10cSrcweir #include <svl/poolitem.hxx>
29cdf0e10cSrcweir #include <tools/stream.hxx>
30cdf0e10cSrcweir 
31cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
32cdf0e10cSrcweir 
33cdf0e10cSrcweir DBG_NAME(SfxFlagItem)
34cdf0e10cSrcweir 
35cdf0e10cSrcweir sal_uInt16 nSfxFlagVal[16] =
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 	0x0001, 0x0002, 0x0004, 0x0008,
38cdf0e10cSrcweir 	0x0010, 0x0020, 0x0040, 0x0080,
39cdf0e10cSrcweir 	0x0100, 0x0200, 0x0400, 0x0800,
40cdf0e10cSrcweir 	0x1000, 0x2000, 0x4000, 0x8000
41cdf0e10cSrcweir };
42cdf0e10cSrcweir 
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // -----------------------------------------------------------------------
45cdf0e10cSrcweir 
46cdf0e10cSrcweir TYPEINIT1(SfxFlagItem, SfxPoolItem);
47cdf0e10cSrcweir 
48cdf0e10cSrcweir // -----------------------------------------------------------------------
49cdf0e10cSrcweir 
SfxFlagItem(sal_uInt16 nW,sal_uInt16 nV)50cdf0e10cSrcweir SfxFlagItem::SfxFlagItem( sal_uInt16 nW, sal_uInt16 nV ) :
51cdf0e10cSrcweir 	SfxPoolItem( nW ),
52cdf0e10cSrcweir 	nVal(nV)
53cdf0e10cSrcweir {
54cdf0e10cSrcweir 	DBG_CTOR(SfxFlagItem, 0);
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir // -----------------------------------------------------------------------
58cdf0e10cSrcweir 
SfxFlagItem(sal_uInt16 nW,SvStream & rStream)59cdf0e10cSrcweir SfxFlagItem::SfxFlagItem( sal_uInt16 nW, SvStream &rStream) :
60cdf0e10cSrcweir 	SfxPoolItem( nW )
61cdf0e10cSrcweir {
62cdf0e10cSrcweir 	DBG_CTOR(SfxFlagItem, 0);
63cdf0e10cSrcweir 	rStream >> nVal;
64cdf0e10cSrcweir }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir // -----------------------------------------------------------------------
67cdf0e10cSrcweir 
SfxFlagItem(const SfxFlagItem & rItem)68cdf0e10cSrcweir SfxFlagItem::SfxFlagItem( const SfxFlagItem& rItem ) :
69cdf0e10cSrcweir 	SfxPoolItem( rItem ),
70cdf0e10cSrcweir 	nVal( rItem.nVal )
71cdf0e10cSrcweir {
72cdf0e10cSrcweir 	DBG_CTOR(SfxFlagItem, 0);
73cdf0e10cSrcweir }
74cdf0e10cSrcweir 
75cdf0e10cSrcweir // -----------------------------------------------------------------------
76cdf0e10cSrcweir 
Store(SvStream & rStream,sal_uInt16) const77cdf0e10cSrcweir SvStream& SfxFlagItem::Store(SvStream &rStream, sal_uInt16) const
78cdf0e10cSrcweir {
79cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
80cdf0e10cSrcweir 	rStream << nVal;
81cdf0e10cSrcweir 	return rStream;
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir // -----------------------------------------------------------------------
85cdf0e10cSrcweir 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const86cdf0e10cSrcweir SfxItemPresentation SfxFlagItem::GetPresentation
87cdf0e10cSrcweir (
88cdf0e10cSrcweir 	SfxItemPresentation 	/*ePresentation*/,
89cdf0e10cSrcweir 	SfxMapUnit				/*eCoreMetric*/,
90cdf0e10cSrcweir 	SfxMapUnit				/*ePresentationMetric*/,
91cdf0e10cSrcweir 	XubString& 				rText,
92cdf0e10cSrcweir     const IntlWrapper *
93cdf0e10cSrcweir )	const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
96cdf0e10cSrcweir 	rText.Erase();
97cdf0e10cSrcweir 	for ( sal_uInt8 nFlag = 0; nFlag < GetFlagCount(); ++nFlag )
98cdf0e10cSrcweir 		rText += XubString::CreateFromInt32( GetFlag(nFlag) );
99cdf0e10cSrcweir 	return SFX_ITEM_PRESENTATION_NAMELESS;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir // -----------------------------------------------------------------------
103cdf0e10cSrcweir 
GetFlagText(sal_uInt8) const104cdf0e10cSrcweir XubString SfxFlagItem::GetFlagText( sal_uInt8 ) const
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
107cdf0e10cSrcweir 	DBG_WARNING( "calling GetValueText(sal_uInt16) on SfxFlagItem -- overload!" );
108cdf0e10cSrcweir 	return XubString();
109cdf0e10cSrcweir }
110cdf0e10cSrcweir 
111cdf0e10cSrcweir // -----------------------------------------------------------------------
112cdf0e10cSrcweir 
GetFlagCount() const113cdf0e10cSrcweir sal_uInt8 SfxFlagItem::GetFlagCount() const
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
116cdf0e10cSrcweir 	DBG_WARNING( "calling GetValueText(sal_uInt16) on SfxFlagItem -- overload!" );
117cdf0e10cSrcweir 	return 0;
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // -----------------------------------------------------------------------
121cdf0e10cSrcweir 
Create(SvStream &,sal_uInt16) const122cdf0e10cSrcweir SfxPoolItem* SfxFlagItem::Create(SvStream &, sal_uInt16) const
123cdf0e10cSrcweir {
124cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
125cdf0e10cSrcweir 	DBG_WARNING( "calling Create() on SfxFlagItem -- overload!" );
126cdf0e10cSrcweir 	return 0;
127cdf0e10cSrcweir }
128cdf0e10cSrcweir 
129cdf0e10cSrcweir // -----------------------------------------------------------------------
130cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rItem) const131cdf0e10cSrcweir int SfxFlagItem::operator==( const SfxPoolItem& rItem ) const
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
134cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==( rItem ), "unequal type" );
135cdf0e10cSrcweir 	return (((SfxFlagItem&)rItem).nVal == nVal);
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // -----------------------------------------------------------------------
139cdf0e10cSrcweir 
SetFlag(sal_uInt8 nFlag,int bVal)140cdf0e10cSrcweir void SfxFlagItem::SetFlag( sal_uInt8 nFlag, int bVal )
141cdf0e10cSrcweir {
142cdf0e10cSrcweir 	if ( bVal )
143cdf0e10cSrcweir 		nVal |= nSfxFlagVal[nFlag];
144cdf0e10cSrcweir 	else
145cdf0e10cSrcweir 		nVal &= ~nSfxFlagVal[nFlag];
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir // -----------------------------------------------------------------------
149cdf0e10cSrcweir 
Clone(SfxItemPool *) const150cdf0e10cSrcweir SfxPoolItem* SfxFlagItem::Clone(SfxItemPool *) const
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	DBG_CHKTHIS(SfxFlagItem, 0);
153cdf0e10cSrcweir 	return new SfxFlagItem( *this );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 
160