1*f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*f6e50924SAndrew Rist  * distributed with this work for additional information
6*f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9*f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*f6e50924SAndrew Rist  *
11*f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*f6e50924SAndrew Rist  *
13*f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15*f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17*f6e50924SAndrew Rist  * specific language governing permissions and limitations
18*f6e50924SAndrew Rist  * under the License.
19*f6e50924SAndrew Rist  *
20*f6e50924SAndrew Rist  *************************************************************/
21*f6e50924SAndrew Rist 
22*f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "unogalitem.hxx"
28cdf0e10cSrcweir #include "unogaltheme.hxx"
29cdf0e10cSrcweir #include "svx/galtheme.hxx"
30cdf0e10cSrcweir #include "svx/galmisc.hxx"
31cdf0e10cSrcweir #include <svx/fmmodel.hxx>
32cdf0e10cSrcweir #include <rtl/uuid.h>
33cdf0e10cSrcweir #include <vos/mutex.hxx>
34cdf0e10cSrcweir #include <vcl/svapp.hxx>
35cdf0e10cSrcweir #include <vcl/graph.hxx>
36cdf0e10cSrcweir #include <svl/itemprop.hxx>
37cdf0e10cSrcweir #include <svl/itempool.hxx>
38cdf0e10cSrcweir #include "galobj.hxx"
39cdf0e10cSrcweir 
40cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYSTATE_HDL_
41cdf0e10cSrcweir #include <com/sun/star/beans/PropertyState.hpp>
42cdf0e10cSrcweir #endif
43cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HDL_
44cdf0e10cSrcweir #include <com/sun/star/beans/PropertyAttribute.hpp>
45cdf0e10cSrcweir #endif
46cdf0e10cSrcweir #include <com/sun/star/gallery/GalleryItemType.hpp>
47cdf0e10cSrcweir 
48cdf0e10cSrcweir #define UNOGALLERY_GALLERYITEMTYPE	1
49cdf0e10cSrcweir #define UNOGALLERY_URL				2
50cdf0e10cSrcweir #define UNOGALLERY_TITLE			3
51cdf0e10cSrcweir #define UNOGALLERY_THUMBNAIL		4
52cdf0e10cSrcweir #define UNOGALLERY_GRAPHIC			5
53cdf0e10cSrcweir #define UNOGALLERY_DRAWING			6
54cdf0e10cSrcweir 
55cdf0e10cSrcweir using namespace ::com::sun::star;
56cdf0e10cSrcweir 
57cdf0e10cSrcweir namespace unogallery {
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // -----------------
60cdf0e10cSrcweir // - GalleryItem -
61cdf0e10cSrcweir // -----------------
62cdf0e10cSrcweir 
GalleryItem(::unogallery::GalleryTheme & rTheme,const GalleryObject & rObject)63cdf0e10cSrcweir GalleryItem::GalleryItem( ::unogallery::GalleryTheme& rTheme, const GalleryObject& rObject ) :
64cdf0e10cSrcweir 	::comphelper::PropertySetHelper( createPropertySetInfo() ),
65cdf0e10cSrcweir 	mpTheme( &rTheme ),
66cdf0e10cSrcweir 	mpGalleryObject( &rObject )
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	mpTheme->implRegisterGalleryItem( *this );
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // ------------------------------------------------------------------------------
72cdf0e10cSrcweir 
~GalleryItem()73cdf0e10cSrcweir GalleryItem::~GalleryItem()
74cdf0e10cSrcweir 	throw()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	if( mpTheme )
77cdf0e10cSrcweir 		mpTheme->implDeregisterGalleryItem( *this );
78cdf0e10cSrcweir }
79cdf0e10cSrcweir 
80cdf0e10cSrcweir // ------------------------------------------------------------------------------
81cdf0e10cSrcweir 
isValid() const82cdf0e10cSrcweir bool GalleryItem::isValid() const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir 	return( mpTheme != NULL );
85cdf0e10cSrcweir }
86cdf0e10cSrcweir 
87cdf0e10cSrcweir // ------------------------------------------------------------------------------
88cdf0e10cSrcweir 
queryAggregation(const uno::Type & rType)89cdf0e10cSrcweir uno::Any SAL_CALL GalleryItem::queryAggregation( const uno::Type & rType )
90cdf0e10cSrcweir 	throw( uno::RuntimeException )
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	uno::Any aAny;
93cdf0e10cSrcweir 
94cdf0e10cSrcweir 	if( rType == ::getCppuType((const uno::Reference< lang::XServiceInfo >*)0) )
95cdf0e10cSrcweir 		aAny <<= uno::Reference< lang::XServiceInfo >(this);
96cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< lang::XTypeProvider >*)0) )
97cdf0e10cSrcweir 		aAny <<= uno::Reference< lang::XTypeProvider >(this);
98cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< gallery::XGalleryItem >*)0) )
99cdf0e10cSrcweir 		aAny <<= uno::Reference< gallery::XGalleryItem >(this);
100cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XPropertySet >*)0) )
101cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XPropertySet >(this);
102cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XPropertyState >*)0) )
103cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XPropertyState >(this);
104cdf0e10cSrcweir 	else if( rType == ::getCppuType((const uno::Reference< beans::XMultiPropertySet >*)0) )
105cdf0e10cSrcweir 		aAny <<= uno::Reference< beans::XMultiPropertySet >(this);
106cdf0e10cSrcweir 	else
107cdf0e10cSrcweir 		aAny <<= OWeakAggObject::queryAggregation( rType );
108cdf0e10cSrcweir 
109cdf0e10cSrcweir 	return aAny;
110cdf0e10cSrcweir }
111cdf0e10cSrcweir 
112cdf0e10cSrcweir // ------------------------------------------------------------------------------
113cdf0e10cSrcweir 
queryInterface(const uno::Type & rType)114cdf0e10cSrcweir uno::Any SAL_CALL GalleryItem::queryInterface( const uno::Type & rType )
115cdf0e10cSrcweir 	throw( uno::RuntimeException )
116cdf0e10cSrcweir {
117cdf0e10cSrcweir 	return OWeakAggObject::queryInterface( rType );
118cdf0e10cSrcweir }
119cdf0e10cSrcweir 
120cdf0e10cSrcweir // ------------------------------------------------------------------------------
121cdf0e10cSrcweir 
acquire()122cdf0e10cSrcweir void SAL_CALL GalleryItem::acquire()
123cdf0e10cSrcweir 	throw()
124cdf0e10cSrcweir {
125cdf0e10cSrcweir 	OWeakAggObject::acquire();
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir // ------------------------------------------------------------------------------
129cdf0e10cSrcweir 
release()130cdf0e10cSrcweir void SAL_CALL GalleryItem::release()
131cdf0e10cSrcweir 	throw()
132cdf0e10cSrcweir {
133cdf0e10cSrcweir 	OWeakAggObject::release();
134cdf0e10cSrcweir }
135cdf0e10cSrcweir 
136cdf0e10cSrcweir // ------------------------------------------------------------------------------
137cdf0e10cSrcweir 
getImplementationName_Static()138cdf0e10cSrcweir ::rtl::OUString GalleryItem::getImplementationName_Static()
139cdf0e10cSrcweir 	throw()
140cdf0e10cSrcweir {
141cdf0e10cSrcweir 	return ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.gallery.GalleryItem" ) );
142cdf0e10cSrcweir }
143cdf0e10cSrcweir 
144cdf0e10cSrcweir // ------------------------------------------------------------------------------
145cdf0e10cSrcweir 
getSupportedServiceNames_Static()146cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > GalleryItem::getSupportedServiceNames_Static()
147cdf0e10cSrcweir 	throw()
148cdf0e10cSrcweir {
149cdf0e10cSrcweir 	uno::Sequence< ::rtl::OUString > aSeq( 1 );
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	aSeq.getArray()[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.gallery.GalleryItem" ) );
152cdf0e10cSrcweir 
153cdf0e10cSrcweir 	return aSeq;
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // ------------------------------------------------------------------------------
157cdf0e10cSrcweir 
getImplementationName()158cdf0e10cSrcweir ::rtl::OUString SAL_CALL GalleryItem::getImplementationName()
159cdf0e10cSrcweir 	throw( uno::RuntimeException )
160cdf0e10cSrcweir {
161cdf0e10cSrcweir 	return getImplementationName_Static();
162cdf0e10cSrcweir }
163cdf0e10cSrcweir 
164cdf0e10cSrcweir // ------------------------------------------------------------------------------
165cdf0e10cSrcweir 
supportsService(const::rtl::OUString & ServiceName)166cdf0e10cSrcweir sal_Bool SAL_CALL GalleryItem::supportsService( const ::rtl::OUString& ServiceName )
167cdf0e10cSrcweir 	throw( uno::RuntimeException )
168cdf0e10cSrcweir {
169cdf0e10cSrcweir     uno::Sequence< ::rtl::OUString >	aSNL( getSupportedServiceNames() );
170cdf0e10cSrcweir     const ::rtl::OUString*				pArray = aSNL.getConstArray();
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     for( int i = 0; i < aSNL.getLength(); i++ )
173cdf0e10cSrcweir         if( pArray[i] == ServiceName )
174cdf0e10cSrcweir             return true;
175cdf0e10cSrcweir 
176cdf0e10cSrcweir     return false;
177cdf0e10cSrcweir }
178cdf0e10cSrcweir 
179cdf0e10cSrcweir // ------------------------------------------------------------------------------
180cdf0e10cSrcweir 
getSupportedServiceNames()181cdf0e10cSrcweir uno::Sequence< ::rtl::OUString > SAL_CALL GalleryItem::getSupportedServiceNames()
182cdf0e10cSrcweir 	throw( uno::RuntimeException )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	return getSupportedServiceNames_Static();
185cdf0e10cSrcweir }
186cdf0e10cSrcweir 
187cdf0e10cSrcweir // ------------------------------------------------------------------------------
188cdf0e10cSrcweir 
getTypes()189cdf0e10cSrcweir uno::Sequence< uno::Type > SAL_CALL GalleryItem::getTypes()
190cdf0e10cSrcweir 	throw(uno::RuntimeException)
191cdf0e10cSrcweir {
192cdf0e10cSrcweir 	uno::Sequence< uno::Type >	aTypes( 6 );
193cdf0e10cSrcweir 	uno::Type* 					pTypes = aTypes.getArray();
194cdf0e10cSrcweir 
195cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< lang::XServiceInfo>*)0);
196cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< lang::XTypeProvider>*)0);
197cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< gallery::XGalleryItem>*)0);
198cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertySet>*)0);
199cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XPropertyState>*)0);
200cdf0e10cSrcweir 	*pTypes++ = ::getCppuType((const uno::Reference< beans::XMultiPropertySet>*)0);
201cdf0e10cSrcweir 
202cdf0e10cSrcweir 	return aTypes;
203cdf0e10cSrcweir }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir // ------------------------------------------------------------------------------
206cdf0e10cSrcweir 
getImplementationId()207cdf0e10cSrcweir uno::Sequence< sal_Int8 > SAL_CALL GalleryItem::getImplementationId()
208cdf0e10cSrcweir 	throw(uno::RuntimeException)
209cdf0e10cSrcweir {
210cdf0e10cSrcweir 	const vos::OGuard 					aGuard( Application::GetSolarMutex() );
211cdf0e10cSrcweir 	static uno::Sequence< sal_Int8 >	aId;
212cdf0e10cSrcweir 
213cdf0e10cSrcweir 	if( aId.getLength() == 0 )
214cdf0e10cSrcweir 	{
215cdf0e10cSrcweir 		aId.realloc( 16 );
216cdf0e10cSrcweir 		rtl_createUuid( reinterpret_cast< sal_uInt8* >( aId.getArray() ), 0, sal_True );
217cdf0e10cSrcweir 	}
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	return aId;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir // ------------------------------------------------------------------------------
223cdf0e10cSrcweir 
getType()224cdf0e10cSrcweir sal_Int8 SAL_CALL GalleryItem::getType()
225cdf0e10cSrcweir 	throw (uno::RuntimeException)
226cdf0e10cSrcweir {
227cdf0e10cSrcweir 	const ::vos::OGuard aGuard( Application::GetSolarMutex() );
228cdf0e10cSrcweir 	sal_Int8 			nRet = gallery::GalleryItemType::EMPTY;
229cdf0e10cSrcweir 
230cdf0e10cSrcweir 	if( isValid() )
231cdf0e10cSrcweir 	{
232cdf0e10cSrcweir 		switch( implGetObject()->eObjKind )
233cdf0e10cSrcweir 		{
234cdf0e10cSrcweir 			case( SGA_OBJ_SOUND ):
235cdf0e10cSrcweir 			case( SGA_OBJ_VIDEO ):
236cdf0e10cSrcweir 				nRet = gallery::GalleryItemType::MEDIA;
237cdf0e10cSrcweir 			break;
238cdf0e10cSrcweir 
239cdf0e10cSrcweir 			case( SGA_OBJ_SVDRAW ):
240cdf0e10cSrcweir 				nRet = gallery::GalleryItemType::DRAWING;
241cdf0e10cSrcweir 			break;
242cdf0e10cSrcweir 
243cdf0e10cSrcweir 			default:
244cdf0e10cSrcweir 				nRet = gallery::GalleryItemType::GRAPHIC;
245cdf0e10cSrcweir 			break;
246cdf0e10cSrcweir 		}
247cdf0e10cSrcweir 	}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	return nRet;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir // ------------------------------------------------------------------------------
253cdf0e10cSrcweir 
createPropertySetInfo()254cdf0e10cSrcweir ::comphelper::PropertySetInfo* GalleryItem::createPropertySetInfo()
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	vos::OGuard 					aGuard( Application::GetSolarMutex() );
257cdf0e10cSrcweir 	::comphelper::PropertySetInfo*	pRet = new ::comphelper::PropertySetInfo();
258cdf0e10cSrcweir 
259cdf0e10cSrcweir 	static ::comphelper::PropertyMapEntry aEntries[] =
260cdf0e10cSrcweir 	{
261cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "GalleryItemType" ), UNOGALLERY_GALLERYITEMTYPE, &::getCppuType( (const sal_Int8*)(0)),
262cdf0e10cSrcweir 		  beans::PropertyAttribute::READONLY, 0 },
263cdf0e10cSrcweir 
264cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "URL" ), UNOGALLERY_URL, &::getCppuType( (const ::rtl::OUString*)(0)),
265cdf0e10cSrcweir 		  beans::PropertyAttribute::READONLY, 0 },
266cdf0e10cSrcweir 
267cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Title" ), UNOGALLERY_TITLE, &::getCppuType( (const ::rtl::OUString*)(0)),
268cdf0e10cSrcweir 		  0, 0 },
269cdf0e10cSrcweir 
270cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Thumbnail" ), UNOGALLERY_THUMBNAIL, &::getCppuType( (const uno::Reference< graphic::XGraphic >*)(0)),
271cdf0e10cSrcweir 		  beans::PropertyAttribute::READONLY, 0 },
272cdf0e10cSrcweir 
273cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Graphic" ), UNOGALLERY_GRAPHIC, &::getCppuType( (const uno::Reference< graphic::XGraphic >*)(0)),
274cdf0e10cSrcweir 		  beans::PropertyAttribute::READONLY, 0 },
275cdf0e10cSrcweir 
276cdf0e10cSrcweir 		{ MAP_CHAR_LEN( "Drawing" ), UNOGALLERY_DRAWING, &::getCppuType( (const uno::Reference< lang::XComponent >*)(0) ),
277cdf0e10cSrcweir 		  beans::PropertyAttribute::READONLY, 0 },
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 		{ 0,0,0,0,0,0}
280cdf0e10cSrcweir 	};
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 	pRet->acquire();
283cdf0e10cSrcweir 	pRet->add( aEntries );
284cdf0e10cSrcweir 
285cdf0e10cSrcweir 	return pRet;
286cdf0e10cSrcweir }
287cdf0e10cSrcweir 
288cdf0e10cSrcweir // ------------------------------------------------------------------------------
289cdf0e10cSrcweir 
_setPropertyValues(const comphelper::PropertyMapEntry ** ppEntries,const uno::Any * pValues)290cdf0e10cSrcweir void GalleryItem::_setPropertyValues( const comphelper::PropertyMapEntry** ppEntries, const uno::Any* pValues )
291cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
292cdf0e10cSrcweir 		   beans::PropertyVetoException,
293cdf0e10cSrcweir 		   lang::IllegalArgumentException,
294cdf0e10cSrcweir 		   lang::WrappedTargetException )
295cdf0e10cSrcweir {
296cdf0e10cSrcweir 	const ::vos::OGuard aGuard( Application::GetSolarMutex() );
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 	while( *ppEntries )
299cdf0e10cSrcweir 	{
300cdf0e10cSrcweir 		if( UNOGALLERY_TITLE == (*ppEntries)->mnHandle )
301cdf0e10cSrcweir 		{
302cdf0e10cSrcweir 			::rtl::OUString aNewTitle;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir 			if( *pValues >>= aNewTitle )
305cdf0e10cSrcweir 			{
306cdf0e10cSrcweir 				::GalleryTheme*	pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
307cdf0e10cSrcweir 
308cdf0e10cSrcweir 				if( pGalTheme )
309cdf0e10cSrcweir 				{
310cdf0e10cSrcweir 					SgaObject* pObj = pGalTheme->ImplReadSgaObject( const_cast< GalleryObject* >( implGetObject() ) );
311cdf0e10cSrcweir 
312cdf0e10cSrcweir 					if( pObj )
313cdf0e10cSrcweir 					{
314cdf0e10cSrcweir 						if( ::rtl::OUString( pObj->GetTitle() ) != aNewTitle )
315cdf0e10cSrcweir 						{
316cdf0e10cSrcweir 							pObj->SetTitle( aNewTitle );
317cdf0e10cSrcweir 							pGalTheme->InsertObject( *pObj );
318cdf0e10cSrcweir 						}
319cdf0e10cSrcweir 
320cdf0e10cSrcweir 						delete pObj;
321cdf0e10cSrcweir 					}
322cdf0e10cSrcweir 				}
323cdf0e10cSrcweir 			}
324cdf0e10cSrcweir 			else
325cdf0e10cSrcweir 			{
326cdf0e10cSrcweir 				throw lang::IllegalArgumentException();
327cdf0e10cSrcweir 			}
328cdf0e10cSrcweir 		}
329cdf0e10cSrcweir 
330cdf0e10cSrcweir 		++ppEntries;
331cdf0e10cSrcweir 		++pValues;
332cdf0e10cSrcweir 	}
333cdf0e10cSrcweir }
334cdf0e10cSrcweir 
335cdf0e10cSrcweir // ------------------------------------------------------------------------------
336cdf0e10cSrcweir 
_getPropertyValues(const comphelper::PropertyMapEntry ** ppEntries,uno::Any * pValue)337cdf0e10cSrcweir void GalleryItem::_getPropertyValues( const comphelper::PropertyMapEntry** ppEntries, uno::Any* pValue )
338cdf0e10cSrcweir 	throw( beans::UnknownPropertyException,
339cdf0e10cSrcweir 		   lang::WrappedTargetException )
340cdf0e10cSrcweir {
341cdf0e10cSrcweir 	const ::vos::OGuard aGuard( Application::GetSolarMutex() );
342cdf0e10cSrcweir 
343cdf0e10cSrcweir 	while( *ppEntries )
344cdf0e10cSrcweir 	{
345cdf0e10cSrcweir 		switch( (*ppEntries)->mnHandle )
346cdf0e10cSrcweir 		{
347cdf0e10cSrcweir 			case( UNOGALLERY_GALLERYITEMTYPE ):
348cdf0e10cSrcweir 			{
349cdf0e10cSrcweir 				*pValue <<= sal_Int8( getType() );
350cdf0e10cSrcweir 			}
351cdf0e10cSrcweir 			break;
352cdf0e10cSrcweir 
353cdf0e10cSrcweir 			case( UNOGALLERY_URL ):
354cdf0e10cSrcweir 			{
355cdf0e10cSrcweir 				::GalleryTheme*	pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
356cdf0e10cSrcweir 
357cdf0e10cSrcweir 				if( pGalTheme )
358cdf0e10cSrcweir 					*pValue <<= ::rtl::OUString( implGetObject()->aURL.GetMainURL( INetURLObject::NO_DECODE ) );
359cdf0e10cSrcweir 			}
360cdf0e10cSrcweir 			break;
361cdf0e10cSrcweir 
362cdf0e10cSrcweir 			case( UNOGALLERY_TITLE ):
363cdf0e10cSrcweir 			{
364cdf0e10cSrcweir 				::GalleryTheme*	pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
365cdf0e10cSrcweir 
366cdf0e10cSrcweir 				if( pGalTheme )
367cdf0e10cSrcweir 				{
368cdf0e10cSrcweir 					SgaObject* pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 					if( pObj )
371cdf0e10cSrcweir 					{
372cdf0e10cSrcweir 						*pValue <<= ::rtl::OUString( pObj->GetTitle() );
373cdf0e10cSrcweir 						pGalTheme->ReleaseObject( pObj );
374cdf0e10cSrcweir 					}
375cdf0e10cSrcweir 				}
376cdf0e10cSrcweir 			}
377cdf0e10cSrcweir 			break;
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 			case( UNOGALLERY_THUMBNAIL ):
380cdf0e10cSrcweir 			{
381cdf0e10cSrcweir 				::GalleryTheme*	pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
382cdf0e10cSrcweir 
383cdf0e10cSrcweir 				if( pGalTheme )
384cdf0e10cSrcweir 				{
385cdf0e10cSrcweir 					SgaObject* pObj = pGalTheme->AcquireObject( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ) );
386cdf0e10cSrcweir 
387cdf0e10cSrcweir 					if( pObj )
388cdf0e10cSrcweir 					{
389cdf0e10cSrcweir 						Graphic aThumbnail;
390cdf0e10cSrcweir 
391cdf0e10cSrcweir 						if( pObj->IsThumbBitmap() )
392cdf0e10cSrcweir 							aThumbnail = pObj->GetThumbBmp();
393cdf0e10cSrcweir 						else
394cdf0e10cSrcweir 							aThumbnail = pObj->GetThumbMtf();
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 						*pValue <<= aThumbnail.GetXGraphic();
397cdf0e10cSrcweir 						pGalTheme->ReleaseObject( pObj );
398cdf0e10cSrcweir 					}
399cdf0e10cSrcweir 				}
400cdf0e10cSrcweir 			}
401cdf0e10cSrcweir 			break;
402cdf0e10cSrcweir 
403cdf0e10cSrcweir 			case( UNOGALLERY_GRAPHIC ):
404cdf0e10cSrcweir 			{
405cdf0e10cSrcweir 				::GalleryTheme*	pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
406cdf0e10cSrcweir 				Graphic			aGraphic;
407cdf0e10cSrcweir 
408cdf0e10cSrcweir 				if( pGalTheme && pGalTheme->GetGraphic( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ), aGraphic ) )
409cdf0e10cSrcweir 					*pValue <<= aGraphic.GetXGraphic();
410cdf0e10cSrcweir 			}
411cdf0e10cSrcweir 			break;
412cdf0e10cSrcweir 
413cdf0e10cSrcweir 			case( UNOGALLERY_DRAWING ):
414cdf0e10cSrcweir 			{
415cdf0e10cSrcweir 				if( gallery::GalleryItemType::DRAWING == getType() )
416cdf0e10cSrcweir 				{
417cdf0e10cSrcweir 					::GalleryTheme*	pGalTheme = ( isValid() ? mpTheme->implGetTheme() : NULL );
418cdf0e10cSrcweir 					FmFormModel*	pModel = new FmFormModel;
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 					pModel->GetItemPool().FreezeIdRanges();
421cdf0e10cSrcweir 
422cdf0e10cSrcweir 					if( pGalTheme && pGalTheme->GetModel( pGalTheme->ImplGetGalleryObjectPos( implGetObject() ), *pModel ) )
423cdf0e10cSrcweir 					{
424cdf0e10cSrcweir 						uno::Reference< lang::XComponent > xDrawing( new GalleryDrawingModel( pModel ) );
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 						pModel->setUnoModel( uno::Reference< uno::XInterface >::query( xDrawing ) );
427cdf0e10cSrcweir 						*pValue <<= xDrawing;
428cdf0e10cSrcweir 					}
429cdf0e10cSrcweir 					else
430cdf0e10cSrcweir 						delete pModel;
431cdf0e10cSrcweir 				}
432cdf0e10cSrcweir 			}
433cdf0e10cSrcweir 			break;
434cdf0e10cSrcweir 		}
435cdf0e10cSrcweir 
436cdf0e10cSrcweir 		++ppEntries;
437cdf0e10cSrcweir 		++pValue;
438cdf0e10cSrcweir 	}
439cdf0e10cSrcweir }
440cdf0e10cSrcweir 
441cdf0e10cSrcweir // ------------------------------------------------------------------------------
442cdf0e10cSrcweir 
implGetObject() const443cdf0e10cSrcweir const ::GalleryObject* GalleryItem::implGetObject() const
444cdf0e10cSrcweir {
445cdf0e10cSrcweir 	return mpGalleryObject;
446cdf0e10cSrcweir }
447cdf0e10cSrcweir 
448cdf0e10cSrcweir // ------------------------------------------------------------------------------
449cdf0e10cSrcweir 
implSetInvalid()450cdf0e10cSrcweir void GalleryItem::implSetInvalid()
451cdf0e10cSrcweir {
452cdf0e10cSrcweir 	if( mpTheme )
453cdf0e10cSrcweir 	{
454cdf0e10cSrcweir 		mpTheme = NULL;
455cdf0e10cSrcweir 		mpGalleryObject = NULL;
456cdf0e10cSrcweir 	}
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir // -----------------------
460cdf0e10cSrcweir // - GalleryDrawingModel -
461cdf0e10cSrcweir // -----------------------
462cdf0e10cSrcweir 
GalleryDrawingModel(SdrModel * pDoc)463cdf0e10cSrcweir GalleryDrawingModel::GalleryDrawingModel( SdrModel* pDoc )
464cdf0e10cSrcweir 	throw() :
465cdf0e10cSrcweir 	SvxUnoDrawingModel( pDoc )
466cdf0e10cSrcweir {
467cdf0e10cSrcweir }
468cdf0e10cSrcweir 
469cdf0e10cSrcweir // -----------------------------------------------------------------------------
470cdf0e10cSrcweir 
~GalleryDrawingModel()471cdf0e10cSrcweir GalleryDrawingModel::~GalleryDrawingModel()
472cdf0e10cSrcweir 	throw()
473cdf0e10cSrcweir {
474cdf0e10cSrcweir 	delete GetDoc();
475cdf0e10cSrcweir }
476cdf0e10cSrcweir 
477cdf0e10cSrcweir // -----------------------------------------------------------------------------
478cdf0e10cSrcweir 
479cdf0e10cSrcweir UNO3_GETIMPLEMENTATION_IMPL( GalleryDrawingModel );
480cdf0e10cSrcweir 
481cdf0e10cSrcweir }
482