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