xref: /aoo41x/main/svx/source/gallery2/galexpl.cxx (revision 6dd94783)
1f6e50924SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3f6e50924SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4f6e50924SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5f6e50924SAndrew Rist  * distributed with this work for additional information
6f6e50924SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7f6e50924SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8f6e50924SAndrew Rist  * "License"); you may not use this file except in compliance
9f6e50924SAndrew Rist  * with the License.  You may obtain a copy of the License at
10f6e50924SAndrew Rist  *
11f6e50924SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12f6e50924SAndrew Rist  *
13f6e50924SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14f6e50924SAndrew Rist  * software distributed under the License is distributed on an
15f6e50924SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16f6e50924SAndrew Rist  * KIND, either express or implied.  See the License for the
17f6e50924SAndrew Rist  * specific language governing permissions and limitations
18f6e50924SAndrew Rist  * under the License.
19f6e50924SAndrew Rist  *
20f6e50924SAndrew Rist  *************************************************************/
21f6e50924SAndrew Rist 
22f6e50924SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_svx.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <unotools/pathoptions.hxx>
28cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
29cdf0e10cSrcweir #include "svx/gallery1.hxx"
30cdf0e10cSrcweir #include "svx/galtheme.hxx"
31cdf0e10cSrcweir #include "svx/galbrws.hxx"
32cdf0e10cSrcweir #include "svx/gallery.hxx"
33cdf0e10cSrcweir #include "galobj.hxx"
34cdf0e10cSrcweir 
35cdf0e10cSrcweir // -----------
36cdf0e10cSrcweir // - Statics -
37cdf0e10cSrcweir // -----------
38cdf0e10cSrcweir 
39cdf0e10cSrcweir static SfxListener aLockListener;
40cdf0e10cSrcweir 
41cdf0e10cSrcweir // -------------------
42cdf0e10cSrcweir // - GalleryExplorer -
43cdf0e10cSrcweir // -------------------
44cdf0e10cSrcweir 
45cdf0e10cSrcweir Gallery* GalleryExplorer::ImplGetGallery()
46cdf0e10cSrcweir {
47cdf0e10cSrcweir 	static Gallery* pGallery = NULL;
48cdf0e10cSrcweir 
49cdf0e10cSrcweir     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
50cdf0e10cSrcweir 
51cdf0e10cSrcweir 	if( !pGallery )
52cdf0e10cSrcweir 		pGallery = Gallery::GetGalleryInstance();
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	return pGallery;
55cdf0e10cSrcweir }
56cdf0e10cSrcweir 
57cdf0e10cSrcweir // ------------------------------------------------------------------------
58cdf0e10cSrcweir 
59cdf0e10cSrcweir GalleryExplorer* GalleryExplorer::GetGallery()
60cdf0e10cSrcweir {
61cdf0e10cSrcweir 	static GalleryExplorer* pThis = NULL;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir     ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
64cdf0e10cSrcweir 
65cdf0e10cSrcweir 	// only create a dummy object which can be accessed
66cdf0e10cSrcweir 	if( !pThis )
67cdf0e10cSrcweir 		pThis = new GalleryExplorer;
68cdf0e10cSrcweir 
69cdf0e10cSrcweir 	return pThis;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir 
72cdf0e10cSrcweir // ------------------------------------------------------------------------
73cdf0e10cSrcweir 
74cdf0e10cSrcweir INetURLObject GalleryExplorer::GetURL() const
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	return GALLERYBROWSER()->GetURL();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir String GalleryExplorer::GetFilterName() const
80cdf0e10cSrcweir {
81cdf0e10cSrcweir 	return GALLERYBROWSER()->GetFilterName();
82cdf0e10cSrcweir }
83cdf0e10cSrcweir 
84cdf0e10cSrcweir // ------------------------------------------------------------------------
85cdf0e10cSrcweir 
86cdf0e10cSrcweir Graphic GalleryExplorer::GetGraphic() const
87cdf0e10cSrcweir {
88cdf0e10cSrcweir 	return GALLERYBROWSER()->GetGraphic();
89cdf0e10cSrcweir }
90cdf0e10cSrcweir 
91cdf0e10cSrcweir // ------------------------------------------------------------------------
92cdf0e10cSrcweir 
93cdf0e10cSrcweir sal_Bool GalleryExplorer::GetVCDrawModel( FmFormModel& rModel ) const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir 	return GALLERYBROWSER()->GetVCDrawModel( rModel );
96cdf0e10cSrcweir }
97cdf0e10cSrcweir 
98cdf0e10cSrcweir // ------------------------------------------------------------------------
99cdf0e10cSrcweir 
100cdf0e10cSrcweir sal_Bool GalleryExplorer::IsLinkage() const
101cdf0e10cSrcweir {
102cdf0e10cSrcweir 	return GALLERYBROWSER()->IsLinkage();
103cdf0e10cSrcweir }
104cdf0e10cSrcweir 
105cdf0e10cSrcweir // ------------------------------------------------------------------------
106cdf0e10cSrcweir 
107cdf0e10cSrcweir sal_Bool GalleryExplorer::FillThemeList( List& rThemeList )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
110cdf0e10cSrcweir 
111cdf0e10cSrcweir 	if( pGal )
112cdf0e10cSrcweir 	{
113cdf0e10cSrcweir 		for( sal_uIntPtr i = 0, nCount = pGal->GetThemeCount(); i < nCount; i++ )
114cdf0e10cSrcweir 		{
115cdf0e10cSrcweir 			const GalleryThemeEntry* pEntry = pGal->GetThemeInfo( i );
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 			if( pEntry && !pEntry->IsReadOnly() && !pEntry->IsHidden() )
118cdf0e10cSrcweir 				rThemeList.Insert( new String( pEntry->GetThemeName() ), LIST_APPEND );
119cdf0e10cSrcweir 		}
120cdf0e10cSrcweir 	}
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 	return( rThemeList.Count() > 0 );
123cdf0e10cSrcweir }
124cdf0e10cSrcweir 
125cdf0e10cSrcweir // ------------------------------------------------------------------------
126cdf0e10cSrcweir 
127cdf0e10cSrcweir sal_Bool GalleryExplorer::FillObjList( const String& rThemeName, List& rObjList )
128cdf0e10cSrcweir {
129cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
130cdf0e10cSrcweir 
131cdf0e10cSrcweir 	if( pGal )
132cdf0e10cSrcweir 	{
133cdf0e10cSrcweir         SfxListener     aListener;
134cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 		if( pTheme )
137cdf0e10cSrcweir 		{
138cdf0e10cSrcweir 			for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
139cdf0e10cSrcweir 				rObjList.Insert( new String( pTheme->GetObjectURL( i ).GetMainURL( INetURLObject::NO_DECODE ) ), LIST_APPEND );
140cdf0e10cSrcweir 
141cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
142cdf0e10cSrcweir 		}
143cdf0e10cSrcweir 	}
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 	return( rObjList.Count() > 0 );
146cdf0e10cSrcweir }
147cdf0e10cSrcweir 
148cdf0e10cSrcweir // ------------------------------------------------------------------------
149cdf0e10cSrcweir 
150cdf0e10cSrcweir sal_Bool GalleryExplorer::FillObjList( sal_uIntPtr nThemeId, List& rObjList )
151cdf0e10cSrcweir {
152cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
153cdf0e10cSrcweir 	return( pGal ? FillObjList( pGal->GetThemeName( nThemeId ), rObjList ) : sal_False );
154cdf0e10cSrcweir }
155cdf0e10cSrcweir 
156cdf0e10cSrcweir // ------------------------------------------------------------------------
157cdf0e10cSrcweir 
158cdf0e10cSrcweir sal_Bool GalleryExplorer::FillObjListTitle( const sal_uInt32 nThemeId, std::vector< rtl::OUString >& rList )
159cdf0e10cSrcweir {
160cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
161cdf0e10cSrcweir 	if( pGal )
162cdf0e10cSrcweir 	{
163cdf0e10cSrcweir         SfxListener     aListener;
164cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( pGal->GetThemeName( nThemeId ), aListener );
165cdf0e10cSrcweir 
166cdf0e10cSrcweir         if( pTheme )
167cdf0e10cSrcweir 		{
168cdf0e10cSrcweir 			for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
169cdf0e10cSrcweir 			{
170cdf0e10cSrcweir 				SgaObject*	pObj = pTheme->AcquireObject( i );
171cdf0e10cSrcweir 				if ( pObj )
172cdf0e10cSrcweir 				{
173cdf0e10cSrcweir 					rtl::OUString aTitle( pObj->GetTitle() );
174cdf0e10cSrcweir 					rList.push_back( aTitle );
175cdf0e10cSrcweir 					pTheme->ReleaseObject( pObj );
176cdf0e10cSrcweir 				}
177cdf0e10cSrcweir 			}
178cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
179cdf0e10cSrcweir 		}
180cdf0e10cSrcweir 	}
181cdf0e10cSrcweir 	return( rList.size() > 0 );
182cdf0e10cSrcweir }
183cdf0e10cSrcweir 
184cdf0e10cSrcweir // ------------------------------------------------------------------------
185cdf0e10cSrcweir 
186cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertURL( const String& rThemeName, const String& rURL )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir 	return InsertURL( rThemeName, rURL, SGA_FORMAT_ALL );
189cdf0e10cSrcweir }
190cdf0e10cSrcweir 
191cdf0e10cSrcweir // ------------------------------------------------------------------------
192cdf0e10cSrcweir 
193cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL )
194cdf0e10cSrcweir {
195cdf0e10cSrcweir 	return InsertURL( nThemeId, rURL, SGA_FORMAT_ALL );
196cdf0e10cSrcweir }
197cdf0e10cSrcweir 
198cdf0e10cSrcweir // ------------------------------------------------------------------------
199cdf0e10cSrcweir 
200cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertURL( const String& rThemeName, const String& rURL, const sal_uIntPtr )
201cdf0e10cSrcweir {
202cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
203cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	if( pGal )
206cdf0e10cSrcweir 	{
207cdf0e10cSrcweir         SfxListener   aListener;
208cdf0e10cSrcweir 		GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
209cdf0e10cSrcweir 
210cdf0e10cSrcweir 		if( pTheme )
211cdf0e10cSrcweir 		{
212cdf0e10cSrcweir 			INetURLObject aURL( rURL );
213cdf0e10cSrcweir 			DBG_ASSERT( aURL.GetProtocol() != INET_PROT_NOT_VALID, "invalid URL" );
214cdf0e10cSrcweir 			bRet = pTheme->InsertURL( aURL );
215cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
216cdf0e10cSrcweir 		}
217cdf0e10cSrcweir 	}
218cdf0e10cSrcweir 
219cdf0e10cSrcweir 	return bRet;
220cdf0e10cSrcweir }
221cdf0e10cSrcweir 
222cdf0e10cSrcweir // ------------------------------------------------------------------------
223cdf0e10cSrcweir 
224cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertURL( sal_uIntPtr nThemeId, const String& rURL, const sal_uIntPtr nSgaFormat )
225cdf0e10cSrcweir {
226cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
227cdf0e10cSrcweir 	return( pGal ? InsertURL( pGal->GetThemeName( nThemeId ), rURL, nSgaFormat ) : sal_False );
228cdf0e10cSrcweir }
229cdf0e10cSrcweir 
230cdf0e10cSrcweir // ------------------------------------------------------------------------
231cdf0e10cSrcweir 
232cdf0e10cSrcweir sal_uIntPtr GalleryExplorer::GetObjCount( const String& rThemeName )
233cdf0e10cSrcweir {
234cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
235cdf0e10cSrcweir 	sal_uIntPtr		nRet = 0;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 	if( pGal )
238cdf0e10cSrcweir 	{
239cdf0e10cSrcweir         SfxListener     aListener;
240cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
241cdf0e10cSrcweir 
242cdf0e10cSrcweir 		if( pTheme )
243cdf0e10cSrcweir 		{
244cdf0e10cSrcweir 			nRet = pTheme->GetObjectCount();
245cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
246cdf0e10cSrcweir 		}
247cdf0e10cSrcweir 	}
248cdf0e10cSrcweir 
249cdf0e10cSrcweir 	return nRet;
250cdf0e10cSrcweir }
251cdf0e10cSrcweir 
252cdf0e10cSrcweir // ------------------------------------------------------------------------
253cdf0e10cSrcweir 
254cdf0e10cSrcweir sal_uIntPtr GalleryExplorer::GetObjCount( sal_uIntPtr nThemeId )
255cdf0e10cSrcweir {
256cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
257cdf0e10cSrcweir 	return( pGal ? GetObjCount( pGal->GetThemeName( nThemeId ) ) : sal_False );
258cdf0e10cSrcweir }
259cdf0e10cSrcweir 
260cdf0e10cSrcweir // ------------------------------------------------------------------------
261cdf0e10cSrcweir 
262cdf0e10cSrcweir sal_Bool GalleryExplorer::GetGraphicObj( const String& rThemeName, sal_uIntPtr nPos,
263*6dd94783SArmin Le Grand 									 Graphic* pGraphic, BitmapEx* pThumb,
264cdf0e10cSrcweir 									 sal_Bool bProgress )
265cdf0e10cSrcweir {
266cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
267cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
268cdf0e10cSrcweir 
269cdf0e10cSrcweir 	if( pGal )
270cdf0e10cSrcweir 	{
271cdf0e10cSrcweir         SfxListener     aListener;
272cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
273cdf0e10cSrcweir 
274cdf0e10cSrcweir 		if( pTheme )
275cdf0e10cSrcweir 		{
276cdf0e10cSrcweir 			if( pGraphic )
277cdf0e10cSrcweir 				bRet = bRet || pTheme->GetGraphic( nPos, *pGraphic, bProgress );
278cdf0e10cSrcweir 
279cdf0e10cSrcweir 			if( pThumb )
280cdf0e10cSrcweir 				bRet = bRet || pTheme->GetThumb( nPos, *pThumb, bProgress );
281cdf0e10cSrcweir 
282cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
283cdf0e10cSrcweir 		}
284cdf0e10cSrcweir 	}
285cdf0e10cSrcweir 
286cdf0e10cSrcweir 	return bRet;
287cdf0e10cSrcweir }
288cdf0e10cSrcweir 
289cdf0e10cSrcweir // ------------------------------------------------------------------------
290cdf0e10cSrcweir 
291cdf0e10cSrcweir sal_Bool GalleryExplorer::GetGraphicObj( sal_uIntPtr nThemeId, sal_uIntPtr nPos,
292*6dd94783SArmin Le Grand 									 Graphic* pGraphic, BitmapEx* pThumb,
293cdf0e10cSrcweir 									 sal_Bool bProgress )
294cdf0e10cSrcweir {
295cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
296cdf0e10cSrcweir 	return( pGal ? GetGraphicObj( pGal->GetThemeName( nThemeId ), nPos, pGraphic, pThumb, bProgress ) : sal_False );
297cdf0e10cSrcweir }
298cdf0e10cSrcweir 
299cdf0e10cSrcweir // ------------------------------------------------------------------------
300cdf0e10cSrcweir 
301cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertGraphicObj( const String& rThemeName, const Graphic& rGraphic )
302cdf0e10cSrcweir {
303cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
304cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
305cdf0e10cSrcweir 
306cdf0e10cSrcweir 	if( pGal )
307cdf0e10cSrcweir 	{
308cdf0e10cSrcweir         SfxListener     aListener;
309cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
310cdf0e10cSrcweir 
311cdf0e10cSrcweir 		if( pTheme )
312cdf0e10cSrcweir 		{
313cdf0e10cSrcweir 			bRet = pTheme->InsertGraphic( rGraphic );
314cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir 
318cdf0e10cSrcweir 	return bRet;
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir // ------------------------------------------------------------------------
322cdf0e10cSrcweir 
323cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertGraphicObj( sal_uIntPtr nThemeId, const Graphic& rGraphic )
324cdf0e10cSrcweir {
325cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
326cdf0e10cSrcweir 	return( pGal ? InsertGraphicObj( pGal->GetThemeName( nThemeId ), rGraphic ) : sal_False );
327cdf0e10cSrcweir }
328cdf0e10cSrcweir 
329cdf0e10cSrcweir // ------------------------------------------------------------------------
330cdf0e10cSrcweir 
331cdf0e10cSrcweir sal_uIntPtr GalleryExplorer::GetSdrObjCount( const String& rThemeName )
332cdf0e10cSrcweir {
333cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
334cdf0e10cSrcweir 	sal_uIntPtr		nRet = 0;
335cdf0e10cSrcweir 
336cdf0e10cSrcweir 	if( pGal )
337cdf0e10cSrcweir 	{
338cdf0e10cSrcweir         SfxListener     aListener;
339cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
340cdf0e10cSrcweir 
341cdf0e10cSrcweir 		if( pTheme )
342cdf0e10cSrcweir 		{
343cdf0e10cSrcweir 			for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(); i < nCount; i++ )
344cdf0e10cSrcweir 				if( SGA_OBJ_SVDRAW == pTheme->GetObjectKind( i ) )
345cdf0e10cSrcweir 					nRet++;
346cdf0e10cSrcweir 
347cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
348cdf0e10cSrcweir 		}
349cdf0e10cSrcweir 	}
350cdf0e10cSrcweir 
351cdf0e10cSrcweir 	return nRet;
352cdf0e10cSrcweir }
353cdf0e10cSrcweir 
354cdf0e10cSrcweir // ------------------------------------------------------------------------
355cdf0e10cSrcweir 
356cdf0e10cSrcweir sal_uIntPtr GalleryExplorer::GetSdrObjCount( sal_uIntPtr nThemeId  )
357cdf0e10cSrcweir {
358cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
359cdf0e10cSrcweir 	return( pGal ? GetSdrObjCount( pGal->GetThemeName( nThemeId ) ) : sal_False );
360cdf0e10cSrcweir }
361cdf0e10cSrcweir 
362cdf0e10cSrcweir // ------------------------------------------------------------------------
363cdf0e10cSrcweir 
364cdf0e10cSrcweir sal_Bool GalleryExplorer::GetSdrObj( const String& rThemeName, sal_uIntPtr nSdrModelPos,
365*6dd94783SArmin Le Grand 								 SdrModel* pModel, BitmapEx* pThumb )
366cdf0e10cSrcweir {
367cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
368cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
369cdf0e10cSrcweir 
370cdf0e10cSrcweir 	if( pGal )
371cdf0e10cSrcweir 	{
372cdf0e10cSrcweir         SfxListener     aListener;
373cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
374cdf0e10cSrcweir 
375cdf0e10cSrcweir 		if( pTheme )
376cdf0e10cSrcweir 		{
377cdf0e10cSrcweir 			for( sal_uIntPtr i = 0, nCount = pTheme->GetObjectCount(), nActPos = 0; ( i < nCount ) && !bRet; i++ )
378cdf0e10cSrcweir 			{
379cdf0e10cSrcweir 				if( SGA_OBJ_SVDRAW == pTheme->GetObjectKind( i ) )
380cdf0e10cSrcweir 				{
381cdf0e10cSrcweir 					if( nActPos++ == nSdrModelPos )
382cdf0e10cSrcweir 					{
383cdf0e10cSrcweir 						if( pModel )
384cdf0e10cSrcweir 							bRet = bRet || pTheme->GetModel( i, *pModel, sal_False );
385cdf0e10cSrcweir 
386cdf0e10cSrcweir 						if( pThumb )
387cdf0e10cSrcweir 							bRet = bRet || pTheme->GetThumb( i, *pThumb );
388cdf0e10cSrcweir 					}
389cdf0e10cSrcweir 				}
390cdf0e10cSrcweir 			}
391cdf0e10cSrcweir 
392cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
393cdf0e10cSrcweir 		}
394cdf0e10cSrcweir 	}
395cdf0e10cSrcweir 
396cdf0e10cSrcweir 	return bRet;
397cdf0e10cSrcweir }
398cdf0e10cSrcweir 
399cdf0e10cSrcweir // ------------------------------------------------------------------------
400cdf0e10cSrcweir 
401cdf0e10cSrcweir sal_Bool GalleryExplorer::GetSdrObj( sal_uIntPtr nThemeId, sal_uIntPtr nSdrModelPos,
402*6dd94783SArmin Le Grand 								 SdrModel* pModel, BitmapEx* pThumb )
403cdf0e10cSrcweir {
404cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
405cdf0e10cSrcweir 	return( pGal ? GetSdrObj( pGal->GetThemeName( nThemeId ), nSdrModelPos, pModel, pThumb ) : sal_False );
406cdf0e10cSrcweir }
407cdf0e10cSrcweir 
408cdf0e10cSrcweir // ------------------------------------------------------------------------
409cdf0e10cSrcweir 
410cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertSdrObj( const String& rThemeName, FmFormModel& rModel )
411cdf0e10cSrcweir {
412cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
413cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	if( pGal )
416cdf0e10cSrcweir 	{
417cdf0e10cSrcweir         SfxListener     aListener;
418cdf0e10cSrcweir         GalleryTheme*   pTheme = pGal->AcquireTheme( rThemeName, aListener );
419cdf0e10cSrcweir 
420cdf0e10cSrcweir 		if( pTheme )
421cdf0e10cSrcweir 		{
422cdf0e10cSrcweir 			bRet = pTheme->InsertModel( rModel );
423cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
424cdf0e10cSrcweir 		}
425cdf0e10cSrcweir 	}
426cdf0e10cSrcweir 
427cdf0e10cSrcweir 	return bRet;
428cdf0e10cSrcweir }
429cdf0e10cSrcweir 
430cdf0e10cSrcweir // ------------------------------------------------------------------------
431cdf0e10cSrcweir 
432cdf0e10cSrcweir sal_Bool GalleryExplorer::InsertSdrObj( sal_uIntPtr nThemeId, FmFormModel& rModel )
433cdf0e10cSrcweir {
434cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
435cdf0e10cSrcweir 	return( pGal ? InsertSdrObj( pGal->GetThemeName( nThemeId ), rModel ) : sal_False );
436cdf0e10cSrcweir }
437cdf0e10cSrcweir 
438cdf0e10cSrcweir // -----------------------------------------------------------------------------
439cdf0e10cSrcweir 
440cdf0e10cSrcweir sal_Bool GalleryExplorer::BeginLocking( const String& rThemeName )
441cdf0e10cSrcweir {
442cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
443cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	if( pGal )
446cdf0e10cSrcweir 	{
447cdf0e10cSrcweir 		GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aLockListener );
448cdf0e10cSrcweir 
449cdf0e10cSrcweir 		if( pTheme )
450cdf0e10cSrcweir         {
451cdf0e10cSrcweir             pTheme->LockTheme();
452cdf0e10cSrcweir 			bRet = sal_True;
453cdf0e10cSrcweir         }
454cdf0e10cSrcweir 	}
455cdf0e10cSrcweir 
456cdf0e10cSrcweir 	return bRet;
457cdf0e10cSrcweir }
458cdf0e10cSrcweir 
459cdf0e10cSrcweir // -----------------------------------------------------------------------------
460cdf0e10cSrcweir 
461cdf0e10cSrcweir sal_Bool GalleryExplorer::BeginLocking( sal_uIntPtr nThemeId )
462cdf0e10cSrcweir {
463cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
464cdf0e10cSrcweir 	return( pGal ? BeginLocking( pGal->GetThemeName( nThemeId ) ) : sal_False );
465cdf0e10cSrcweir }
466cdf0e10cSrcweir 
467cdf0e10cSrcweir // -----------------------------------------------------------------------------
468cdf0e10cSrcweir 
469cdf0e10cSrcweir sal_Bool GalleryExplorer::EndLocking( const String& rThemeName )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir 	Gallery*	pGal = ImplGetGallery();
472cdf0e10cSrcweir 	sal_Bool		bRet = sal_False;
473cdf0e10cSrcweir 
474cdf0e10cSrcweir 	if( pGal )
475cdf0e10cSrcweir 	{
476cdf0e10cSrcweir         SfxListener   aListener;
477cdf0e10cSrcweir 		GalleryTheme* pTheme = pGal->AcquireTheme( rThemeName, aListener );
478cdf0e10cSrcweir 
479cdf0e10cSrcweir 		if( pTheme )
480cdf0e10cSrcweir 		{
481cdf0e10cSrcweir             const sal_Bool bReleaseLockedTheme = pTheme->UnlockTheme();
482cdf0e10cSrcweir 
483cdf0e10cSrcweir 			// release acquired theme
484cdf0e10cSrcweir 			pGal->ReleaseTheme( pTheme, aListener );
485cdf0e10cSrcweir 
486cdf0e10cSrcweir             if( bReleaseLockedTheme )
487cdf0e10cSrcweir             {
488cdf0e10cSrcweir                 // release locked theme
489cdf0e10cSrcweir                 pGal->ReleaseTheme( pTheme, aLockListener );
490cdf0e10cSrcweir                 bRet = sal_True;
491cdf0e10cSrcweir             }
492cdf0e10cSrcweir 		}
493cdf0e10cSrcweir 	}
494cdf0e10cSrcweir 
495cdf0e10cSrcweir 	return bRet;
496cdf0e10cSrcweir }
497cdf0e10cSrcweir 
498cdf0e10cSrcweir // -----------------------------------------------------------------------------
499cdf0e10cSrcweir 
500cdf0e10cSrcweir sal_Bool GalleryExplorer::EndLocking( sal_uIntPtr nThemeId )
501cdf0e10cSrcweir {
502cdf0e10cSrcweir 	Gallery* pGal = ImplGetGallery();
503cdf0e10cSrcweir 	return( pGal ? EndLocking( pGal->GetThemeName( nThemeId ) ) : sal_False );
504cdf0e10cSrcweir }
505cdf0e10cSrcweir 
506cdf0e10cSrcweir // -----------------------------------------------------------------------------
507*6dd94783SArmin Le Grand // eof
508