1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: galtheme.hxx,v $
10 * $Revision: 1.11.216.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_GALTHEME_HXX_
32 #define _SVX_GALTHEME_HXX_
34 #include "svx/svxdllapi.h"
36 #define ENABLE_BYTESTRING_STREAM_OPERATORS
38 #include <tools/debug.hxx>
39 #include <tools/urlobj.hxx>
40 #include <vcl/salctype.hxx>
41 #include <svtools/brdcst.hxx>
42 #include <svtools/lstner.hxx>
43 #include <svtools/transfer.hxx>
44 #include <sot/storage.hxx>
46 #include "galmisc.hxx"
47 #include "gallery1.hxx"
61 DECLARE_LIST( GalleryObjectList
, GalleryObject
* )
81 class GalleryProgress
;
88 class GalleryTheme
: public SfxBroadcaster
91 friend class GalleryThemeCacheEntry
;
92 friend class ::unogallery::GalleryTheme
;
93 friend class ::unogallery::GalleryItem
;
97 GalleryObjectList aObjectList
;
100 SotStorageRef aSvDrawStorageRef
;
102 GalleryThemeEntry
* pThm
;
103 ULONG mnThemeLockCount
;
104 ULONG mnBroadcasterLockCount
;
107 BOOL bAbortActualize
;
109 void ImplCreateSvDrawStorage();
110 SVX_DLLPUBLIC SgaObject
* ImplReadSgaObject( GalleryObject
* pEntry
);
111 BOOL
ImplWriteSgaObject( const SgaObject
& rObj
, ULONG nPos
, GalleryObject
* pExistentEntry
);
114 const GalleryObject
* ImplGetGalleryObject( ULONG nPos
) const { return aObjectList
.GetObject( nPos
); }
115 SVX_DLLPUBLIC
const GalleryObject
* ImplGetGalleryObject( const INetURLObject
& rURL
);
116 ULONG
ImplGetGalleryObjectPos( const GalleryObject
* pObj
) const { return aObjectList
.GetPos( pObj
); }
117 INetURLObject
ImplGetURL( const GalleryObject
* pObject
) const;
118 INetURLObject
ImplCreateUniqueURL( SgaObjKind eObjKind
, ULONG nFormat
= CVT_UNKNOWN
);
119 void ImplSetModified( BOOL bModified
) { pThm
->SetModified( bModified
); }
120 void ImplBroadcast( ULONG nUpdatePos
);
123 GalleryTheme( Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
);
128 static GalleryThemeEntry
* CreateThemeEntry( const INetURLObject
& rURL
, BOOL bReadOnly
);
130 ULONG
GetObjectCount() const { return aObjectList
.Count(); }
132 SVX_DLLPUBLIC SgaObject
* AcquireObject( ULONG nPos
);
133 SVX_DLLPUBLIC
void ReleaseObject( SgaObject
* pObj
);
135 SVX_DLLPUBLIC BOOL
InsertObject( const SgaObject
& rObj
, ULONG nPos
= LIST_APPEND
);
136 SVX_DLLPUBLIC BOOL
RemoveObject( ULONG nPos
);
137 BOOL
ChangeObjectPos( ULONG nOldPos
, ULONG nNewPos
);
139 const String
& GetName() const { return IsImported() ? aImportName
: pThm
->GetThemeName(); }
140 const String
& GetRealName() const { return pThm
->GetThemeName(); }
141 const String
& GetImportName() const { return aImportName
; }
142 void SetImportName(const String
& rImportName
) { aImportName
= rImportName
; }
144 const String
& GetDestDir() const { return m_aDestDir
; }
145 void SetDestDir(const String
& rDestDir
) { m_aDestDir
= rDestDir
; }
147 const INetURLObject
& GetThmURL() const { return pThm
->GetThmURL(); }
148 const INetURLObject
& GetSdgURL() const { return pThm
->GetSdgURL(); }
149 const INetURLObject
& GetSdvURL() const { return pThm
->GetSdvURL(); }
151 UINT32
GetId() const { return pThm
->GetId(); }
152 void SetId( UINT32 nNewId
, BOOL bResetThemeName
) { pThm
->SetId( nNewId
, bResetThemeName
); }
154 void SetDragging( BOOL bSet
) { bDragging
= bSet
; }
155 BOOL
IsDragging() const { return bDragging
; }
157 void LockTheme() { ++mnThemeLockCount
; }
160 void LockBroadcaster() { mnBroadcasterLockCount
++; }
161 SVX_DLLPUBLIC
void UnlockBroadcaster( ULONG nUpdatePos
= 0 );
162 BOOL
IsBroadcasterLocked() const { return mnBroadcasterLockCount
> 0; }
164 void SetDragPos( ULONG nPos
) { nDragPos
= nPos
; }
165 ULONG
GetDragPos() const { return nDragPos
; }
167 BOOL
IsThemeNameFromResource() const { return pThm
->IsNameFromResource(); }
169 BOOL
IsImported() const { return pThm
->IsImported(); }
170 BOOL
IsReadOnly() const { return pThm
->IsReadOnly(); }
171 BOOL
IsDefault() const { return pThm
->IsDefault(); }
172 BOOL
IsModified() const { return pThm
->IsModified(); }
174 SVX_DLLPUBLIC
void Actualize( const Link
& rActualizeLink
, GalleryProgress
* pProgress
= NULL
);
175 void AbortActualize() { bAbortActualize
= TRUE
; }
177 Gallery
* GetParent() const { return pParent
; }
178 SotStorageRef
GetSvDrawStorage() const { return aSvDrawStorageRef
; }
182 SgaObjKind
GetObjectKind( ULONG nPos
) const
184 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
185 return ImplGetGalleryObject( nPos
)->eObjKind
;
189 const INetURLObject
& GetObjectURL( ULONG nPos
) const
191 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
192 return ImplGetGalleryObject( nPos
)->aURL
;
195 BOOL
GetThumb( ULONG nPos
, Bitmap
& rBmp
, BOOL bProgress
= FALSE
);
197 SVX_DLLPUBLIC BOOL
GetGraphic( ULONG nPos
, Graphic
& rGraphic
, BOOL bProgress
= FALSE
);
198 SVX_DLLPUBLIC BOOL
InsertGraphic( const Graphic
& rGraphic
, ULONG nInsertPos
= LIST_APPEND
);
200 SVX_DLLPUBLIC BOOL
GetModel( ULONG nPos
, SdrModel
& rModel
, BOOL bProgress
= FALSE
);
201 SVX_DLLPUBLIC BOOL
InsertModel( const FmFormModel
& rModel
, ULONG nInsertPos
= LIST_APPEND
);
203 BOOL
GetModelStream( ULONG nPos
, SotStorageStreamRef
& rModelStreamRef
, BOOL bProgress
= FALSE
);
204 BOOL
InsertModelStream( const SotStorageStreamRef
& rModelStream
, ULONG nInsertPos
= LIST_APPEND
);
206 BOOL
GetURL( ULONG nPos
, INetURLObject
& rURL
, BOOL bProgress
= FALSE
);
207 SVX_DLLPUBLIC BOOL
InsertURL( const INetURLObject
& rURL
, ULONG nInsertPos
= LIST_APPEND
);
208 BOOL
InsertFileOrDirURL( const INetURLObject
& rFileOrDirURL
, ULONG nInsertPos
= LIST_APPEND
);
210 BOOL
InsertTransferable( const ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
, ULONG nInsertPos
);
212 void CopyToClipboard( Window
* pWindow
, ULONG nPos
);
213 void StartDrag( Window
* pWindow
, ULONG nPos
);
217 SvStream
& WriteData( SvStream
& rOut
) const;
218 SvStream
& ReadData( SvStream
& rIn
);
221 SvStream
& operator<<( SvStream
& rOut
, const GalleryTheme
& rTheme
);
222 SvStream
& operator>>( SvStream
& rIn
, GalleryTheme
& rTheme
);