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: pageitem.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_svx.hxx"
34 // include ---------------------------------------------------------------
35 #include <tools/stream.hxx>
38 #include <svx/pageitem.hxx>
39 #include <svx/itemtype.hxx>
40 #include <svx/unomid.hxx>
41 #include <com/sun/star/style/PageStyleLayout.hpp>
42 #include <com/sun/star/style/BreakType.hpp>
43 #include <svtools/itemset.hxx>
45 using namespace ::rtl
;
46 using namespace ::com::sun::star
;
48 // STATIC DATA -----------------------------------------------------------
50 TYPEINIT1_FACTORY( SvxPageItem
, SfxPoolItem
, new SvxPageItem(0));
52 /*--------------------------------------------------------------------
53 Beschreibung: Konstruktor
54 --------------------------------------------------------------------*/
56 SvxPageItem::SvxPageItem( const USHORT nId
) : SfxPoolItem( nId
),
58 eNumType ( SVX_ARABIC
),
59 bLandscape ( sal_False
),
64 /*--------------------------------------------------------------------
65 Beschreibung: Copy-Konstruktor
66 --------------------------------------------------------------------*/
68 SvxPageItem::SvxPageItem( const SvxPageItem
& rItem
)
69 : SfxPoolItem( rItem
)
71 eNumType
= rItem
.eNumType
;
72 bLandscape
= rItem
.bLandscape
;
76 /*--------------------------------------------------------------------
78 --------------------------------------------------------------------*/
80 SfxPoolItem
* SvxPageItem::Clone( SfxItemPool
* ) const
82 return new SvxPageItem( *this );
85 /*--------------------------------------------------------------------
86 Beschreibung: Abfrage auf Gleichheit
87 --------------------------------------------------------------------*/
89 int SvxPageItem::operator==( const SfxPoolItem
& rAttr
) const
91 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
92 const SvxPageItem
& rItem
= (SvxPageItem
&)rAttr
;
93 return ( eNumType
== rItem
.eNumType
&&
94 bLandscape
== rItem
.bLandscape
&&
98 inline XubString
GetUsageText( const USHORT eU
)
100 if ( eU
& SVX_PAGE_LEFT
)
101 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT
);
102 if ( eU
& SVX_PAGE_RIGHT
)
103 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT
);
104 if ( eU
& SVX_PAGE_ALL
)
105 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL
);
106 if ( eU
& SVX_PAGE_MIRROR
)
107 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR
);
111 //------------------------------------------------------------------------
113 SfxItemPresentation
SvxPageItem::GetPresentation
115 SfxItemPresentation ePres
,
116 SfxMapUnit
/*eCoreUnit*/,
117 SfxMapUnit
/*ePresUnit*/,
118 XubString
& rText
, const IntlWrapper
*
125 case SFX_ITEM_PRESENTATION_NONE
:
126 return SFX_ITEM_PRESENTATION_NONE
;
127 case SFX_ITEM_PRESENTATION_NAMELESS
:
129 if ( aDescName
.Len() )
134 DBG_ASSERT( eNumType
<= SVX_NUMBER_NONE
, "enum overflow" );
135 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN
+ eNumType
);
138 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE
);
140 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE
);
141 rText
+= GetUsageText( eUse
);
142 return SFX_ITEM_PRESENTATION_NAMELESS
;
144 case SFX_ITEM_PRESENTATION_COMPLETE
:
146 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE
);
147 if ( aDescName
.Len() )
152 DBG_ASSERT( eNumType
<= SVX_NUMBER_NONE
, "enum overflow" );
153 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN
+ eNumType
);
156 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE
);
158 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE
);
159 rText
+= GetUsageText( eUse
);
160 return SFX_ITEM_PRESENTATION_COMPLETE
;
162 default: ;//prevent warning
164 return SFX_ITEM_PRESENTATION_NONE
;
167 //------------------------------------------------------------------------
168 sal_Bool
SvxPageItem::QueryValue( uno::Any
& rVal
, BYTE nMemberId
) const
170 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
171 nMemberId
&= ~CONVERT_TWIPS
;
174 case MID_PAGE_NUMTYPE
:
176 //! die Konstanten sind nicht mehr in den IDLs ?!?
177 rVal
<<= (sal_Int16
)( eNumType
);
180 case MID_PAGE_ORIENTATION
:
181 //Landscape= sal_True
182 rVal
= Bool2Any(bLandscape
);
184 case MID_PAGE_LAYOUT
:
186 style::PageStyleLayout eRet
;
189 case SVX_PAGE_LEFT
: eRet
= style::PageStyleLayout_LEFT
; break;
190 case SVX_PAGE_RIGHT
: eRet
= style::PageStyleLayout_RIGHT
; break;
191 case SVX_PAGE_ALL
: eRet
= style::PageStyleLayout_ALL
; break;
192 case SVX_PAGE_MIRROR
: eRet
= style::PageStyleLayout_MIRRORED
; break;
194 DBG_ERROR("was fuer ein Layout ist das?");
204 //------------------------------------------------------------------------
205 sal_Bool
SvxPageItem::PutValue( const uno::Any
& rVal
, BYTE nMemberId
)
209 case MID_PAGE_NUMTYPE
:
211 sal_Int32 nValue
= 0;
212 if(!(rVal
>>= nValue
))
215 eNumType
= (SvxNumType
)nValue
;
218 case MID_PAGE_ORIENTATION
:
219 bLandscape
= Any2Bool(rVal
);
221 case MID_PAGE_LAYOUT
:
223 style::PageStyleLayout eLayout
;
224 if(!(rVal
>>= eLayout
))
226 sal_Int32 nValue
= 0;
227 if(!(rVal
>>= nValue
))
229 eLayout
= (style::PageStyleLayout
)nValue
;
234 case style::PageStyleLayout_LEFT
: eUse
|= SVX_PAGE_LEFT
; break;
235 case style::PageStyleLayout_RIGHT
: eUse
|= SVX_PAGE_RIGHT
; break;
236 case style::PageStyleLayout_ALL
: eUse
|= SVX_PAGE_ALL
; break;
237 case style::PageStyleLayout_MIRRORED
: eUse
|= SVX_PAGE_MIRROR
;break;
238 default: ;//prevent warning
246 //------------------------------------------------------------------------
248 SfxPoolItem
* SvxPageItem::Create( SvStream
& rStream
, USHORT
) const
255 // UNICODE: rStream >> sStr;
256 rStream
.ReadByteString( sStr
);
262 SvxPageItem
* pPage
= new SvxPageItem( Which() );
263 pPage
->SetDescName( sStr
);
264 pPage
->SetNumType( (SvxNumType
)eType
);
265 pPage
->SetLandscape( bLand
);
266 pPage
->SetPageUsage( nUse
);
270 //------------------------------------------------------------------------
272 SvStream
& SvxPageItem::Store( SvStream
&rStrm
, USHORT
/*nItemVersion*/ ) const
274 // UNICODE: rStrm << aDescName;
275 rStrm
.WriteByteString(aDescName
);
277 rStrm
<< (BYTE
)eNumType
<< bLandscape
<< eUse
;
281 /*--------------------------------------------------------------------
282 Beschreibung: HeaderFooterSet
283 --------------------------------------------------------------------*/
285 SvxSetItem::SvxSetItem( const USHORT nId
, const SfxItemSet
& rSet
) :
287 SfxSetItem( nId
, rSet
)
291 SvxSetItem::SvxSetItem( const SvxSetItem
& rItem
) :
297 SvxSetItem::SvxSetItem( const USHORT nId
, SfxItemSet
* _pSet
) :
299 SfxSetItem( nId
, _pSet
)
303 SfxPoolItem
* SvxSetItem::Clone( SfxItemPool
* ) const
305 return new SvxSetItem(*this);
308 //------------------------------------------------------------------------
310 SfxItemPresentation
SvxSetItem::GetPresentation
312 SfxItemPresentation
/*ePres*/,
313 SfxMapUnit
/*eCoreUnit*/,
314 SfxMapUnit
/*ePresUnit*/,
315 XubString
& rText
, const IntlWrapper
*
319 return SFX_ITEM_PRESENTATION_NONE
;
322 SfxPoolItem
* SvxSetItem::Create(SvStream
&rStrm
, USHORT
/*nVersion*/) const
324 SfxItemSet
* _pSet
= new SfxItemSet( *GetItemSet().GetPool(),
325 GetItemSet().GetRanges() );
327 _pSet
->Load( rStrm
);
329 return new SvxSetItem( Which(), *_pSet
);
332 SvStream
& SvxSetItem::Store(SvStream
&rStrm
, USHORT nItemVersion
) const
334 GetItemSet().Store( rStrm
, nItemVersion
);