1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir // include --------------------------------------------------------------- 32*cdf0e10cSrcweir #include <tools/stream.hxx> 33*cdf0e10cSrcweir 34*cdf0e10cSrcweir 35*cdf0e10cSrcweir #include <svx/pageitem.hxx> 36*cdf0e10cSrcweir #include <editeng/itemtype.hxx> 37*cdf0e10cSrcweir #include <svx/unomid.hxx> 38*cdf0e10cSrcweir #include <com/sun/star/style/PageStyleLayout.hpp> 39*cdf0e10cSrcweir #include <com/sun/star/style/BreakType.hpp> 40*cdf0e10cSrcweir #include <svl/itemset.hxx> 41*cdf0e10cSrcweir #include <svx/svxitems.hrc> 42*cdf0e10cSrcweir #include <svx/dialmgr.hxx> 43*cdf0e10cSrcweir 44*cdf0e10cSrcweir using namespace ::rtl; 45*cdf0e10cSrcweir using namespace ::com::sun::star; 46*cdf0e10cSrcweir 47*cdf0e10cSrcweir // STATIC DATA ----------------------------------------------------------- 48*cdf0e10cSrcweir 49*cdf0e10cSrcweir TYPEINIT1_FACTORY( SvxPageItem, SfxPoolItem , new SvxPageItem(0)); 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /*-------------------------------------------------------------------- 52*cdf0e10cSrcweir Beschreibung: Konstruktor 53*cdf0e10cSrcweir --------------------------------------------------------------------*/ 54*cdf0e10cSrcweir 55*cdf0e10cSrcweir SvxPageItem::SvxPageItem( const sal_uInt16 nId ) : SfxPoolItem( nId ), 56*cdf0e10cSrcweir 57*cdf0e10cSrcweir eNumType ( SVX_ARABIC ), 58*cdf0e10cSrcweir bLandscape ( sal_False ), 59*cdf0e10cSrcweir eUse ( SVX_PAGE_ALL ) 60*cdf0e10cSrcweir { 61*cdf0e10cSrcweir } 62*cdf0e10cSrcweir 63*cdf0e10cSrcweir /*-------------------------------------------------------------------- 64*cdf0e10cSrcweir Beschreibung: Copy-Konstruktor 65*cdf0e10cSrcweir --------------------------------------------------------------------*/ 66*cdf0e10cSrcweir 67*cdf0e10cSrcweir SvxPageItem::SvxPageItem( const SvxPageItem& rItem ) 68*cdf0e10cSrcweir : SfxPoolItem( rItem ) 69*cdf0e10cSrcweir { 70*cdf0e10cSrcweir eNumType = rItem.eNumType; 71*cdf0e10cSrcweir bLandscape = rItem.bLandscape; 72*cdf0e10cSrcweir eUse = rItem.eUse; 73*cdf0e10cSrcweir } 74*cdf0e10cSrcweir 75*cdf0e10cSrcweir /*-------------------------------------------------------------------- 76*cdf0e10cSrcweir Beschreibung: Clonen 77*cdf0e10cSrcweir --------------------------------------------------------------------*/ 78*cdf0e10cSrcweir 79*cdf0e10cSrcweir SfxPoolItem* SvxPageItem::Clone( SfxItemPool * ) const 80*cdf0e10cSrcweir { 81*cdf0e10cSrcweir return new SvxPageItem( *this ); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir 84*cdf0e10cSrcweir /*-------------------------------------------------------------------- 85*cdf0e10cSrcweir Beschreibung: Abfrage auf Gleichheit 86*cdf0e10cSrcweir --------------------------------------------------------------------*/ 87*cdf0e10cSrcweir 88*cdf0e10cSrcweir int SvxPageItem::operator==( const SfxPoolItem& rAttr ) const 89*cdf0e10cSrcweir { 90*cdf0e10cSrcweir DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); 91*cdf0e10cSrcweir const SvxPageItem& rItem = (SvxPageItem&)rAttr; 92*cdf0e10cSrcweir return ( eNumType == rItem.eNumType && 93*cdf0e10cSrcweir bLandscape == rItem.bLandscape && 94*cdf0e10cSrcweir eUse == rItem.eUse ); 95*cdf0e10cSrcweir } 96*cdf0e10cSrcweir 97*cdf0e10cSrcweir inline XubString GetUsageText( const sal_uInt16 eU ) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir if ( eU & SVX_PAGE_LEFT ) 100*cdf0e10cSrcweir return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_LEFT); 101*cdf0e10cSrcweir if ( eU & SVX_PAGE_RIGHT ) 102*cdf0e10cSrcweir return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_RIGHT); 103*cdf0e10cSrcweir if ( eU & SVX_PAGE_ALL ) 104*cdf0e10cSrcweir return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_ALL); 105*cdf0e10cSrcweir if ( eU & SVX_PAGE_MIRROR ) 106*cdf0e10cSrcweir return SVX_RESSTR(RID_SVXITEMS_PAGE_USAGE_MIRROR); 107*cdf0e10cSrcweir return String(); 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir //------------------------------------------------------------------------ 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir SfxItemPresentation SvxPageItem::GetPresentation 113*cdf0e10cSrcweir ( 114*cdf0e10cSrcweir SfxItemPresentation ePres, 115*cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/, 116*cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/, 117*cdf0e10cSrcweir XubString& rText, const IntlWrapper * 118*cdf0e10cSrcweir ) const 119*cdf0e10cSrcweir { 120*cdf0e10cSrcweir rText.Erase(); 121*cdf0e10cSrcweir 122*cdf0e10cSrcweir switch ( ePres ) 123*cdf0e10cSrcweir { 124*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NONE: 125*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 126*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_NAMELESS: 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir if ( aDescName.Len() ) 129*cdf0e10cSrcweir { 130*cdf0e10cSrcweir rText = aDescName; 131*cdf0e10cSrcweir rText += cpDelim; 132*cdf0e10cSrcweir } 133*cdf0e10cSrcweir DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" ); 134*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType); 135*cdf0e10cSrcweir rText += cpDelim; 136*cdf0e10cSrcweir if ( bLandscape ) 137*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE); 138*cdf0e10cSrcweir else 139*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE); 140*cdf0e10cSrcweir rText += GetUsageText( eUse ); 141*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NAMELESS; 142*cdf0e10cSrcweir } 143*cdf0e10cSrcweir case SFX_ITEM_PRESENTATION_COMPLETE: 144*cdf0e10cSrcweir { 145*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_COMPLETE); 146*cdf0e10cSrcweir if ( aDescName.Len() ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir rText += aDescName; 149*cdf0e10cSrcweir rText += cpDelim; 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir DBG_ASSERT( eNumType <= SVX_NUMBER_NONE, "enum overflow" ); 152*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_NUM_BEGIN + eNumType); 153*cdf0e10cSrcweir rText += cpDelim; 154*cdf0e10cSrcweir if ( bLandscape ) 155*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_TRUE); 156*cdf0e10cSrcweir else 157*cdf0e10cSrcweir rText += SVX_RESSTR(RID_SVXITEMS_PAGE_LAND_FALSE); 158*cdf0e10cSrcweir rText += GetUsageText( eUse ); 159*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_COMPLETE; 160*cdf0e10cSrcweir } 161*cdf0e10cSrcweir default: ;//prevent warning 162*cdf0e10cSrcweir } 163*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir 166*cdf0e10cSrcweir //------------------------------------------------------------------------ 167*cdf0e10cSrcweir sal_Bool SvxPageItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const 168*cdf0e10cSrcweir { 169*cdf0e10cSrcweir // sal_Bool bConvert = 0!=(nMemberId&CONVERT_TWIPS); 170*cdf0e10cSrcweir nMemberId &= ~CONVERT_TWIPS; 171*cdf0e10cSrcweir switch( nMemberId ) 172*cdf0e10cSrcweir { 173*cdf0e10cSrcweir case MID_PAGE_NUMTYPE: 174*cdf0e10cSrcweir { 175*cdf0e10cSrcweir //! die Konstanten sind nicht mehr in den IDLs ?!? 176*cdf0e10cSrcweir rVal <<= (sal_Int16)( eNumType ); 177*cdf0e10cSrcweir } 178*cdf0e10cSrcweir break; 179*cdf0e10cSrcweir case MID_PAGE_ORIENTATION: 180*cdf0e10cSrcweir //Landscape= sal_True 181*cdf0e10cSrcweir rVal = Bool2Any(bLandscape); 182*cdf0e10cSrcweir break; 183*cdf0e10cSrcweir case MID_PAGE_LAYOUT : 184*cdf0e10cSrcweir { 185*cdf0e10cSrcweir style::PageStyleLayout eRet; 186*cdf0e10cSrcweir switch(eUse & 0x0f) 187*cdf0e10cSrcweir { 188*cdf0e10cSrcweir case SVX_PAGE_LEFT : eRet = style::PageStyleLayout_LEFT; break; 189*cdf0e10cSrcweir case SVX_PAGE_RIGHT : eRet = style::PageStyleLayout_RIGHT; break; 190*cdf0e10cSrcweir case SVX_PAGE_ALL : eRet = style::PageStyleLayout_ALL; break; 191*cdf0e10cSrcweir case SVX_PAGE_MIRROR: eRet = style::PageStyleLayout_MIRRORED; break; 192*cdf0e10cSrcweir default: 193*cdf0e10cSrcweir DBG_ERROR("was fuer ein Layout ist das?"); 194*cdf0e10cSrcweir return sal_False; 195*cdf0e10cSrcweir } 196*cdf0e10cSrcweir rVal <<= eRet; 197*cdf0e10cSrcweir } 198*cdf0e10cSrcweir break; 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir return sal_True; 202*cdf0e10cSrcweir } 203*cdf0e10cSrcweir //------------------------------------------------------------------------ 204*cdf0e10cSrcweir sal_Bool SvxPageItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) 205*cdf0e10cSrcweir { 206*cdf0e10cSrcweir switch( nMemberId ) 207*cdf0e10cSrcweir { 208*cdf0e10cSrcweir case MID_PAGE_NUMTYPE: 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir sal_Int32 nValue = 0; 211*cdf0e10cSrcweir if(!(rVal >>= nValue)) 212*cdf0e10cSrcweir return sal_False; 213*cdf0e10cSrcweir 214*cdf0e10cSrcweir eNumType = (SvxNumType)nValue; 215*cdf0e10cSrcweir } 216*cdf0e10cSrcweir break; 217*cdf0e10cSrcweir case MID_PAGE_ORIENTATION: 218*cdf0e10cSrcweir bLandscape = Any2Bool(rVal); 219*cdf0e10cSrcweir break; 220*cdf0e10cSrcweir case MID_PAGE_LAYOUT : 221*cdf0e10cSrcweir { 222*cdf0e10cSrcweir style::PageStyleLayout eLayout; 223*cdf0e10cSrcweir if(!(rVal >>= eLayout)) 224*cdf0e10cSrcweir { 225*cdf0e10cSrcweir sal_Int32 nValue = 0; 226*cdf0e10cSrcweir if(!(rVal >>= nValue)) 227*cdf0e10cSrcweir return sal_False; 228*cdf0e10cSrcweir eLayout = (style::PageStyleLayout)nValue; 229*cdf0e10cSrcweir } 230*cdf0e10cSrcweir eUse &= 0xfff0; 231*cdf0e10cSrcweir switch( eLayout ) 232*cdf0e10cSrcweir { 233*cdf0e10cSrcweir case style::PageStyleLayout_LEFT : eUse |= SVX_PAGE_LEFT ; break; 234*cdf0e10cSrcweir case style::PageStyleLayout_RIGHT : eUse |= SVX_PAGE_RIGHT; break; 235*cdf0e10cSrcweir case style::PageStyleLayout_ALL : eUse |= SVX_PAGE_ALL ; break; 236*cdf0e10cSrcweir case style::PageStyleLayout_MIRRORED: eUse |= SVX_PAGE_MIRROR;break; 237*cdf0e10cSrcweir default: ;//prevent warning 238*cdf0e10cSrcweir } 239*cdf0e10cSrcweir } 240*cdf0e10cSrcweir break; 241*cdf0e10cSrcweir } 242*cdf0e10cSrcweir return sal_True; 243*cdf0e10cSrcweir } 244*cdf0e10cSrcweir 245*cdf0e10cSrcweir //------------------------------------------------------------------------ 246*cdf0e10cSrcweir 247*cdf0e10cSrcweir SfxPoolItem* SvxPageItem::Create( SvStream& rStream, sal_uInt16 ) const 248*cdf0e10cSrcweir { 249*cdf0e10cSrcweir XubString sStr; 250*cdf0e10cSrcweir sal_uInt8 eType; 251*cdf0e10cSrcweir sal_Bool bLand; 252*cdf0e10cSrcweir sal_uInt16 nUse; 253*cdf0e10cSrcweir 254*cdf0e10cSrcweir // UNICODE: rStream >> sStr; 255*cdf0e10cSrcweir rStream.ReadByteString( sStr ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir rStream >> eType; 258*cdf0e10cSrcweir rStream >> bLand; 259*cdf0e10cSrcweir rStream >> nUse; 260*cdf0e10cSrcweir 261*cdf0e10cSrcweir SvxPageItem* pPage = new SvxPageItem( Which() ); 262*cdf0e10cSrcweir pPage->SetDescName( sStr ); 263*cdf0e10cSrcweir pPage->SetNumType( (SvxNumType)eType ); 264*cdf0e10cSrcweir pPage->SetLandscape( bLand ); 265*cdf0e10cSrcweir pPage->SetPageUsage( nUse ); 266*cdf0e10cSrcweir return pPage; 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir //------------------------------------------------------------------------ 270*cdf0e10cSrcweir 271*cdf0e10cSrcweir SvStream& SvxPageItem::Store( SvStream &rStrm, sal_uInt16 /*nItemVersion*/ ) const 272*cdf0e10cSrcweir { 273*cdf0e10cSrcweir // UNICODE: rStrm << aDescName; 274*cdf0e10cSrcweir rStrm.WriteByteString(aDescName); 275*cdf0e10cSrcweir 276*cdf0e10cSrcweir rStrm << (sal_uInt8)eNumType << bLandscape << eUse; 277*cdf0e10cSrcweir return rStrm; 278*cdf0e10cSrcweir } 279*cdf0e10cSrcweir 280*cdf0e10cSrcweir /*-------------------------------------------------------------------- 281*cdf0e10cSrcweir Beschreibung: HeaderFooterSet 282*cdf0e10cSrcweir --------------------------------------------------------------------*/ 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir SvxSetItem::SvxSetItem( const sal_uInt16 nId, const SfxItemSet& rSet ) : 285*cdf0e10cSrcweir 286*cdf0e10cSrcweir SfxSetItem( nId, rSet ) 287*cdf0e10cSrcweir { 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir 290*cdf0e10cSrcweir SvxSetItem::SvxSetItem( const SvxSetItem& rItem ) : 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir SfxSetItem( rItem ) 293*cdf0e10cSrcweir { 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir 296*cdf0e10cSrcweir SvxSetItem::SvxSetItem( const sal_uInt16 nId, SfxItemSet* _pSet ) : 297*cdf0e10cSrcweir 298*cdf0e10cSrcweir SfxSetItem( nId, _pSet ) 299*cdf0e10cSrcweir { 300*cdf0e10cSrcweir } 301*cdf0e10cSrcweir 302*cdf0e10cSrcweir SfxPoolItem* SvxSetItem::Clone( SfxItemPool * ) const 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir return new SvxSetItem(*this); 305*cdf0e10cSrcweir } 306*cdf0e10cSrcweir 307*cdf0e10cSrcweir //------------------------------------------------------------------------ 308*cdf0e10cSrcweir 309*cdf0e10cSrcweir SfxItemPresentation SvxSetItem::GetPresentation 310*cdf0e10cSrcweir ( 311*cdf0e10cSrcweir SfxItemPresentation /*ePres*/, 312*cdf0e10cSrcweir SfxMapUnit /*eCoreUnit*/, 313*cdf0e10cSrcweir SfxMapUnit /*ePresUnit*/, 314*cdf0e10cSrcweir XubString& rText, const IntlWrapper * 315*cdf0e10cSrcweir ) const 316*cdf0e10cSrcweir { 317*cdf0e10cSrcweir rText.Erase(); 318*cdf0e10cSrcweir return SFX_ITEM_PRESENTATION_NONE; 319*cdf0e10cSrcweir } 320*cdf0e10cSrcweir 321*cdf0e10cSrcweir SfxPoolItem* SvxSetItem::Create(SvStream &rStrm, sal_uInt16 /*nVersion*/) const 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir SfxItemSet* _pSet = new SfxItemSet( *GetItemSet().GetPool(), 324*cdf0e10cSrcweir GetItemSet().GetRanges() ); 325*cdf0e10cSrcweir 326*cdf0e10cSrcweir _pSet->Load( rStrm ); 327*cdf0e10cSrcweir 328*cdf0e10cSrcweir return new SvxSetItem( Which(), *_pSet ); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir SvStream& SvxSetItem::Store(SvStream &rStrm, sal_uInt16 nItemVersion) const 332*cdf0e10cSrcweir { 333*cdf0e10cSrcweir GetItemSet().Store( rStrm, nItemVersion ); 334*cdf0e10cSrcweir 335*cdf0e10cSrcweir return rStrm; 336*cdf0e10cSrcweir } 337*cdf0e10cSrcweir 338*cdf0e10cSrcweir 339