1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: flagitem.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
34 #include <svtools/flagitem.hxx>
35 #include <svtools/poolitem.hxx>
36 #include <tools/stream.hxx>
38 // STATIC DATA -----------------------------------------------------------
42 USHORT nSfxFlagVal
[16] =
44 0x0001, 0x0002, 0x0004, 0x0008,
45 0x0010, 0x0020, 0x0040, 0x0080,
46 0x0100, 0x0200, 0x0400, 0x0800,
47 0x1000, 0x2000, 0x4000, 0x8000
51 // -----------------------------------------------------------------------
53 TYPEINIT1(SfxFlagItem
, SfxPoolItem
);
55 // -----------------------------------------------------------------------
57 SfxFlagItem::SfxFlagItem( USHORT nW
, USHORT nV
) :
61 DBG_CTOR(SfxFlagItem
, 0);
64 // -----------------------------------------------------------------------
66 SfxFlagItem::SfxFlagItem( USHORT nW
, SvStream
&rStream
) :
69 DBG_CTOR(SfxFlagItem
, 0);
73 // -----------------------------------------------------------------------
75 SfxFlagItem::SfxFlagItem( const SfxFlagItem
& rItem
) :
79 DBG_CTOR(SfxFlagItem
, 0);
82 // -----------------------------------------------------------------------
84 SvStream
& SfxFlagItem::Store(SvStream
&rStream
, USHORT
) const
86 DBG_CHKTHIS(SfxFlagItem
, 0);
91 // -----------------------------------------------------------------------
93 SfxItemPresentation
SfxFlagItem::GetPresentation
95 SfxItemPresentation
/*ePresentation*/,
96 SfxMapUnit
/*eCoreMetric*/,
97 SfxMapUnit
/*ePresentationMetric*/,
102 DBG_CHKTHIS(SfxFlagItem
, 0);
104 for ( BYTE nFlag
= 0; nFlag
< GetFlagCount(); ++nFlag
)
105 rText
+= XubString::CreateFromInt32( GetFlag(nFlag
) );
106 return SFX_ITEM_PRESENTATION_NAMELESS
;
109 // -----------------------------------------------------------------------
111 XubString
SfxFlagItem::GetFlagText( BYTE
) const
113 DBG_CHKTHIS(SfxFlagItem
, 0);
114 DBG_WARNING( "calling GetValueText(USHORT) on SfxFlagItem -- overload!" );
118 // -----------------------------------------------------------------------
120 BYTE
SfxFlagItem::GetFlagCount() const
122 DBG_CHKTHIS(SfxFlagItem
, 0);
123 DBG_WARNING( "calling GetValueText(USHORT) on SfxFlagItem -- overload!" );
127 // -----------------------------------------------------------------------
129 SfxPoolItem
* SfxFlagItem::Create(SvStream
&, USHORT
) const
131 DBG_CHKTHIS(SfxFlagItem
, 0);
132 DBG_WARNING( "calling Create() on SfxFlagItem -- overload!" );
136 // -----------------------------------------------------------------------
138 int SfxFlagItem::operator==( const SfxPoolItem
& rItem
) const
140 DBG_CHKTHIS(SfxFlagItem
, 0);
141 DBG_ASSERT( SfxPoolItem::operator==( rItem
), "unequal type" );
142 return (((SfxFlagItem
&)rItem
).nVal
== nVal
);
145 // -----------------------------------------------------------------------
147 void SfxFlagItem::SetFlag( BYTE nFlag
, int bVal
)
150 nVal
|= nSfxFlagVal
[nFlag
];
152 nVal
&= ~nSfxFlagVal
[nFlag
];
155 // -----------------------------------------------------------------------
157 SfxPoolItem
* SfxFlagItem::Clone(SfxItemPool
*) const
159 DBG_CHKTHIS(SfxFlagItem
, 0);
160 return new SfxFlagItem( *this );