Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / galtheme.hxx
blobf542593d0d35989054b7009b2f292dbd570bd405
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/SfxBroadcaster.hxx>
29 #include <svl/lstner.hxx>
30 #include <svtools/transfer.hxx>
31 #include <svx/svdmodel.hxx>
32 #include <svx/galmisc.hxx>
33 #include <vector>
35 class SotStorage;
36 class SotStorageStream;
38 // - SgaObjKind -
41 struct GalleryObject
43 INetURLObject aURL;
44 sal_uInt32 nOffset;
45 SgaObjKind eObjKind;
46 bool mbDelete;
48 //UI visualization buffering
49 BitmapEx maPreviewBitmapEx;
50 Size maPreparedSize;
51 OUString maTitle;
52 OUString maPath;
55 typedef ::std::vector< GalleryObject* > GalleryObjectList;
57 class GalleryThemeEntry;
58 class SgaObject;
59 class FmFormModel;
60 class ListBox;
63 // - GalDragParams -
66 struct GalDragParams
68 vcl::Region aDragRegion;
69 sal_uIntPtr nDragObjPos;
70 OUString aThemeName;
71 OUString aFileName;
72 SgaObjKind eObjKind;
76 // - GalleryTheme -
79 class Gallery;
80 class GalleryProgress;
81 namespace unogallery
83 class GalleryTheme;
84 class GalleryItem;
87 class SVX_DLLPUBLIC GalleryTheme : public SfxBroadcaster
89 friend class Gallery;
90 friend class GalleryThemeCacheEntry;
91 friend class ::unogallery::GalleryTheme;
92 friend class ::unogallery::GalleryItem;
94 private:
96 GalleryObjectList aObjectList;
97 OUString m_aDestDir;
98 bool m_bDestDirRelative;
99 tools::SvRef<SotStorage> aSvDrawStorageRef;
100 Gallery* pParent;
101 GalleryThemeEntry* pThm;
102 sal_uIntPtr mnThemeLockCount;
103 sal_uIntPtr mnBroadcasterLockCount;
104 sal_uIntPtr nDragPos;
105 bool bDragging;
106 bool bAbortActualize;
108 SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
109 SgaObject* ImplReadSgaObject( GalleryObject* pEntry );
110 SAL_DLLPRIVATE bool ImplWriteSgaObject( const SgaObject& rObj, size_t nPos, GalleryObject* pExistentEntry );
111 SAL_DLLPRIVATE void ImplWrite();
112 SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject( size_t nPos ) const
113 { return ( nPos < aObjectList.size() ) ? aObjectList[ nPos ] : NULL; }
114 const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
116 SAL_DLLPRIVATE size_t ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
118 for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
119 if ( pObj == aObjectList[ i ] )
120 return i;
121 return size_t(-1);
123 SAL_DLLPRIVATE INetURLObject ImplGetURL( const GalleryObject* pObject ) const;
124 SAL_DLLPRIVATE INetURLObject ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPtr nFormat = CVT_UNKNOWN );
125 SAL_DLLPRIVATE void ImplSetModified( bool bModified );
126 SAL_DLLPRIVATE void ImplBroadcast( sal_uIntPtr nUpdatePos );
128 SAL_DLLPRIVATE GalleryTheme();
129 SAL_DLLPRIVATE GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
130 SAL_DLLPRIVATE virtual ~GalleryTheme();
132 GalleryTheme(GalleryTheme const &) = delete;
133 void operator =(GalleryTheme const &) = delete;
135 public:
137 SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly );
139 SAL_DLLPRIVATE size_t GetObjectCount() const { return aObjectList.size(); }
141 SgaObject* AcquireObject( size_t nPos );
142 static void ReleaseObject( SgaObject* pObj );
144 bool InsertObject( const SgaObject& rObj, sal_uIntPtr nPos = CONTAINER_APPEND );
145 bool RemoveObject( size_t nPos );
146 SAL_DLLPRIVATE bool ChangeObjectPos( size_t nOldPos, size_t nNewPos );
148 const OUString& GetName() const;
149 SAL_DLLPRIVATE const OUString& GetRealName() const;
151 // used for building gallery themes during compilation:
152 SAL_DLLPRIVATE const OUString& GetDestDir() const { return m_aDestDir; }
153 SAL_DLLPRIVATE void SetDestDir(const OUString& rDestDir, bool bRelative = true)
154 { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
156 SAL_DLLPRIVATE const INetURLObject& GetThmURL() const;
157 const INetURLObject& GetSdgURL() const;
158 SAL_DLLPRIVATE const INetURLObject& GetSdvURL() const;
160 sal_uInt32 GetId() const;
161 SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
163 SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
164 SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
166 SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
167 SAL_DLLPRIVATE bool UnlockTheme();
169 SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
170 void UnlockBroadcaster( sal_uIntPtr nUpdatePos = 0 );
171 SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
173 SAL_DLLPRIVATE void SetDragPos( sal_uIntPtr nPos ) { nDragPos = nPos; }
174 SAL_DLLPRIVATE sal_uIntPtr GetDragPos() const { return nDragPos; }
176 SAL_DLLPRIVATE bool IsThemeNameFromResource() const;
178 bool IsReadOnly() const;
179 bool IsDefault() const;
180 SAL_DLLPRIVATE bool IsModified() const;
182 void Actualize( const Link<>& rActualizeLink, GalleryProgress* pProgress = NULL );
183 SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
185 SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
186 SAL_DLLPRIVATE tools::SvRef<SotStorage> GetSvDrawStorage() const;
188 public:
190 SAL_DLLPRIVATE SgaObjKind GetObjectKind( sal_uIntPtr nPos ) const
192 DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
193 return ImplGetGalleryObject( nPos )->eObjKind;
197 SAL_DLLPRIVATE const INetURLObject& GetObjectURL( sal_uIntPtr nPos ) const
199 DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
200 return ImplGetGalleryObject( nPos )->aURL;
203 SAL_DLLPRIVATE bool GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, bool bProgress = false );
205 bool GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, bool bProgress = false );
206 bool InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
208 bool GetModel( sal_uIntPtr nPos, SdrModel& rModel, bool bProgress = false );
209 bool InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
211 SAL_DLLPRIVATE bool GetModelStream( sal_uIntPtr nPos, tools::SvRef<SotStorageStream>& rModelStreamRef, bool bProgress = false );
212 SAL_DLLPRIVATE bool InsertModelStream( const tools::SvRef<SotStorageStream>& rModelStream, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
214 SAL_DLLPRIVATE bool GetURL( sal_uIntPtr nPos, INetURLObject& rURL, bool bProgress = false );
215 bool InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
216 SAL_DLLPRIVATE bool InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
218 SAL_DLLPRIVATE bool InsertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos );
220 SAL_DLLPRIVATE void CopyToClipboard( vcl::Window* pWindow, sal_uIntPtr nPos );
221 SAL_DLLPRIVATE void StartDrag( vcl::Window* pWindow, sal_uIntPtr nPos );
223 public:
225 SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
226 SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
227 static void InsertAllThemes( ListBox& rListBox );
229 // for buffering PreviewBitmaps and strings for object and path
230 SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
231 SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
234 SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
235 SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme );
237 #endif
239 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */