xref: /aoo41x/main/svx/source/items/pageitem.cxx (revision 09e49f8f)
1f6e50924SAndrew Rist /**************************************************************
2*09e49f8fSmseidel  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*09e49f8fSmseidel  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*09e49f8fSmseidel  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19*09e49f8fSmseidel  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir // include ---------------------------------------------------------------
28cdf0e10cSrcweir #include <tools/stream.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <svx/pageitem.hxx>
32cdf0e10cSrcweir #include <editeng/itemtype.hxx>
33cdf0e10cSrcweir #include <svx/unomid.hxx>
34cdf0e10cSrcweir #include <com/sun/star/style/PageStyleLayout.hpp>
35cdf0e10cSrcweir #include <com/sun/star/style/BreakType.hpp>
36cdf0e10cSrcweir #include <svl/itemset.hxx>
37cdf0e10cSrcweir #include <svx/svxitems.hrc>
38cdf0e10cSrcweir #include <svx/dialmgr.hxx>
39cdf0e10cSrcweir 
40cdf0e10cSrcweir using namespace ::rtl;
41cdf0e10cSrcweir using namespace ::com::sun::star;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // STATIC DATA -----------------------------------------------------------
44cdf0e10cSrcweir 
45*09e49f8fSmseidel TYPEINIT1_FACTORY( SvxPageItem, SfxPoolItem , new SvxPageItem(0));
46cdf0e10cSrcweir 
47cdf0e10cSrcweir /*--------------------------------------------------------------------
48*09e49f8fSmseidel 	Description: Constructor
49cdf0e10cSrcweir  --------------------------------------------------------------------*/
50cdf0e10cSrcweir 
SvxPageItem(const sal_uInt16 nId)51cdf0e10cSrcweir SvxPageItem::SvxPageItem( const sal_uInt16 nId ) : SfxPoolItem( nId ),
52cdf0e10cSrcweir 
53cdf0e10cSrcweir 	eNumType	( SVX_ARABIC ),
54cdf0e10cSrcweir 	bLandscape	( sal_False ),
55cdf0e10cSrcweir 	eUse		( SVX_PAGE_ALL )
56cdf0e10cSrcweir {
57cdf0e10cSrcweir }
58cdf0e10cSrcweir 
59cdf0e10cSrcweir /*--------------------------------------------------------------------
60*09e49f8fSmseidel 	Description: Copy-Constructor
61cdf0e10cSrcweir  --------------------------------------------------------------------*/
62cdf0e10cSrcweir 
SvxPageItem(const SvxPageItem & rItem)63cdf0e10cSrcweir SvxPageItem::SvxPageItem( const SvxPageItem& rItem )
64cdf0e10cSrcweir 	: SfxPoolItem( rItem )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir 	eNumType 	= rItem.eNumType;
67cdf0e10cSrcweir 	bLandscape 	= rItem.bLandscape;
68cdf0e10cSrcweir 	eUse 		= rItem.eUse;
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir /*--------------------------------------------------------------------
72*09e49f8fSmseidel 	Description: Clone
73cdf0e10cSrcweir  --------------------------------------------------------------------*/
74cdf0e10cSrcweir 
Clone(SfxItemPool *) const75cdf0e10cSrcweir SfxPoolItem* SvxPageItem::Clone( SfxItemPool * ) const
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	return new SvxPageItem( *this );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir /*--------------------------------------------------------------------
81*09e49f8fSmseidel 	Description: Query on equality
82cdf0e10cSrcweir  --------------------------------------------------------------------*/
83cdf0e10cSrcweir 
operator ==(const SfxPoolItem & rAttr) const84cdf0e10cSrcweir int SvxPageItem::operator==( const SfxPoolItem& rAttr ) const
85cdf0e10cSrcweir {
86cdf0e10cSrcweir 	DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
87cdf0e10cSrcweir 	const SvxPageItem& rItem = (SvxPageItem&)rAttr;
88cdf0e10cSrcweir 	return ( eNumType 	== rItem.eNumType 	&&
89cdf0e10cSrcweir 			 bLandscape == rItem.bLandscape &&
90cdf0e10cSrcweir 			 eUse 		== rItem.eUse );
91cdf0e10cSrcweir }
92cdf0e10cSrcweir 
GetUsageText(const sal_uInt16 eU)93cdf0e10cSrcweir inline XubString GetUsageText( const sal_uInt16 eU )
94cdf0e10cSrcweir {
95*09e49f8fSmseidel 	switch( eU & 0x000f )
96*09e49f8fSmseidel 	{
97*09e49f8fSmseidel 		case SVX_PAGE_LEFT:		return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT);
98*09e49f8fSmseidel 		case SVX_PAGE_RIGHT:	return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT);
99*09e49f8fSmseidel 		case SVX_PAGE_ALL:		return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL);
100*09e49f8fSmseidel 		case SVX_PAGE_MIRROR:	return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR);
101*09e49f8fSmseidel 		default: return String();
102*09e49f8fSmseidel 	}
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir //------------------------------------------------------------------------
106cdf0e10cSrcweir 
GetPresentation(SfxItemPresentation ePres,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const107cdf0e10cSrcweir SfxItemPresentation SvxPageItem::GetPresentation
108cdf0e10cSrcweir (
109*09e49f8fSmseidel 	SfxItemPresentation	ePres,
110*09e49f8fSmseidel 	SfxMapUnit			/*eCoreUnit*/,
111*09e49f8fSmseidel 	SfxMapUnit			/*ePresUnit*/,
112*09e49f8fSmseidel 	XubString&			rText, const IntlWrapper *
113cdf0e10cSrcweir )	const
114cdf0e10cSrcweir {
115cdf0e10cSrcweir 	rText.Erase();
116cdf0e10cSrcweir 
117*09e49f8fSmseidel 	switch( ePres )
118cdf0e10cSrcweir 	{
119cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NONE:
120cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NONE;
121cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_NAMELESS:
122cdf0e10cSrcweir 		{
123cdf0e10cSrcweir 			if ( aDescName.Len() )
124cdf0e10cSrcweir 			{
125cdf0e10cSrcweir 				rText = aDescName;
126cdf0e10cSrcweir 				rText += cpDelim;
127cdf0e10cSrcweir 			}
128cdf0e10cSrcweir 			DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" );
129cdf0e10cSrcweir 			rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType);
130cdf0e10cSrcweir 			rText += cpDelim;
131cdf0e10cSrcweir 			if ( bLandscape )
132cdf0e10cSrcweir 				rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE);
133cdf0e10cSrcweir 			else
134cdf0e10cSrcweir 				rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE);
135*09e49f8fSmseidel 			rText += cpDelim;
136cdf0e10cSrcweir 			rText += GetUsageText( eUse );
137cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_NAMELESS;
138cdf0e10cSrcweir 		}
139cdf0e10cSrcweir 		case SFX_ITEM_PRESENTATION_COMPLETE:
140cdf0e10cSrcweir 		{
141cdf0e10cSrcweir 			rText += SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE);
142cdf0e10cSrcweir 			if ( aDescName.Len() )
143cdf0e10cSrcweir 			{
144cdf0e10cSrcweir 				rText += aDescName;
145cdf0e10cSrcweir 				rText += cpDelim;
146cdf0e10cSrcweir 			}
147cdf0e10cSrcweir 			DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" );
148cdf0e10cSrcweir 			rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType);
149cdf0e10cSrcweir 			rText += cpDelim;
150cdf0e10cSrcweir 			if ( bLandscape )
151cdf0e10cSrcweir 				rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE);
152cdf0e10cSrcweir 			else
153cdf0e10cSrcweir 				rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE);
154*09e49f8fSmseidel 			rText += cpDelim;
155cdf0e10cSrcweir 			rText += GetUsageText( eUse );
156cdf0e10cSrcweir 			return SFX_ITEM_PRESENTATION_COMPLETE;
157cdf0e10cSrcweir 		}
158*09e49f8fSmseidel 		default: ; // prevent warning
159cdf0e10cSrcweir 	}
160cdf0e10cSrcweir 	return SFX_ITEM_PRESENTATION_NONE;
161cdf0e10cSrcweir }
162cdf0e10cSrcweir 
163cdf0e10cSrcweir //------------------------------------------------------------------------
QueryValue(uno::Any & rVal,sal_uInt8 nMemberId) const164cdf0e10cSrcweir sal_Bool SvxPageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const
165cdf0e10cSrcweir {
166*09e49f8fSmseidel //	sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS);
167*09e49f8fSmseidel 	nMemberId &= ~CONVERT_TWIPS;
168cdf0e10cSrcweir 	switch( nMemberId )
169cdf0e10cSrcweir 	{
170cdf0e10cSrcweir 		case MID_PAGE_NUMTYPE:
171cdf0e10cSrcweir 		{
172cdf0e10cSrcweir 			//!	die Konstanten sind nicht mehr in den IDLs ?!?
173cdf0e10cSrcweir 			rVal <<= (sal_Int16)( eNumType );
174cdf0e10cSrcweir 		}
175cdf0e10cSrcweir 		break;
176cdf0e10cSrcweir 		case MID_PAGE_ORIENTATION:
177cdf0e10cSrcweir 			//Landscape= sal_True
178cdf0e10cSrcweir 			rVal = Bool2Any(bLandscape);
179cdf0e10cSrcweir 		break;
180*09e49f8fSmseidel 		case MID_PAGE_LAYOUT :
181cdf0e10cSrcweir 		{
182cdf0e10cSrcweir 			style::PageStyleLayout eRet;
183*09e49f8fSmseidel 			switch( eUse & 0x0f )
184cdf0e10cSrcweir 			{
185*09e49f8fSmseidel 				case SVX_PAGE_LEFT:		eRet = style::PageStyleLayout_LEFT;		break;
186*09e49f8fSmseidel 				case SVX_PAGE_RIGHT:	eRet = style::PageStyleLayout_RIGHT;	break;
187*09e49f8fSmseidel 				case SVX_PAGE_ALL:		eRet = style::PageStyleLayout_ALL;		break;
188*09e49f8fSmseidel 				case SVX_PAGE_MIRROR:	eRet = style::PageStyleLayout_MIRRORED;	break;
189cdf0e10cSrcweir 				default:
190*09e49f8fSmseidel 					DBG_ERROR("What kind of layout is this?");
191cdf0e10cSrcweir 					return sal_False;
192cdf0e10cSrcweir 			}
193cdf0e10cSrcweir 			rVal <<= eRet;
194cdf0e10cSrcweir 		}
195cdf0e10cSrcweir 		break;
196cdf0e10cSrcweir 	}
197cdf0e10cSrcweir 
198cdf0e10cSrcweir 	return sal_True;
199cdf0e10cSrcweir }
200cdf0e10cSrcweir //------------------------------------------------------------------------
PutValue(const uno::Any & rVal,sal_uInt8 nMemberId)201cdf0e10cSrcweir sal_Bool SvxPageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
202cdf0e10cSrcweir {
203cdf0e10cSrcweir 	switch( nMemberId )
204cdf0e10cSrcweir 	{
205cdf0e10cSrcweir 		case MID_PAGE_NUMTYPE:
206cdf0e10cSrcweir 		{
207cdf0e10cSrcweir 			sal_Int32 nValue = 0;
208cdf0e10cSrcweir 			if(!(rVal >>= nValue))
209cdf0e10cSrcweir 				return sal_False;
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 			eNumType = (SvxNumType)nValue;
212cdf0e10cSrcweir 		}
213cdf0e10cSrcweir 		break;
214cdf0e10cSrcweir 		case MID_PAGE_ORIENTATION:
215cdf0e10cSrcweir 			bLandscape = Any2Bool(rVal);
216cdf0e10cSrcweir 		break;
217*09e49f8fSmseidel 		case MID_PAGE_LAYOUT :
218cdf0e10cSrcweir 		{
219cdf0e10cSrcweir 			style::PageStyleLayout eLayout;
220cdf0e10cSrcweir 			if(!(rVal >>= eLayout))
221cdf0e10cSrcweir 			{
222cdf0e10cSrcweir 				sal_Int32 nValue = 0;
223cdf0e10cSrcweir 				if(!(rVal >>= nValue))
224cdf0e10cSrcweir 					return sal_False;
225cdf0e10cSrcweir 				eLayout = (style::PageStyleLayout)nValue;
226cdf0e10cSrcweir 			}
227cdf0e10cSrcweir 			eUse &= 0xfff0;
228cdf0e10cSrcweir 			switch( eLayout )
229cdf0e10cSrcweir 			{
230*09e49f8fSmseidel 				case style::PageStyleLayout_LEFT:		eUse |= SVX_PAGE_LEFT ;		break;
231*09e49f8fSmseidel 				case style::PageStyleLayout_RIGHT:		eUse |= SVX_PAGE_RIGHT ;	break;
232*09e49f8fSmseidel 				case style::PageStyleLayout_ALL:		eUse |= SVX_PAGE_ALL ;		break;
233*09e49f8fSmseidel 				case style::PageStyleLayout_MIRRORED:	eUse |= SVX_PAGE_MIRROR ;	break;
234*09e49f8fSmseidel 				default: ; // prevent warning
235*09e49f8fSmseidel 			}
236cdf0e10cSrcweir 		}
237cdf0e10cSrcweir 		break;
238cdf0e10cSrcweir 	}
239cdf0e10cSrcweir 	return sal_True;
240cdf0e10cSrcweir }
241cdf0e10cSrcweir 
242cdf0e10cSrcweir //------------------------------------------------------------------------
243cdf0e10cSrcweir 
Create(SvStream & rStream,sal_uInt16) const244cdf0e10cSrcweir SfxPoolItem* SvxPageItem::Create( SvStream& rStream, sal_uInt16 ) const
245cdf0e10cSrcweir {
246cdf0e10cSrcweir 	XubString sStr;
247cdf0e10cSrcweir 	sal_uInt8 eType;
248cdf0e10cSrcweir 	sal_Bool bLand;
249cdf0e10cSrcweir 	sal_uInt16 nUse;
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 	// UNICODE: rStream >> sStr;
252cdf0e10cSrcweir 	rStream.ReadByteString( sStr );
253cdf0e10cSrcweir 
254cdf0e10cSrcweir 	rStream >> eType;
255cdf0e10cSrcweir 	rStream >> bLand;
256cdf0e10cSrcweir 	rStream >> nUse;
257cdf0e10cSrcweir 
258cdf0e10cSrcweir 	SvxPageItem* pPage = new SvxPageItem( Which() );
259cdf0e10cSrcweir 	pPage->SetDescName( sStr );
260cdf0e10cSrcweir 	pPage->SetNumType( (SvxNumType)eType );
261cdf0e10cSrcweir 	pPage->SetLandscape( bLand );
262cdf0e10cSrcweir 	pPage->SetPageUsage( nUse );
263cdf0e10cSrcweir 	return pPage;
264cdf0e10cSrcweir }
265cdf0e10cSrcweir 
266cdf0e10cSrcweir //------------------------------------------------------------------------
267cdf0e10cSrcweir 
Store(SvStream & rStrm,sal_uInt16) const268cdf0e10cSrcweir SvStream& SvxPageItem::Store( SvStream &rStrm, sal_uInt16 /*nItemVersion*/ ) const
269cdf0e10cSrcweir {
270cdf0e10cSrcweir 	// UNICODE: rStrm << aDescName;
271cdf0e10cSrcweir 	rStrm.WriteByteString(aDescName);
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 	rStrm << (sal_uInt8)eNumType << bLandscape << eUse;
274cdf0e10cSrcweir 	return rStrm;
275cdf0e10cSrcweir }
276cdf0e10cSrcweir 
277cdf0e10cSrcweir /*--------------------------------------------------------------------
278*09e49f8fSmseidel 	Description: HeaderFooterSet
279cdf0e10cSrcweir  --------------------------------------------------------------------*/
280cdf0e10cSrcweir 
SvxSetItem(const sal_uInt16 nId,const SfxItemSet & rSet)281cdf0e10cSrcweir SvxSetItem::SvxSetItem( const sal_uInt16 nId, const SfxItemSet& rSet ) :
282cdf0e10cSrcweir 
283cdf0e10cSrcweir 	SfxSetItem( nId, rSet )
284cdf0e10cSrcweir {
285cdf0e10cSrcweir }
286cdf0e10cSrcweir 
SvxSetItem(const SvxSetItem & rItem)287cdf0e10cSrcweir SvxSetItem::SvxSetItem( const SvxSetItem& rItem ) :
288cdf0e10cSrcweir 
289cdf0e10cSrcweir 	SfxSetItem( rItem )
290cdf0e10cSrcweir {
291cdf0e10cSrcweir }
292cdf0e10cSrcweir 
SvxSetItem(const sal_uInt16 nId,SfxItemSet * _pSet)293cdf0e10cSrcweir SvxSetItem::SvxSetItem( const sal_uInt16 nId, SfxItemSet* _pSet ) :
294cdf0e10cSrcweir 
295*09e49f8fSmseidel 	SfxSetItem( nId, _pSet )
296cdf0e10cSrcweir {
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
Clone(SfxItemPool *) const299cdf0e10cSrcweir SfxPoolItem* SvxSetItem::Clone( SfxItemPool * ) const
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	return new SvxSetItem(*this);
302cdf0e10cSrcweir }
303cdf0e10cSrcweir 
304cdf0e10cSrcweir //------------------------------------------------------------------------
305cdf0e10cSrcweir 
GetPresentation(SfxItemPresentation,SfxMapUnit,SfxMapUnit,XubString & rText,const IntlWrapper *) const306cdf0e10cSrcweir SfxItemPresentation SvxSetItem::GetPresentation
307cdf0e10cSrcweir (
308*09e49f8fSmseidel 	SfxItemPresentation	/*ePres*/,
309*09e49f8fSmseidel 	SfxMapUnit			/*eCoreUnit*/,
310*09e49f8fSmseidel 	SfxMapUnit			/*ePresUnit*/,
311*09e49f8fSmseidel 	XubString&			rText, const IntlWrapper *
312cdf0e10cSrcweir )	const
313cdf0e10cSrcweir {
314cdf0e10cSrcweir 	rText.Erase();
315cdf0e10cSrcweir 	return SFX_ITEM_PRESENTATION_NONE;
316cdf0e10cSrcweir }
317cdf0e10cSrcweir 
Create(SvStream & rStrm,sal_uInt16) const318cdf0e10cSrcweir SfxPoolItem* SvxSetItem::Create(SvStream &rStrm, sal_uInt16 /*nVersion*/) const
319cdf0e10cSrcweir {
320*09e49f8fSmseidel 	SfxItemSet* _pSet = new SfxItemSet( *GetItemSet().GetPool(),
321*09e49f8fSmseidel 										 GetItemSet().GetRanges() );
322cdf0e10cSrcweir 
323*09e49f8fSmseidel 	_pSet->Load( rStrm );
324cdf0e10cSrcweir 
325*09e49f8fSmseidel 	return new SvxSetItem( Which(), *_pSet );
326cdf0e10cSrcweir }
327cdf0e10cSrcweir 
Store(SvStream & rStrm,sal_uInt16 nItemVersion) const328cdf0e10cSrcweir SvStream& SvxSetItem::Store(SvStream &rStrm, sal_uInt16 nItemVersion) const
329cdf0e10cSrcweir {
330cdf0e10cSrcweir 	GetItemSet().Store( rStrm, nItemVersion );
331cdf0e10cSrcweir 
332cdf0e10cSrcweir 	return rStrm;
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335*09e49f8fSmseidel /* vim: set noet sw=4 ts=4: */
336