1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 // include ---------------------------------------------------------------
31 #include <tools/stream.hxx>
34 #include <svx/pageitem.hxx>
35 #include <editeng/itemtype.hxx>
36 #include <svx/unomid.hxx>
37 #include <com/sun/star/style/PageStyleLayout.hpp>
38 #include <com/sun/star/style/BreakType.hpp>
39 #include <svl/itemset.hxx>
40 #include <svx/svxitems.hrc>
41 #include <svx/dialmgr.hxx>
43 using namespace ::rtl
;
44 using namespace ::com::sun::star
;
46 // STATIC DATA -----------------------------------------------------------
48 TYPEINIT1_FACTORY( SvxPageItem
, SfxPoolItem
, new SvxPageItem(0));
50 /*--------------------------------------------------------------------
51 Beschreibung: Konstruktor
52 --------------------------------------------------------------------*/
54 SvxPageItem::SvxPageItem( const sal_uInt16 nId
) : SfxPoolItem( nId
),
56 eNumType ( SVX_ARABIC
),
57 bLandscape ( sal_False
),
62 /*--------------------------------------------------------------------
63 Beschreibung: Copy-Konstruktor
64 --------------------------------------------------------------------*/
66 SvxPageItem::SvxPageItem( const SvxPageItem
& rItem
)
67 : SfxPoolItem( rItem
)
69 eNumType
= rItem
.eNumType
;
70 bLandscape
= rItem
.bLandscape
;
74 /*--------------------------------------------------------------------
76 --------------------------------------------------------------------*/
78 SfxPoolItem
* SvxPageItem::Clone( SfxItemPool
* ) const
80 return new SvxPageItem( *this );
83 /*--------------------------------------------------------------------
84 Beschreibung: Abfrage auf Gleichheit
85 --------------------------------------------------------------------*/
87 int SvxPageItem::operator==( const SfxPoolItem
& rAttr
) const
89 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
90 const SvxPageItem
& rItem
= (SvxPageItem
&)rAttr
;
91 return ( eNumType
== rItem
.eNumType
&&
92 bLandscape
== rItem
.bLandscape
&&
96 inline XubString
GetUsageText( const sal_uInt16 eU
)
98 if ( eU
& SVX_PAGE_LEFT
)
99 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT
);
100 if ( eU
& SVX_PAGE_RIGHT
)
101 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT
);
102 if ( eU
& SVX_PAGE_ALL
)
103 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL
);
104 if ( eU
& SVX_PAGE_MIRROR
)
105 return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR
);
109 //------------------------------------------------------------------------
111 SfxItemPresentation
SvxPageItem::GetPresentation
113 SfxItemPresentation ePres
,
114 SfxMapUnit
/*eCoreUnit*/,
115 SfxMapUnit
/*ePresUnit*/,
116 XubString
& rText
, const IntlWrapper
*
123 case SFX_ITEM_PRESENTATION_NONE
:
124 return SFX_ITEM_PRESENTATION_NONE
;
125 case SFX_ITEM_PRESENTATION_NAMELESS
:
127 if ( aDescName
.Len() )
132 DBG_ASSERT( eNumType
<= SVX_NUMBER_NONE
, "enum overflow" );
133 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN
+ eNumType
);
136 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE
);
138 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE
);
139 String aUsageText
= GetUsageText( eUse
);
140 if (aUsageText
.Len())
145 return SFX_ITEM_PRESENTATION_NAMELESS
;
147 case SFX_ITEM_PRESENTATION_COMPLETE
:
149 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE
);
150 if ( aDescName
.Len() )
155 DBG_ASSERT( eNumType
<= SVX_NUMBER_NONE
, "enum overflow" );
156 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN
+ eNumType
);
159 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE
);
161 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE
);
162 String aUsageText
= GetUsageText( eUse
);
163 if (aUsageText
.Len())
168 return SFX_ITEM_PRESENTATION_COMPLETE
;
170 default: ;//prevent warning
172 return SFX_ITEM_PRESENTATION_NONE
;
175 //------------------------------------------------------------------------
176 bool SvxPageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
178 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
179 nMemberId
&= ~CONVERT_TWIPS
;
182 case MID_PAGE_NUMTYPE
:
184 //! die Konstanten sind nicht mehr in den IDLs ?!?
185 rVal
<<= (sal_Int16
)( eNumType
);
188 case MID_PAGE_ORIENTATION
:
189 //Landscape= sal_True
190 rVal
= Bool2Any(bLandscape
);
192 case MID_PAGE_LAYOUT
:
194 style::PageStyleLayout eRet
;
197 case SVX_PAGE_LEFT
: eRet
= style::PageStyleLayout_LEFT
; break;
198 case SVX_PAGE_RIGHT
: eRet
= style::PageStyleLayout_RIGHT
; break;
199 case SVX_PAGE_ALL
: eRet
= style::PageStyleLayout_ALL
; break;
200 case SVX_PAGE_MIRROR
: eRet
= style::PageStyleLayout_MIRRORED
; break;
202 OSL_FAIL("was fuer ein Layout ist das?");
212 //------------------------------------------------------------------------
213 bool SvxPageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
217 case MID_PAGE_NUMTYPE
:
219 sal_Int32 nValue
= 0;
220 if(!(rVal
>>= nValue
))
223 eNumType
= (SvxNumType
)nValue
;
226 case MID_PAGE_ORIENTATION
:
227 bLandscape
= Any2Bool(rVal
);
229 case MID_PAGE_LAYOUT
:
231 style::PageStyleLayout eLayout
;
232 if(!(rVal
>>= eLayout
))
234 sal_Int32 nValue
= 0;
235 if(!(rVal
>>= nValue
))
237 eLayout
= (style::PageStyleLayout
)nValue
;
242 case style::PageStyleLayout_LEFT
: eUse
|= SVX_PAGE_LEFT
; break;
243 case style::PageStyleLayout_RIGHT
: eUse
|= SVX_PAGE_RIGHT
; break;
244 case style::PageStyleLayout_ALL
: eUse
|= SVX_PAGE_ALL
; break;
245 case style::PageStyleLayout_MIRRORED
: eUse
|= SVX_PAGE_MIRROR
;break;
246 default: ;//prevent warning
254 //------------------------------------------------------------------------
256 SfxPoolItem
* SvxPageItem::Create( SvStream
& rStream
, sal_uInt16
) const
262 // UNICODE: rStream >> sStr;
263 XubString sStr
= rStream
.ReadUniOrByteString( rStream
.GetStreamCharSet() );
269 SvxPageItem
* pPage
= new SvxPageItem( Which() );
270 pPage
->SetDescName( sStr
);
271 pPage
->SetNumType( (SvxNumType
)eType
);
272 pPage
->SetLandscape( bLand
);
273 pPage
->SetPageUsage( nUse
);
277 //------------------------------------------------------------------------
279 SvStream
& SvxPageItem::Store( SvStream
&rStrm
, sal_uInt16
/*nItemVersion*/ ) const
281 // UNICODE: rStrm << aDescName;
282 rStrm
.WriteUniOrByteString(aDescName
, rStrm
.GetStreamCharSet());
284 rStrm
<< (sal_uInt8
)eNumType
<< bLandscape
<< eUse
;
288 /*--------------------------------------------------------------------
289 Beschreibung: HeaderFooterSet
290 --------------------------------------------------------------------*/
292 SvxSetItem::SvxSetItem( const sal_uInt16 nId
, const SfxItemSet
& rSet
) :
294 SfxSetItem( nId
, rSet
)
298 SvxSetItem::SvxSetItem( const SvxSetItem
& rItem
) :
304 SvxSetItem::SvxSetItem( const sal_uInt16 nId
, SfxItemSet
* _pSet
) :
306 SfxSetItem( nId
, _pSet
)
310 SfxPoolItem
* SvxSetItem::Clone( SfxItemPool
* ) const
312 return new SvxSetItem(*this);
315 //------------------------------------------------------------------------
317 SfxItemPresentation
SvxSetItem::GetPresentation
319 SfxItemPresentation
/*ePres*/,
320 SfxMapUnit
/*eCoreUnit*/,
321 SfxMapUnit
/*ePresUnit*/,
322 XubString
& rText
, const IntlWrapper
*
326 return SFX_ITEM_PRESENTATION_NONE
;
329 SfxPoolItem
* SvxSetItem::Create(SvStream
&rStrm
, sal_uInt16
/*nVersion*/) const
331 SfxItemSet
* _pSet
= new SfxItemSet( *GetItemSet().GetPool(),
332 GetItemSet().GetRanges() );
334 _pSet
->Load( rStrm
);
336 return new SvxSetItem( Which(), *_pSet
);
339 SvStream
& SvxSetItem::Store(SvStream
&rStrm
, sal_uInt16 nItemVersion
) const
341 GetItemSet().Store( rStrm
, nItemVersion
);
347 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */