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_sd.hxx" 30*cdf0e10cSrcweir #include <com/sun/star/drawing/BitmapMode.hpp> 31*cdf0e10cSrcweir #include <vos/mutex.hxx> 32*cdf0e10cSrcweir #include <vcl/svapp.hxx> 33*cdf0e10cSrcweir #include <svl/itemset.hxx> 34*cdf0e10cSrcweir #include <svx/svdpool.hxx> 35*cdf0e10cSrcweir #include <comphelper/extract.hxx> 36*cdf0e10cSrcweir #include <rtl/uuid.h> 37*cdf0e10cSrcweir #include <rtl/memory.h> 38*cdf0e10cSrcweir #include <svx/xflbstit.hxx> 39*cdf0e10cSrcweir #include <svx/xflbmtit.hxx> 40*cdf0e10cSrcweir #include <svx/svdobj.hxx> 41*cdf0e10cSrcweir #include <svx/unoprov.hxx> 42*cdf0e10cSrcweir #include <svx/unoshape.hxx> 43*cdf0e10cSrcweir #include <comphelper/serviceinfohelper.hxx> 44*cdf0e10cSrcweir 45*cdf0e10cSrcweir #include "unopback.hxx" 46*cdf0e10cSrcweir #include "unohelp.hxx" 47*cdf0e10cSrcweir #include "drawdoc.hxx" 48*cdf0e10cSrcweir #include "unokywds.hxx" 49*cdf0e10cSrcweir 50*cdf0e10cSrcweir using namespace ::rtl; 51*cdf0e10cSrcweir using namespace ::vos; 52*cdf0e10cSrcweir using namespace ::com::sun::star; 53*cdf0e10cSrcweir 54*cdf0e10cSrcweir const SvxItemPropertySet* ImplGetPageBackgroundPropertySet() 55*cdf0e10cSrcweir { 56*cdf0e10cSrcweir static const SfxItemPropertyMapEntry aPageBackgroundPropertyMap_Impl[] = 57*cdf0e10cSrcweir { 58*cdf0e10cSrcweir FILL_PROPERTIES 59*cdf0e10cSrcweir {0,0,0,0,0,0} 60*cdf0e10cSrcweir }; 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir static SvxItemPropertySet aPageBackgroundPropertySet_Impl( aPageBackgroundPropertyMap_Impl, SdrObject::GetGlobalDrawObjectItemPool() ); 63*cdf0e10cSrcweir return &aPageBackgroundPropertySet_Impl; 64*cdf0e10cSrcweir } 65*cdf0e10cSrcweir 66*cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( SdUnoPageBackground ); 67*cdf0e10cSrcweir 68*cdf0e10cSrcweir SdUnoPageBackground::SdUnoPageBackground( 69*cdf0e10cSrcweir SdDrawDocument* pDoc /* = NULL */, 70*cdf0e10cSrcweir const SfxItemSet* pSet /* = NULL */) throw() 71*cdf0e10cSrcweir : mpPropSet(ImplGetPageBackgroundPropertySet()), 72*cdf0e10cSrcweir mpSet(NULL), 73*cdf0e10cSrcweir mpDoc(pDoc) 74*cdf0e10cSrcweir { 75*cdf0e10cSrcweir if( pDoc ) 76*cdf0e10cSrcweir { 77*cdf0e10cSrcweir StartListening( *pDoc ); 78*cdf0e10cSrcweir mpSet = new SfxItemSet( pDoc->GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST ); 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir if( pSet ) 81*cdf0e10cSrcweir mpSet->Put(*pSet); 82*cdf0e10cSrcweir } 83*cdf0e10cSrcweir } 84*cdf0e10cSrcweir 85*cdf0e10cSrcweir SdUnoPageBackground::~SdUnoPageBackground() throw() 86*cdf0e10cSrcweir { 87*cdf0e10cSrcweir if( mpDoc ) 88*cdf0e10cSrcweir EndListening( *mpDoc ); 89*cdf0e10cSrcweir 90*cdf0e10cSrcweir if( mpSet ) 91*cdf0e10cSrcweir delete mpSet; 92*cdf0e10cSrcweir } 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir void SdUnoPageBackground::Notify( SfxBroadcaster&, const SfxHint& rHint ) 95*cdf0e10cSrcweir { 96*cdf0e10cSrcweir const SdrHint* pSdrHint = PTR_CAST( SdrHint, &rHint ); 97*cdf0e10cSrcweir 98*cdf0e10cSrcweir if( pSdrHint ) 99*cdf0e10cSrcweir { 100*cdf0e10cSrcweir // delete item set if document is dying because then the pool 101*cdf0e10cSrcweir // will also die 102*cdf0e10cSrcweir if( pSdrHint->GetKind() == HINT_MODELCLEARED ) 103*cdf0e10cSrcweir { 104*cdf0e10cSrcweir delete mpSet; 105*cdf0e10cSrcweir mpSet = NULL; 106*cdf0e10cSrcweir mpDoc = NULL; 107*cdf0e10cSrcweir } 108*cdf0e10cSrcweir } 109*cdf0e10cSrcweir 110*cdf0e10cSrcweir } 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir void SdUnoPageBackground::fillItemSet( SdDrawDocument* pDoc, SfxItemSet& rSet ) throw() 113*cdf0e10cSrcweir { 114*cdf0e10cSrcweir rSet.ClearItem(); 115*cdf0e10cSrcweir 116*cdf0e10cSrcweir if( mpSet == NULL ) 117*cdf0e10cSrcweir { 118*cdf0e10cSrcweir StartListening( *pDoc ); 119*cdf0e10cSrcweir mpDoc = pDoc; 120*cdf0e10cSrcweir 121*cdf0e10cSrcweir mpSet = new SfxItemSet( *rSet.GetPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST ); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir if( mpPropSet->AreThereOwnUsrAnys() ) 124*cdf0e10cSrcweir { 125*cdf0e10cSrcweir uno::Any* pAny; 126*cdf0e10cSrcweir PropertyEntryVector_t aProperties = mpPropSet->getPropertyMap()->getPropertyEntries(); 127*cdf0e10cSrcweir PropertyEntryVector_t::const_iterator aIt = aProperties.begin(); 128*cdf0e10cSrcweir 129*cdf0e10cSrcweir while( aIt != aProperties.end() ) 130*cdf0e10cSrcweir { 131*cdf0e10cSrcweir pAny = mpPropSet->GetUsrAnyForID( aIt->nWID ); 132*cdf0e10cSrcweir if( pAny ) 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir OUString aPropertyName( aIt->sName ); 135*cdf0e10cSrcweir switch( aIt->nWID ) 136*cdf0e10cSrcweir { 137*cdf0e10cSrcweir case XATTR_FILLFLOATTRANSPARENCE : 138*cdf0e10cSrcweir case XATTR_FILLGRADIENT : 139*cdf0e10cSrcweir { 140*cdf0e10cSrcweir if ( ( pAny->getValueType() == ::getCppuType((const ::com::sun::star::awt::Gradient*)0) ) 141*cdf0e10cSrcweir && ( aIt->nMemberId == MID_FILLGRADIENT ) ) 142*cdf0e10cSrcweir { 143*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 144*cdf0e10cSrcweir } 145*cdf0e10cSrcweir else if ( ( pAny->getValueType() == ::getCppuType((const ::rtl::OUString*)0) ) && 146*cdf0e10cSrcweir ( aIt->nMemberId == MID_NAME ) ) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 149*cdf0e10cSrcweir } 150*cdf0e10cSrcweir } 151*cdf0e10cSrcweir break; 152*cdf0e10cSrcweir case XATTR_FILLHATCH : 153*cdf0e10cSrcweir { 154*cdf0e10cSrcweir if ( ( pAny->getValueType() == ::getCppuType((const ::com::sun::star::drawing::Hatch*)0) ) 155*cdf0e10cSrcweir && ( aIt->nMemberId == MID_FILLHATCH ) ) 156*cdf0e10cSrcweir { 157*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 158*cdf0e10cSrcweir } 159*cdf0e10cSrcweir else if ( ( pAny->getValueType() == ::getCppuType((const ::rtl::OUString*)0) ) && 160*cdf0e10cSrcweir ( aIt->nMemberId == MID_NAME ) ) 161*cdf0e10cSrcweir { 162*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 163*cdf0e10cSrcweir } 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir break; 166*cdf0e10cSrcweir case XATTR_FILLBITMAP : 167*cdf0e10cSrcweir { 168*cdf0e10cSrcweir if ( ( ( pAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >*)0) ) || 169*cdf0e10cSrcweir ( pAny->getValueType() == ::getCppuType((const ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic >*)0) ) ) && 170*cdf0e10cSrcweir ( aIt->nMemberId == MID_BITMAP ) ) 171*cdf0e10cSrcweir { 172*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 173*cdf0e10cSrcweir } 174*cdf0e10cSrcweir else if ( ( pAny->getValueType() == ::getCppuType((const ::rtl::OUString*)0) ) && 175*cdf0e10cSrcweir ( ( aIt->nMemberId == MID_NAME ) || ( aIt->nMemberId == MID_GRAFURL ) ) ) 176*cdf0e10cSrcweir { 177*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 178*cdf0e10cSrcweir } 179*cdf0e10cSrcweir } 180*cdf0e10cSrcweir break; 181*cdf0e10cSrcweir 182*cdf0e10cSrcweir default: 183*cdf0e10cSrcweir setPropertyValue( aPropertyName, *pAny ); 184*cdf0e10cSrcweir } 185*cdf0e10cSrcweir } 186*cdf0e10cSrcweir ++aIt; 187*cdf0e10cSrcweir } 188*cdf0e10cSrcweir } 189*cdf0e10cSrcweir } 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir rSet.Put( *mpSet ); 192*cdf0e10cSrcweir } 193*cdf0e10cSrcweir 194*cdf0e10cSrcweir // XServiceInfo 195*cdf0e10cSrcweir OUString SAL_CALL SdUnoPageBackground::getImplementationName() 196*cdf0e10cSrcweir throw(uno::RuntimeException) 197*cdf0e10cSrcweir { 198*cdf0e10cSrcweir return OUString::createFromAscii( sUNO_SdUnoPageBackground ); 199*cdf0e10cSrcweir } 200*cdf0e10cSrcweir 201*cdf0e10cSrcweir sal_Bool SAL_CALL SdUnoPageBackground::supportsService( const OUString& ServiceName ) 202*cdf0e10cSrcweir throw(uno::RuntimeException) 203*cdf0e10cSrcweir { 204*cdf0e10cSrcweir return comphelper::ServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); 205*cdf0e10cSrcweir } 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir uno::Sequence< OUString > SAL_CALL SdUnoPageBackground::getSupportedServiceNames() 208*cdf0e10cSrcweir throw(uno::RuntimeException) 209*cdf0e10cSrcweir { 210*cdf0e10cSrcweir uno::Sequence< OUString > aNameSequence( 2 ); 211*cdf0e10cSrcweir OUString* pStrings = aNameSequence.getArray(); 212*cdf0e10cSrcweir 213*cdf0e10cSrcweir *pStrings++ = OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_Service_PageBackground ) ); 214*cdf0e10cSrcweir *pStrings = OUString( RTL_CONSTASCII_USTRINGPARAM( sUNO_Service_FillProperties ) ); 215*cdf0e10cSrcweir 216*cdf0e10cSrcweir return aNameSequence; 217*cdf0e10cSrcweir } 218*cdf0e10cSrcweir 219*cdf0e10cSrcweir // XPropertySet 220*cdf0e10cSrcweir uno::Reference< beans::XPropertySetInfo > SAL_CALL SdUnoPageBackground::getPropertySetInfo() 221*cdf0e10cSrcweir throw(uno::RuntimeException) 222*cdf0e10cSrcweir { 223*cdf0e10cSrcweir return mpPropSet->getPropertySetInfo(); 224*cdf0e10cSrcweir } 225*cdf0e10cSrcweir 226*cdf0e10cSrcweir void SAL_CALL SdUnoPageBackground::setPropertyValue( const OUString& aPropertyName, const uno::Any& aValue ) 227*cdf0e10cSrcweir throw(beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 230*cdf0e10cSrcweir 231*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry( aPropertyName ); 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir if( pEntry == NULL ) 234*cdf0e10cSrcweir { 235*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 236*cdf0e10cSrcweir } 237*cdf0e10cSrcweir else 238*cdf0e10cSrcweir { 239*cdf0e10cSrcweir if( mpSet ) 240*cdf0e10cSrcweir { 241*cdf0e10cSrcweir if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 242*cdf0e10cSrcweir { 243*cdf0e10cSrcweir drawing::BitmapMode eMode; 244*cdf0e10cSrcweir if( aValue >>= eMode ) 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir mpSet->Put( XFillBmpStretchItem( eMode == drawing::BitmapMode_STRETCH ) ); 247*cdf0e10cSrcweir mpSet->Put( XFillBmpTileItem( eMode == drawing::BitmapMode_REPEAT ) ); 248*cdf0e10cSrcweir return; 249*cdf0e10cSrcweir } 250*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 251*cdf0e10cSrcweir } 252*cdf0e10cSrcweir 253*cdf0e10cSrcweir SfxItemPool& rPool = *mpSet->GetPool(); 254*cdf0e10cSrcweir SfxItemSet aSet( rPool, pEntry->nWID, pEntry->nWID); 255*cdf0e10cSrcweir aSet.Put( *mpSet ); 256*cdf0e10cSrcweir 257*cdf0e10cSrcweir if( !aSet.Count() ) 258*cdf0e10cSrcweir aSet.Put( rPool.GetDefaultItem( pEntry->nWID ) ); 259*cdf0e10cSrcweir 260*cdf0e10cSrcweir if( pEntry->nMemberId == MID_NAME && ( pEntry->nWID == XATTR_FILLBITMAP || pEntry->nWID == XATTR_FILLGRADIENT || pEntry->nWID == XATTR_FILLHATCH || pEntry->nWID == XATTR_FILLFLOATTRANSPARENCE ) ) 261*cdf0e10cSrcweir { 262*cdf0e10cSrcweir OUString aName; 263*cdf0e10cSrcweir if(!(aValue >>= aName )) 264*cdf0e10cSrcweir throw lang::IllegalArgumentException(); 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir SvxShape::SetFillAttribute( pEntry->nWID, aName, aSet ); 267*cdf0e10cSrcweir } 268*cdf0e10cSrcweir else 269*cdf0e10cSrcweir { 270*cdf0e10cSrcweir SvxItemPropertySet_setPropertyValue( *mpPropSet, pEntry, aValue, aSet ); 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir mpSet->Put( aSet ); 274*cdf0e10cSrcweir } 275*cdf0e10cSrcweir else 276*cdf0e10cSrcweir { 277*cdf0e10cSrcweir if(pEntry && pEntry->nWID) 278*cdf0e10cSrcweir mpPropSet->setPropertyValue( pEntry, aValue ); 279*cdf0e10cSrcweir } 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir } 282*cdf0e10cSrcweir 283*cdf0e10cSrcweir uno::Any SAL_CALL SdUnoPageBackground::getPropertyValue( const OUString& PropertyName ) 284*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 285*cdf0e10cSrcweir { 286*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 287*cdf0e10cSrcweir 288*cdf0e10cSrcweir uno::Any aAny; 289*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry(PropertyName); 290*cdf0e10cSrcweir 291*cdf0e10cSrcweir if( pEntry == NULL ) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 294*cdf0e10cSrcweir } 295*cdf0e10cSrcweir else 296*cdf0e10cSrcweir { 297*cdf0e10cSrcweir if( mpSet ) 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 300*cdf0e10cSrcweir { 301*cdf0e10cSrcweir XFillBmpStretchItem* pStretchItem = (XFillBmpStretchItem*)mpSet->GetItem(XATTR_FILLBMP_STRETCH); 302*cdf0e10cSrcweir XFillBmpTileItem* pTileItem = (XFillBmpTileItem*)mpSet->GetItem(XATTR_FILLBMP_TILE); 303*cdf0e10cSrcweir 304*cdf0e10cSrcweir if( pStretchItem && pTileItem ) 305*cdf0e10cSrcweir { 306*cdf0e10cSrcweir if( pTileItem->GetValue() ) 307*cdf0e10cSrcweir aAny <<= drawing::BitmapMode_REPEAT; 308*cdf0e10cSrcweir else if( pStretchItem->GetValue() ) 309*cdf0e10cSrcweir aAny <<= drawing::BitmapMode_STRETCH; 310*cdf0e10cSrcweir else 311*cdf0e10cSrcweir aAny <<= drawing::BitmapMode_NO_REPEAT; 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir } 314*cdf0e10cSrcweir else 315*cdf0e10cSrcweir { 316*cdf0e10cSrcweir SfxItemPool& rPool = *mpSet->GetPool(); 317*cdf0e10cSrcweir SfxItemSet aSet( rPool, pEntry->nWID, pEntry->nWID); 318*cdf0e10cSrcweir aSet.Put( *mpSet ); 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir if( !aSet.Count() ) 321*cdf0e10cSrcweir aSet.Put( rPool.GetDefaultItem( pEntry->nWID ) ); 322*cdf0e10cSrcweir 323*cdf0e10cSrcweir // Hole Wert aus ItemSet 324*cdf0e10cSrcweir aAny = SvxItemPropertySet_getPropertyValue( *mpPropSet, pEntry, aSet ); 325*cdf0e10cSrcweir } 326*cdf0e10cSrcweir } 327*cdf0e10cSrcweir else 328*cdf0e10cSrcweir { 329*cdf0e10cSrcweir if(pEntry && pEntry->nWID) 330*cdf0e10cSrcweir aAny = mpPropSet->getPropertyValue( pEntry ); 331*cdf0e10cSrcweir } 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir return aAny; 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir void SAL_CALL SdUnoPageBackground::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 337*cdf0e10cSrcweir void SAL_CALL SdUnoPageBackground::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 338*cdf0e10cSrcweir void SAL_CALL SdUnoPageBackground::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 339*cdf0e10cSrcweir void SAL_CALL SdUnoPageBackground::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >& ) throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) {} 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir // XPropertyState 342*cdf0e10cSrcweir beans::PropertyState SAL_CALL SdUnoPageBackground::getPropertyState( const OUString& PropertyName ) 343*cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 344*cdf0e10cSrcweir { 345*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 346*cdf0e10cSrcweir 347*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry(PropertyName); 348*cdf0e10cSrcweir 349*cdf0e10cSrcweir if( pEntry == NULL ) 350*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 351*cdf0e10cSrcweir 352*cdf0e10cSrcweir if( mpSet ) 353*cdf0e10cSrcweir { 354*cdf0e10cSrcweir if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir if( mpSet->GetItemState( XATTR_FILLBMP_STRETCH, false ) == SFX_ITEM_SET || 357*cdf0e10cSrcweir mpSet->GetItemState( XATTR_FILLBMP_TILE, false ) == SFX_ITEM_SET ) 358*cdf0e10cSrcweir { 359*cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE; 360*cdf0e10cSrcweir } 361*cdf0e10cSrcweir else 362*cdf0e10cSrcweir { 363*cdf0e10cSrcweir return beans::PropertyState_AMBIGUOUS_VALUE; 364*cdf0e10cSrcweir } 365*cdf0e10cSrcweir } 366*cdf0e10cSrcweir 367*cdf0e10cSrcweir switch( mpSet->GetItemState( pEntry->nWID, sal_False ) ) 368*cdf0e10cSrcweir { 369*cdf0e10cSrcweir case SFX_ITEM_READONLY: 370*cdf0e10cSrcweir case SFX_ITEM_SET: 371*cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE; 372*cdf0e10cSrcweir case SFX_ITEM_DEFAULT: 373*cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE; 374*cdf0e10cSrcweir default: 375*cdf0e10cSrcweir // case SFX_ITEM_DONTCARE: 376*cdf0e10cSrcweir // case SFX_ITEM_DISABLED: 377*cdf0e10cSrcweir return beans::PropertyState_AMBIGUOUS_VALUE; 378*cdf0e10cSrcweir } 379*cdf0e10cSrcweir } 380*cdf0e10cSrcweir else 381*cdf0e10cSrcweir { 382*cdf0e10cSrcweir if( NULL == mpPropSet->GetUsrAnyForID(pEntry->nWID) ) 383*cdf0e10cSrcweir return beans::PropertyState_DEFAULT_VALUE; 384*cdf0e10cSrcweir else 385*cdf0e10cSrcweir return beans::PropertyState_DIRECT_VALUE; 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir } 388*cdf0e10cSrcweir 389*cdf0e10cSrcweir uno::Sequence< beans::PropertyState > SAL_CALL SdUnoPageBackground::getPropertyStates( const uno::Sequence< OUString >& aPropertyName ) 390*cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 391*cdf0e10cSrcweir { 392*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 393*cdf0e10cSrcweir 394*cdf0e10cSrcweir sal_Int32 nCount = aPropertyName.getLength(); 395*cdf0e10cSrcweir const OUString* pNames = aPropertyName.getConstArray(); 396*cdf0e10cSrcweir 397*cdf0e10cSrcweir uno::Sequence< beans::PropertyState > aPropertyStateSequence( nCount ); 398*cdf0e10cSrcweir beans::PropertyState* pState = aPropertyStateSequence.getArray(); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir while( nCount-- ) 401*cdf0e10cSrcweir *pState++ = getPropertyState( *pNames++ ); 402*cdf0e10cSrcweir 403*cdf0e10cSrcweir return aPropertyStateSequence; 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir void SAL_CALL SdUnoPageBackground::setPropertyToDefault( const OUString& PropertyName ) 407*cdf0e10cSrcweir throw(beans::UnknownPropertyException, uno::RuntimeException) 408*cdf0e10cSrcweir { 409*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 410*cdf0e10cSrcweir 411*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry(PropertyName); 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir if( pEntry == NULL ) 414*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 415*cdf0e10cSrcweir 416*cdf0e10cSrcweir if( mpSet ) 417*cdf0e10cSrcweir { 418*cdf0e10cSrcweir if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir mpSet->ClearItem( XATTR_FILLBMP_STRETCH ); 421*cdf0e10cSrcweir mpSet->ClearItem( XATTR_FILLBMP_TILE ); 422*cdf0e10cSrcweir } 423*cdf0e10cSrcweir else 424*cdf0e10cSrcweir { 425*cdf0e10cSrcweir mpSet->ClearItem( pEntry->nWID ); 426*cdf0e10cSrcweir } 427*cdf0e10cSrcweir } 428*cdf0e10cSrcweir } 429*cdf0e10cSrcweir 430*cdf0e10cSrcweir uno::Any SAL_CALL SdUnoPageBackground::getPropertyDefault( const OUString& aPropertyName ) 431*cdf0e10cSrcweir throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 432*cdf0e10cSrcweir { 433*cdf0e10cSrcweir OGuard aGuard( Application::GetSolarMutex() ); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* pEntry = getPropertyMapEntry(aPropertyName); 436*cdf0e10cSrcweir if( pEntry == NULL || mpSet == NULL ) 437*cdf0e10cSrcweir throw beans::UnknownPropertyException(); 438*cdf0e10cSrcweir 439*cdf0e10cSrcweir uno::Any aAny; 440*cdf0e10cSrcweir if( mpSet ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir if( pEntry->nWID == OWN_ATTR_FILLBMP_MODE ) 443*cdf0e10cSrcweir { 444*cdf0e10cSrcweir aAny <<= drawing::BitmapMode_REPEAT; 445*cdf0e10cSrcweir } 446*cdf0e10cSrcweir else 447*cdf0e10cSrcweir { 448*cdf0e10cSrcweir SfxItemPool& rPool = *mpSet->GetPool(); 449*cdf0e10cSrcweir SfxItemSet aSet( rPool, pEntry->nWID, pEntry->nWID); 450*cdf0e10cSrcweir aSet.Put( rPool.GetDefaultItem( pEntry->nWID ) ); 451*cdf0e10cSrcweir 452*cdf0e10cSrcweir aAny = SvxItemPropertySet_getPropertyValue( *mpPropSet, pEntry, aSet ); 453*cdf0e10cSrcweir } 454*cdf0e10cSrcweir } 455*cdf0e10cSrcweir return aAny; 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir 458*cdf0e10cSrcweir /** this is used because our property map is not sorted yet */ 459*cdf0e10cSrcweir const SfxItemPropertySimpleEntry* SdUnoPageBackground::getPropertyMapEntry( const OUString& rPropertyName ) const throw() 460*cdf0e10cSrcweir { 461*cdf0e10cSrcweir return mpPropSet->getPropertyMap()->getByName(rPropertyName); 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir 464