1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_SVX_GALTHEME_HXX
21 #define INCLUDED_SVX_GALTHEME_HXX
23 #include <svx/svxdllapi.h>
25 #include <tools/debug.hxx>
26 #include <tools/urlobj.hxx>
27 #include <vcl/salctype.hxx>
28 #include <svl/brdcst.hxx>
29 #include <svl/lstner.hxx>
30 #include <svtools/transfer.hxx>
31 #include <sot/storage.hxx>
32 #include <svx/svdmodel.hxx>
33 #include <svx/galmisc.hxx>
50 //UI visualization buffering
51 BitmapEx maPreviewBitmapEx
;
57 typedef ::std::vector
< GalleryObject
* > GalleryObjectList
;
59 class GalleryThemeEntry
;
71 sal_uIntPtr nDragObjPos
;
82 class GalleryProgress
;
89 class GalleryTheme
: public SfxBroadcaster
92 friend class GalleryThemeCacheEntry
;
93 friend class ::unogallery::GalleryTheme
;
94 friend class ::unogallery::GalleryItem
;
98 GalleryObjectList aObjectList
;
100 bool m_bDestDirRelative
;
101 SotStorageRef aSvDrawStorageRef
;
103 GalleryThemeEntry
* pThm
;
104 sal_uIntPtr mnThemeLockCount
;
105 sal_uIntPtr mnBroadcasterLockCount
;
106 sal_uIntPtr nDragPos
;
108 bool bAbortActualize
;
110 void ImplCreateSvDrawStorage();
111 SVX_DLLPUBLIC SgaObject
* ImplReadSgaObject( GalleryObject
* pEntry
);
112 bool ImplWriteSgaObject( const SgaObject
& rObj
, size_t nPos
, GalleryObject
* pExistentEntry
);
114 const GalleryObject
* ImplGetGalleryObject( size_t nPos
) const
115 { return ( nPos
< aObjectList
.size() ) ? aObjectList
[ nPos
] : NULL
; }
116 SVX_DLLPUBLIC
const GalleryObject
* ImplGetGalleryObject( const INetURLObject
& rURL
);
118 size_t ImplGetGalleryObjectPos( const GalleryObject
* pObj
) const
120 for ( size_t i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
121 if ( pObj
== aObjectList
[ i
] )
125 INetURLObject
ImplGetURL( const GalleryObject
* pObject
) const;
126 INetURLObject
ImplCreateUniqueURL( SgaObjKind eObjKind
, sal_uIntPtr nFormat
= CVT_UNKNOWN
);
127 void ImplSetModified( bool bModified
);
128 void ImplBroadcast( sal_uIntPtr nUpdatePos
);
131 GalleryTheme( Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
);
132 virtual ~GalleryTheme();
136 static GalleryThemeEntry
* CreateThemeEntry( const INetURLObject
& rURL
, bool bReadOnly
);
138 size_t GetObjectCount() const { return aObjectList
.size(); }
140 SVX_DLLPUBLIC SgaObject
* AcquireObject( size_t nPos
);
141 SVX_DLLPUBLIC
void ReleaseObject( SgaObject
* pObj
);
143 SVX_DLLPUBLIC
bool InsertObject( const SgaObject
& rObj
, sal_uIntPtr nPos
= CONTAINER_APPEND
);
144 SVX_DLLPUBLIC
bool RemoveObject( size_t nPos
);
145 bool ChangeObjectPos( size_t nOldPos
, size_t nNewPos
);
147 SVX_DLLPUBLIC
const OUString
& GetName() const;
148 const OUString
& GetRealName() const;
150 // used for building gallery themes during compilation:
151 const OUString
& GetDestDir() const { return m_aDestDir
; }
152 void SetDestDir(const OUString
& rDestDir
, bool bRelative
= true)
153 { m_aDestDir
= rDestDir
; m_bDestDirRelative
= bRelative
; }
155 const INetURLObject
& GetThmURL() const;
156 SVX_DLLPUBLIC
const INetURLObject
& GetSdgURL() const;
157 const INetURLObject
& GetSdvURL() const;
159 SVX_DLLPUBLIC sal_uInt32
GetId() const;
160 void SetId( sal_uInt32 nNewId
, bool bResetThemeName
);
162 void SetDragging( bool bSet
) { bDragging
= bSet
; }
163 bool IsDragging() const { return bDragging
; }
165 void LockTheme() { ++mnThemeLockCount
; }
168 void LockBroadcaster() { mnBroadcasterLockCount
++; }
169 SVX_DLLPUBLIC
void UnlockBroadcaster( sal_uIntPtr nUpdatePos
= 0 );
170 bool IsBroadcasterLocked() const { return mnBroadcasterLockCount
> 0; }
172 void SetDragPos( sal_uIntPtr nPos
) { nDragPos
= nPos
; }
173 sal_uIntPtr
GetDragPos() const { return nDragPos
; }
175 bool IsThemeNameFromResource() const;
177 SVX_DLLPUBLIC
bool IsReadOnly() const;
178 SVX_DLLPUBLIC
bool IsDefault() const;
179 bool IsModified() const;
181 SVX_DLLPUBLIC
void Actualize( const Link
& rActualizeLink
, GalleryProgress
* pProgress
= NULL
);
182 void AbortActualize() { bAbortActualize
= true; }
184 Gallery
* GetParent() const { return pParent
; }
185 SotStorageRef
GetSvDrawStorage() const { return aSvDrawStorageRef
; }
189 SgaObjKind
GetObjectKind( sal_uIntPtr nPos
) const
191 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
192 return ImplGetGalleryObject( nPos
)->eObjKind
;
196 const INetURLObject
& GetObjectURL( sal_uIntPtr nPos
) const
198 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
199 return ImplGetGalleryObject( nPos
)->aURL
;
202 bool GetThumb( sal_uIntPtr nPos
, BitmapEx
& rBmp
, bool bProgress
= false );
204 SVX_DLLPUBLIC
bool GetGraphic( sal_uIntPtr nPos
, Graphic
& rGraphic
, bool bProgress
= false );
205 SVX_DLLPUBLIC
bool InsertGraphic( const Graphic
& rGraphic
, sal_uIntPtr nInsertPos
= CONTAINER_APPEND
);
207 SVX_DLLPUBLIC
bool GetModel( sal_uIntPtr nPos
, SdrModel
& rModel
, bool bProgress
= false );
208 SVX_DLLPUBLIC
bool InsertModel( const FmFormModel
& rModel
, sal_uIntPtr nInsertPos
= CONTAINER_APPEND
);
210 bool GetModelStream( sal_uIntPtr nPos
, SotStorageStreamRef
& rModelStreamRef
, bool bProgress
= false );
211 bool InsertModelStream( const SotStorageStreamRef
& rModelStream
, sal_uIntPtr nInsertPos
= CONTAINER_APPEND
);
213 bool GetURL( sal_uIntPtr nPos
, INetURLObject
& rURL
, bool bProgress
= false );
214 SVX_DLLPUBLIC
bool InsertURL( const INetURLObject
& rURL
, sal_uIntPtr nInsertPos
= CONTAINER_APPEND
);
215 bool InsertFileOrDirURL( const INetURLObject
& rFileOrDirURL
, sal_uIntPtr nInsertPos
= CONTAINER_APPEND
);
217 bool InsertTransferable( const ::com::sun::star::uno::Reference
< ::com::sun::star::datatransfer::XTransferable
>& rxTransferable
, sal_uIntPtr nInsertPos
);
219 void CopyToClipboard( Window
* pWindow
, sal_uIntPtr nPos
);
220 void StartDrag( Window
* pWindow
, sal_uIntPtr nPos
);
224 SvStream
& WriteData( SvStream
& rOut
) const;
225 SvStream
& ReadData( SvStream
& rIn
);
226 static SVX_DLLPUBLIC
void InsertAllThemes( ListBox
& rListBox
);
228 // for buffering PreviewBitmaps and strings for object and path
229 void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos
, BitmapEx
& rBitmapEx
, Size
& rSize
, OUString
& rTitle
, OUString
& rPath
) const;
230 void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos
, const BitmapEx
& rBitmapEx
, const Size
& rSize
, const OUString
& rTitle
, const OUString
& rPath
);
233 SvStream
& WriteGalleryTheme( SvStream
& rOut
, const GalleryTheme
& rTheme
);
234 SvStream
& ReadGalleryTheme( SvStream
& rIn
, GalleryTheme
& rTheme
);
238 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */