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