1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <tools/stream.hxx>
23 #include <svx/pageitem.hxx>
24 #include <editeng/itemtype.hxx>
25 #include <svx/unomid.hxx>
26 #include <com/sun/star/style/PageStyleLayout.hpp>
27 #include <com/sun/star/style/BreakType.hpp>
28 #include <svl/itemset.hxx>
29 #include <svx/svxitems.hrc>
30 #include <svx/dialmgr.hxx>
32 using namespace ::rtl
;
33 using namespace ::com::sun::star
;
35 // STATIC DATA -----------------------------------------------------------
37 TYPEINIT1_FACTORY( SvxPageItem
, SfxPoolItem
, new SvxPageItem(0));
39 /*--------------------------------------------------------------------
40 Beschreibung: Konstruktor
41 --------------------------------------------------------------------*/
43 SvxPageItem::SvxPageItem( const sal_uInt16 nId
) : SfxPoolItem( nId
),
45 eNumType ( SVX_ARABIC
),
46 bLandscape ( sal_False
),
51 /*--------------------------------------------------------------------
52 Beschreibung: Copy-Konstruktor
53 --------------------------------------------------------------------*/
55 SvxPageItem::SvxPageItem( const SvxPageItem
& rItem
)
56 : SfxPoolItem( rItem
)
58 eNumType
= rItem
.eNumType
;
59 bLandscape
= rItem
.bLandscape
;
63 /*--------------------------------------------------------------------
65 --------------------------------------------------------------------*/
67 SfxPoolItem
* SvxPageItem::Clone( SfxItemPool
* ) const
69 return new SvxPageItem( *this );
72 /*--------------------------------------------------------------------
73 Beschreibung: Abfrage auf Gleichheit
74 --------------------------------------------------------------------*/
76 int SvxPageItem::operator==( const SfxPoolItem
& rAttr
) const
78 DBG_ASSERT( SfxPoolItem::operator==(rAttr
), "unequal types" );
79 const SvxPageItem
& rItem
= (SvxPageItem
&)rAttr
;
80 return ( eNumType
== rItem
.eNumType
&&
81 bLandscape
== rItem
.bLandscape
&&
85 inline XubString
GetUsageText( const sal_uInt16 eU
)
89 case SVX_PAGE_LEFT
: return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT
);
90 case SVX_PAGE_RIGHT
: return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT
);
91 case SVX_PAGE_ALL
: return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL
);
92 case SVX_PAGE_MIRROR
: return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR
);
93 default: return String();
97 //------------------------------------------------------------------------
99 SfxItemPresentation
SvxPageItem::GetPresentation
101 SfxItemPresentation ePres
,
102 SfxMapUnit
/*eCoreUnit*/,
103 SfxMapUnit
/*ePresUnit*/,
104 OUString
& rText
, const IntlWrapper
*
108 OUString cpDelimTmp
= OUString(cpDelim
);
112 case SFX_ITEM_PRESENTATION_NONE
:
113 return SFX_ITEM_PRESENTATION_NONE
;
114 case SFX_ITEM_PRESENTATION_NAMELESS
:
116 if ( aDescName
.Len() )
118 rText
= aDescName
+ cpDelimTmp
;
120 DBG_ASSERT( eNumType
<= SVX_NUMBER_NONE
, "enum overflow" );
121 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN
+ eNumType
) + cpDelimTmp
;
123 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE
);
125 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE
);
126 String aUsageText
= GetUsageText( eUse
);
127 if (aUsageText
.Len())
129 rText
+= cpDelimTmp
+ aUsageText
;
131 return SFX_ITEM_PRESENTATION_NAMELESS
;
133 case SFX_ITEM_PRESENTATION_COMPLETE
:
135 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE
);
136 if ( aDescName
.Len() )
138 rText
+= aDescName
+ cpDelimTmp
;
140 DBG_ASSERT( eNumType
<= SVX_NUMBER_NONE
, "enum overflow" );
141 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN
+ eNumType
) + cpDelimTmp
;
143 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE
);
145 rText
+= SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE
);
146 String aUsageText
= GetUsageText( eUse
);
147 if (aUsageText
.Len())
149 rText
+= cpDelimTmp
+ aUsageText
;
151 return SFX_ITEM_PRESENTATION_COMPLETE
;
153 default: ;//prevent warning
155 return SFX_ITEM_PRESENTATION_NONE
;
158 //------------------------------------------------------------------------
159 bool SvxPageItem::QueryValue( uno::Any
& rVal
, sal_uInt8 nMemberId
) const
161 // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
162 nMemberId
&= ~CONVERT_TWIPS
;
165 case MID_PAGE_NUMTYPE
:
167 //! die Konstanten sind nicht mehr in den IDLs ?!?
168 rVal
<<= (sal_Int16
)( eNumType
);
171 case MID_PAGE_ORIENTATION
:
172 //Landscape= sal_True
173 rVal
= Bool2Any(bLandscape
);
175 case MID_PAGE_LAYOUT
:
177 style::PageStyleLayout eRet
;
180 case SVX_PAGE_LEFT
: eRet
= style::PageStyleLayout_LEFT
; break;
181 case SVX_PAGE_RIGHT
: eRet
= style::PageStyleLayout_RIGHT
; break;
182 case SVX_PAGE_ALL
: eRet
= style::PageStyleLayout_ALL
; break;
183 case SVX_PAGE_MIRROR
: eRet
= style::PageStyleLayout_MIRRORED
; break;
185 OSL_FAIL("was fuer ein Layout ist das?");
195 //------------------------------------------------------------------------
196 bool SvxPageItem::PutValue( const uno::Any
& rVal
, sal_uInt8 nMemberId
)
200 case MID_PAGE_NUMTYPE
:
202 sal_Int32 nValue
= 0;
203 if(!(rVal
>>= nValue
))
206 eNumType
= (SvxNumType
)nValue
;
209 case MID_PAGE_ORIENTATION
:
210 bLandscape
= Any2Bool(rVal
);
212 case MID_PAGE_LAYOUT
:
214 style::PageStyleLayout eLayout
;
215 if(!(rVal
>>= eLayout
))
217 sal_Int32 nValue
= 0;
218 if(!(rVal
>>= nValue
))
220 eLayout
= (style::PageStyleLayout
)nValue
;
225 case style::PageStyleLayout_LEFT
: eUse
|= SVX_PAGE_LEFT
; break;
226 case style::PageStyleLayout_RIGHT
: eUse
|= SVX_PAGE_RIGHT
; break;
227 case style::PageStyleLayout_ALL
: eUse
|= SVX_PAGE_ALL
; break;
228 case style::PageStyleLayout_MIRRORED
: eUse
|= SVX_PAGE_MIRROR
;break;
229 default: ;//prevent warning
237 //------------------------------------------------------------------------
239 SfxPoolItem
* SvxPageItem::Create( SvStream
& rStream
, sal_uInt16
) const
245 // UNICODE: rStream >> sStr;
246 XubString sStr
= rStream
.ReadUniOrByteString( rStream
.GetStreamCharSet() );
252 SvxPageItem
* pPage
= new SvxPageItem( Which() );
253 pPage
->SetDescName( sStr
);
254 pPage
->SetNumType( (SvxNumType
)eType
);
255 pPage
->SetLandscape( bLand
);
256 pPage
->SetPageUsage( nUse
);
260 //------------------------------------------------------------------------
262 SvStream
& SvxPageItem::Store( SvStream
&rStrm
, sal_uInt16
/*nItemVersion*/ ) const
264 // UNICODE: rStrm << aDescName;
265 rStrm
.WriteUniOrByteString(aDescName
, rStrm
.GetStreamCharSet());
267 rStrm
<< (sal_uInt8
)eNumType
<< bLandscape
<< eUse
;
271 /*--------------------------------------------------------------------
272 Beschreibung: HeaderFooterSet
273 --------------------------------------------------------------------*/
275 SvxSetItem::SvxSetItem( const sal_uInt16 nId
, const SfxItemSet
& rSet
) :
277 SfxSetItem( nId
, rSet
)
281 SvxSetItem::SvxSetItem( const SvxSetItem
& rItem
) :
287 SvxSetItem::SvxSetItem( const sal_uInt16 nId
, SfxItemSet
* _pSet
) :
289 SfxSetItem( nId
, _pSet
)
293 SfxPoolItem
* SvxSetItem::Clone( SfxItemPool
* ) const
295 return new SvxSetItem(*this);
298 //------------------------------------------------------------------------
300 SfxItemPresentation
SvxSetItem::GetPresentation
302 SfxItemPresentation
/*ePres*/,
303 SfxMapUnit
/*eCoreUnit*/,
304 SfxMapUnit
/*ePresUnit*/,
305 OUString
& rText
, const IntlWrapper
*
309 return SFX_ITEM_PRESENTATION_NONE
;
312 SfxPoolItem
* SvxSetItem::Create(SvStream
&rStrm
, sal_uInt16
/*nVersion*/) const
314 SfxItemSet
* _pSet
= new SfxItemSet( *GetItemSet().GetPool(),
315 GetItemSet().GetRanges() );
317 _pSet
->Load( rStrm
);
319 return new SvxSetItem( Which(), *_pSet
);
322 SvStream
& SvxSetItem::Store(SvStream
&rStrm
, sal_uInt16 nItemVersion
) const
324 GetItemSet().Store( rStrm
, nItemVersion
);
330 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */