xref: /aoo41x/main/svx/inc/svx/galtheme.hxx (revision 21b36550)
13334a7e6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
33334a7e6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
43334a7e6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
53334a7e6SAndrew Rist  * distributed with this work for additional information
63334a7e6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
73334a7e6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
83334a7e6SAndrew Rist  * "License"); you may not use this file except in compliance
93334a7e6SAndrew Rist  * with the License.  You may obtain a copy of the License at
103334a7e6SAndrew Rist  *
113334a7e6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
123334a7e6SAndrew Rist  *
133334a7e6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
143334a7e6SAndrew Rist  * software distributed under the License is distributed on an
153334a7e6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
163334a7e6SAndrew Rist  * KIND, either express or implied.  See the License for the
173334a7e6SAndrew Rist  * specific language governing permissions and limitations
183334a7e6SAndrew Rist  * under the License.
193334a7e6SAndrew Rist  *
203334a7e6SAndrew Rist  *************************************************************/
213334a7e6SAndrew Rist 
223334a7e6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _SVX_GALTHEME_HXX_
25cdf0e10cSrcweir #define _SVX_GALTHEME_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include "svx/svxdllapi.h"
28cdf0e10cSrcweir 
29cdf0e10cSrcweir #define ENABLE_BYTESTRING_STREAM_OPERATORS
30cdf0e10cSrcweir 
31cdf0e10cSrcweir #include <tools/debug.hxx>
32cdf0e10cSrcweir #include <tools/urlobj.hxx>
33cdf0e10cSrcweir #include <vcl/salctype.hxx>
34cdf0e10cSrcweir #include <svl/brdcst.hxx>
35cdf0e10cSrcweir #include <svl/lstner.hxx>
36cdf0e10cSrcweir #include <svtools/transfer.hxx>
37cdf0e10cSrcweir #include <sot/storage.hxx>
38cdf0e10cSrcweir #include <svx/svdmodel.hxx>
39cdf0e10cSrcweir //#include <svx/galobj.hxx>
40cdf0e10cSrcweir #include <svx/galmisc.hxx>
41cdf0e10cSrcweir //#include <svx/gallery1.hxx>
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // -----------------
44cdf0e10cSrcweir // - GalleryObject -
45cdf0e10cSrcweir // -----------------
46cdf0e10cSrcweir // --------------
47cdf0e10cSrcweir // - SgaObjKind -
48cdf0e10cSrcweir // --------------
49cdf0e10cSrcweir 
50cdf0e10cSrcweir struct GalleryObject
51cdf0e10cSrcweir {
52cdf0e10cSrcweir 	INetURLObject	aURL;
53cdf0e10cSrcweir 	sal_uInt32		nOffset;
54cdf0e10cSrcweir 	SgaObjKind		eObjKind;
55*21b36550SArmin Le Grand     bool            mbDelete;
56*21b36550SArmin Le Grand 
57*21b36550SArmin Le Grand     //UI visualization buffering
58*21b36550SArmin Le Grand     BitmapEx        maPreviewBitmapEx;
59*21b36550SArmin Le Grand     Size            maPreparedSize;
60*21b36550SArmin Le Grand     String          maTitle;
61*21b36550SArmin Le Grand     String          maPath;
62cdf0e10cSrcweir };
63cdf0e10cSrcweir 
64cdf0e10cSrcweir DECLARE_LIST( GalleryObjectList, GalleryObject* )
65cdf0e10cSrcweir 
66cdf0e10cSrcweir class GalleryThemeEntry;
67cdf0e10cSrcweir class SgaObject;
68cdf0e10cSrcweir class FmFormModel;
69cdf0e10cSrcweir class ListBox;
70cdf0e10cSrcweir 
71cdf0e10cSrcweir // -----------------
72cdf0e10cSrcweir // - GalDragParams -
73cdf0e10cSrcweir // -----------------
74cdf0e10cSrcweir 
75cdf0e10cSrcweir struct GalDragParams
76cdf0e10cSrcweir {
77cdf0e10cSrcweir 	Region		aDragRegion;
78cdf0e10cSrcweir 	sal_uIntPtr		nDragObjPos;
79cdf0e10cSrcweir 	String		aThemeName;
80cdf0e10cSrcweir 	String		aFileName;
81cdf0e10cSrcweir 	SgaObjKind	eObjKind;
82cdf0e10cSrcweir };
83cdf0e10cSrcweir 
84cdf0e10cSrcweir // ----------------
85cdf0e10cSrcweir // - GalleryTheme -
86cdf0e10cSrcweir // ----------------
87cdf0e10cSrcweir 
88cdf0e10cSrcweir class Gallery;
89cdf0e10cSrcweir class GalleryProgress;
90cdf0e10cSrcweir namespace unogallery
91cdf0e10cSrcweir {
92cdf0e10cSrcweir 	class GalleryTheme;
93cdf0e10cSrcweir 	class GalleryItem;
94cdf0e10cSrcweir }
95cdf0e10cSrcweir 
96cdf0e10cSrcweir class GalleryTheme : public SfxBroadcaster
97cdf0e10cSrcweir {
98cdf0e10cSrcweir 	friend class Gallery;
99cdf0e10cSrcweir 	friend class GalleryThemeCacheEntry;
100cdf0e10cSrcweir 	friend class ::unogallery::GalleryTheme;
101cdf0e10cSrcweir 	friend class ::unogallery::GalleryItem;
102cdf0e10cSrcweir 
103cdf0e10cSrcweir private:
104cdf0e10cSrcweir 
105cdf0e10cSrcweir 	GalleryObjectList			aObjectList;
106cdf0e10cSrcweir 	String						aImportName;
107cdf0e10cSrcweir 	String						m_aDestDir;
108cdf0e10cSrcweir 	SotStorageRef				aSvDrawStorageRef;
109cdf0e10cSrcweir 	Gallery*					pParent;
110cdf0e10cSrcweir 	GalleryThemeEntry*			pThm;
111cdf0e10cSrcweir     sal_uIntPtr                       mnThemeLockCount;
112cdf0e10cSrcweir 	sal_uIntPtr						mnBroadcasterLockCount;
113cdf0e10cSrcweir 	sal_uIntPtr						nDragPos;
114cdf0e10cSrcweir 	sal_Bool						bDragging;
115cdf0e10cSrcweir 	sal_Bool						bAbortActualize;
116cdf0e10cSrcweir 
117cdf0e10cSrcweir 	void						ImplCreateSvDrawStorage();
118cdf0e10cSrcweir 	SVX_DLLPUBLIC SgaObject*					ImplReadSgaObject( GalleryObject* pEntry );
119cdf0e10cSrcweir 	sal_Bool						ImplWriteSgaObject( const SgaObject& rObj, sal_uIntPtr nPos, GalleryObject* pExistentEntry );
120cdf0e10cSrcweir 	void						ImplRead();
121cdf0e10cSrcweir 	void						ImplWrite();
ImplGetGalleryObject(sal_uIntPtr nPos) const122cdf0e10cSrcweir 	const GalleryObject*		ImplGetGalleryObject( sal_uIntPtr nPos ) const { return aObjectList.GetObject( nPos ); }
123cdf0e10cSrcweir 	SVX_DLLPUBLIC const GalleryObject*		ImplGetGalleryObject( const INetURLObject& rURL );
ImplGetGalleryObjectPos(const GalleryObject * pObj) const124cdf0e10cSrcweir 	sal_uIntPtr						ImplGetGalleryObjectPos( const GalleryObject* pObj ) const { return aObjectList.GetPos( pObj ); }
125cdf0e10cSrcweir 	INetURLObject				ImplGetURL( const GalleryObject* pObject ) const;
126cdf0e10cSrcweir     INetURLObject               ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPtr nFormat = CVT_UNKNOWN );
127cdf0e10cSrcweir 	void						ImplSetModified( sal_Bool bModified );
128cdf0e10cSrcweir 	void						ImplBroadcast( sal_uIntPtr nUpdatePos );
129cdf0e10cSrcweir 
130cdf0e10cSrcweir 								GalleryTheme();
131cdf0e10cSrcweir 								GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
132cdf0e10cSrcweir 								~GalleryTheme();
133cdf0e10cSrcweir 
134cdf0e10cSrcweir public:
135cdf0e10cSrcweir 
136cdf0e10cSrcweir 	static GalleryThemeEntry*	CreateThemeEntry( const INetURLObject& rURL, sal_Bool bReadOnly );
137cdf0e10cSrcweir 
GetObjectCount() const138cdf0e10cSrcweir 	sal_uIntPtr					GetObjectCount() const { return aObjectList.Count(); }
139cdf0e10cSrcweir 
140cdf0e10cSrcweir 	SVX_DLLPUBLIC SgaObject*					AcquireObject( sal_uIntPtr nPos );
141cdf0e10cSrcweir 	SVX_DLLPUBLIC void						ReleaseObject( SgaObject* pObj );
142cdf0e10cSrcweir 
143cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						InsertObject( const SgaObject& rObj, sal_uIntPtr nPos = LIST_APPEND );
144cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						RemoveObject( sal_uIntPtr nPos );
145cdf0e10cSrcweir 	sal_Bool						ChangeObjectPos( sal_uIntPtr nOldPos, sal_uIntPtr nNewPos );
146cdf0e10cSrcweir 
147cdf0e10cSrcweir 	SVX_DLLPUBLIC const String&	GetName() const;
148cdf0e10cSrcweir 	const String&				GetRealName() const;
GetImportName() const149cdf0e10cSrcweir 	const String&				GetImportName() const { return aImportName; }
SetImportName(const String & rImportName)150cdf0e10cSrcweir 	void						SetImportName(const String& rImportName) { aImportName = rImportName; }
151cdf0e10cSrcweir 
GetDestDir() const152cdf0e10cSrcweir 	const String&				GetDestDir() const { return m_aDestDir; }
SetDestDir(const String & rDestDir)153cdf0e10cSrcweir 	void						SetDestDir(const String& rDestDir) { m_aDestDir = rDestDir; }
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 	const INetURLObject&		GetThmURL() const;
156cdf0e10cSrcweir 	SVX_DLLPUBLIC const INetURLObject&		GetSdgURL() const;
157cdf0e10cSrcweir 	const INetURLObject&		GetSdvURL() const;
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_uInt32		GetId() const;
160cdf0e10cSrcweir 	void						SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName );
161cdf0e10cSrcweir 
SetDragging(sal_Bool bSet)162cdf0e10cSrcweir 	void						SetDragging( sal_Bool bSet ) { bDragging = bSet; }
IsDragging() const163cdf0e10cSrcweir 	sal_Bool						IsDragging() const { return bDragging; }
164cdf0e10cSrcweir 
LockTheme()165cdf0e10cSrcweir     void                        LockTheme() { ++mnThemeLockCount; }
166cdf0e10cSrcweir     sal_Bool                        UnlockTheme();
167cdf0e10cSrcweir 
LockBroadcaster()168cdf0e10cSrcweir 	void						LockBroadcaster() { mnBroadcasterLockCount++; }
169cdf0e10cSrcweir 	SVX_DLLPUBLIC void			UnlockBroadcaster( sal_uIntPtr nUpdatePos = 0 );
IsBroadcasterLocked() const170cdf0e10cSrcweir 	sal_Bool						IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
171cdf0e10cSrcweir 
SetDragPos(sal_uIntPtr nPos)172cdf0e10cSrcweir 	void						SetDragPos( sal_uIntPtr nPos ) { nDragPos = nPos; }
GetDragPos() const173cdf0e10cSrcweir 	sal_uIntPtr						GetDragPos() const { return nDragPos; }
174cdf0e10cSrcweir 
175cdf0e10cSrcweir 	sal_Bool						IsThemeNameFromResource() const;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool			IsImported() const;
178cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool			IsReadOnly() const;
179cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool			IsDefault() const;
180cdf0e10cSrcweir 	sal_Bool						IsModified() const;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 	SVX_DLLPUBLIC void						Actualize( const Link& rActualizeLink, GalleryProgress* pProgress = NULL );
AbortActualize()183cdf0e10cSrcweir 	void						AbortActualize() { bAbortActualize = sal_True; }
184cdf0e10cSrcweir 
GetParent() const185cdf0e10cSrcweir 	Gallery*					GetParent() const { return pParent; }
GetSvDrawStorage() const186cdf0e10cSrcweir 	SotStorageRef				GetSvDrawStorage() const { return aSvDrawStorageRef; }
187cdf0e10cSrcweir 
188cdf0e10cSrcweir public:
189cdf0e10cSrcweir 
GetObjectKind(sal_uIntPtr nPos) const190cdf0e10cSrcweir 	SgaObjKind					GetObjectKind( sal_uIntPtr nPos ) const
191cdf0e10cSrcweir 								{
192cdf0e10cSrcweir 									DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
193cdf0e10cSrcweir 									return ImplGetGalleryObject( nPos )->eObjKind;
194cdf0e10cSrcweir 								}
195cdf0e10cSrcweir 
196cdf0e10cSrcweir 
GetObjectURL(sal_uIntPtr nPos) const197cdf0e10cSrcweir 	const INetURLObject&		GetObjectURL( sal_uIntPtr nPos ) const
198cdf0e10cSrcweir 								{
199cdf0e10cSrcweir 									DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
200cdf0e10cSrcweir 									return ImplGetGalleryObject( nPos )->aURL;
201cdf0e10cSrcweir 								}
202cdf0e10cSrcweir 
2036dd94783SArmin Le Grand 	sal_Bool						GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, sal_Bool bProgress = sal_False );
204cdf0e10cSrcweir 
205cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, sal_Bool bProgress = sal_False );
206cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos = LIST_APPEND );
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						GetModel( sal_uIntPtr nPos, SdrModel& rModel, sal_Bool bProgress = sal_False );
209cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos = LIST_APPEND );
210cdf0e10cSrcweir 
211cdf0e10cSrcweir 	sal_Bool						GetModelStream( sal_uIntPtr nPos, SotStorageStreamRef& rModelStreamRef, sal_Bool bProgress = sal_False );
212cdf0e10cSrcweir 	sal_Bool						InsertModelStream( const SotStorageStreamRef& rModelStream, sal_uIntPtr nInsertPos = LIST_APPEND );
213cdf0e10cSrcweir 
214cdf0e10cSrcweir 	sal_Bool						GetURL( sal_uIntPtr nPos, INetURLObject& rURL, sal_Bool bProgress = sal_False );
215cdf0e10cSrcweir 	SVX_DLLPUBLIC sal_Bool						InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos = LIST_APPEND );
216cdf0e10cSrcweir     sal_Bool                        InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos = LIST_APPEND );
217cdf0e10cSrcweir 
218cdf0e10cSrcweir 	sal_Bool						InsertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos );
219cdf0e10cSrcweir 
220cdf0e10cSrcweir 	void						CopyToClipboard( Window* pWindow, sal_uIntPtr nPos );
221cdf0e10cSrcweir 	void						StartDrag( Window* pWindow, sal_uIntPtr nPos );
222cdf0e10cSrcweir 
223cdf0e10cSrcweir public:
224cdf0e10cSrcweir 
225cdf0e10cSrcweir 	SvStream&					WriteData( SvStream& rOut ) const;
226cdf0e10cSrcweir 	SvStream&					ReadData( SvStream& rIn );
227cdf0e10cSrcweir 	static SVX_DLLPUBLIC void	InsertAllThemes( ListBox& rListBox );
228*21b36550SArmin Le Grand 
229*21b36550SArmin Le Grand     // for buffering PreviewBitmaps and strings for object and path
230*21b36550SArmin Le Grand     void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, String& rTitle, String& rPath) const;
231*21b36550SArmin Le Grand     void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const String& rTitle, const String& rPath);
232cdf0e10cSrcweir };
233cdf0e10cSrcweir 
234cdf0e10cSrcweir SvStream& operator<<( SvStream& rOut, const GalleryTheme& rTheme );
235cdf0e10cSrcweir SvStream& operator>>( SvStream& rIn, GalleryTheme& rTheme );
236cdf0e10cSrcweir 
237cdf0e10cSrcweir #endif
238