Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef INCLUDED_SVX_GALTHEME_HXX
21 : #define INCLUDED_SVX_GALTHEME_HXX
22 :
23 : #include <svx/svxdllapi.h>
24 :
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 <sot/storage.hxx>
32 : #include <svx/svdmodel.hxx>
33 : #include <svx/galmisc.hxx>
34 : #include <vector>
35 :
36 :
37 : // - GalleryObject -
38 :
39 :
40 : // - SgaObjKind -
41 :
42 :
43 1006 : struct GalleryObject
44 : {
45 : INetURLObject aURL;
46 : sal_uInt32 nOffset;
47 : SgaObjKind eObjKind;
48 : bool mbDelete;
49 :
50 : //UI visualization buffering
51 : BitmapEx maPreviewBitmapEx;
52 : Size maPreparedSize;
53 : OUString maTitle;
54 : OUString maPath;
55 : };
56 :
57 : typedef ::std::vector< GalleryObject* > GalleryObjectList;
58 :
59 : class GalleryThemeEntry;
60 : class SgaObject;
61 : class FmFormModel;
62 : class ListBox;
63 :
64 :
65 : // - GalDragParams -
66 :
67 :
68 : struct GalDragParams
69 : {
70 : vcl::Region aDragRegion;
71 : sal_uIntPtr nDragObjPos;
72 : OUString aThemeName;
73 : OUString aFileName;
74 : SgaObjKind eObjKind;
75 : };
76 :
77 :
78 : // - GalleryTheme -
79 :
80 :
81 : class Gallery;
82 : class GalleryProgress;
83 : namespace unogallery
84 : {
85 : class GalleryTheme;
86 : class GalleryItem;
87 : }
88 :
89 : class SVX_DLLPUBLIC GalleryTheme : public SfxBroadcaster
90 : {
91 : friend class Gallery;
92 : friend class GalleryThemeCacheEntry;
93 : friend class ::unogallery::GalleryTheme;
94 : friend class ::unogallery::GalleryItem;
95 :
96 : private:
97 :
98 : GalleryObjectList aObjectList;
99 : OUString m_aDestDir;
100 : bool m_bDestDirRelative;
101 : SotStorageRef aSvDrawStorageRef;
102 : Gallery* pParent;
103 : GalleryThemeEntry* pThm;
104 : sal_uIntPtr mnThemeLockCount;
105 : sal_uIntPtr mnBroadcasterLockCount;
106 : sal_uIntPtr nDragPos;
107 : bool bDragging;
108 : bool bAbortActualize;
109 :
110 : SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
111 : SgaObject* ImplReadSgaObject( GalleryObject* pEntry );
112 : SAL_DLLPRIVATE bool ImplWriteSgaObject( const SgaObject& rObj, size_t nPos, GalleryObject* pExistentEntry );
113 : SAL_DLLPRIVATE void ImplWrite();
114 503 : SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject( size_t nPos ) const
115 503 : { return ( nPos < aObjectList.size() ) ? aObjectList[ nPos ] : NULL; }
116 : const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
117 :
118 0 : SAL_DLLPRIVATE size_t ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
119 : {
120 0 : for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
121 0 : if ( pObj == aObjectList[ i ] )
122 0 : return i;
123 0 : return size_t(-1);
124 : }
125 : SAL_DLLPRIVATE INetURLObject ImplGetURL( const GalleryObject* pObject ) const;
126 : SAL_DLLPRIVATE INetURLObject ImplCreateUniqueURL( SgaObjKind eObjKind, sal_uIntPtr nFormat = CVT_UNKNOWN );
127 : SAL_DLLPRIVATE void ImplSetModified( bool bModified );
128 : SAL_DLLPRIVATE void ImplBroadcast( sal_uIntPtr nUpdatePos );
129 :
130 : SAL_DLLPRIVATE GalleryTheme();
131 : SAL_DLLPRIVATE GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
132 : SAL_DLLPRIVATE virtual ~GalleryTheme();
133 :
134 : public:
135 :
136 : SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly );
137 :
138 2034 : SAL_DLLPRIVATE size_t GetObjectCount() const { return aObjectList.size(); }
139 :
140 : SgaObject* AcquireObject( size_t nPos );
141 : void ReleaseObject( SgaObject* pObj );
142 :
143 : bool InsertObject( const SgaObject& rObj, sal_uIntPtr nPos = CONTAINER_APPEND );
144 : bool RemoveObject( size_t nPos );
145 : SAL_DLLPRIVATE bool ChangeObjectPos( size_t nOldPos, size_t nNewPos );
146 :
147 : const OUString& GetName() const;
148 : SAL_DLLPRIVATE const OUString& GetRealName() const;
149 :
150 : // used for building gallery themes during compilation:
151 : SAL_DLLPRIVATE const OUString& GetDestDir() const { return m_aDestDir; }
152 11 : SAL_DLLPRIVATE void SetDestDir(const OUString& rDestDir, bool bRelative = true)
153 11 : { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
154 :
155 : SAL_DLLPRIVATE const INetURLObject& GetThmURL() const;
156 : const INetURLObject& GetSdgURL() const;
157 : SAL_DLLPRIVATE const INetURLObject& GetSdvURL() const;
158 :
159 : sal_uInt32 GetId() const;
160 : SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
161 :
162 0 : SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
163 0 : SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
164 :
165 0 : SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
166 : SAL_DLLPRIVATE bool UnlockTheme();
167 :
168 0 : SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
169 : void UnlockBroadcaster( sal_uIntPtr nUpdatePos = 0 );
170 503 : SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
171 :
172 0 : SAL_DLLPRIVATE void SetDragPos( sal_uIntPtr nPos ) { nDragPos = nPos; }
173 0 : SAL_DLLPRIVATE sal_uIntPtr GetDragPos() const { return nDragPos; }
174 :
175 : SAL_DLLPRIVATE bool IsThemeNameFromResource() const;
176 :
177 : bool IsReadOnly() const;
178 : bool IsDefault() const;
179 : SAL_DLLPRIVATE bool IsModified() const;
180 :
181 : void Actualize( const Link& rActualizeLink, GalleryProgress* pProgress = NULL );
182 0 : SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
183 :
184 66 : SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
185 0 : SAL_DLLPRIVATE SotStorageRef GetSvDrawStorage() const { return aSvDrawStorageRef; }
186 :
187 : public:
188 :
189 0 : SAL_DLLPRIVATE SgaObjKind GetObjectKind( sal_uIntPtr nPos ) const
190 : {
191 : DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
192 0 : return ImplGetGalleryObject( nPos )->eObjKind;
193 : }
194 :
195 :
196 0 : SAL_DLLPRIVATE const INetURLObject& GetObjectURL( sal_uIntPtr nPos ) const
197 : {
198 : DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
199 0 : return ImplGetGalleryObject( nPos )->aURL;
200 : }
201 :
202 : SAL_DLLPRIVATE bool GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, bool bProgress = false );
203 :
204 : bool GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, bool bProgress = false );
205 : bool InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
206 :
207 : bool GetModel( sal_uIntPtr nPos, SdrModel& rModel, bool bProgress = false );
208 : bool InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
209 :
210 : SAL_DLLPRIVATE bool GetModelStream( sal_uIntPtr nPos, SotStorageStreamRef& rModelStreamRef, bool bProgress = false );
211 : SAL_DLLPRIVATE bool InsertModelStream( const SotStorageStreamRef& rModelStream, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
212 :
213 : SAL_DLLPRIVATE bool GetURL( sal_uIntPtr nPos, INetURLObject& rURL, bool bProgress = false );
214 : bool InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
215 : SAL_DLLPRIVATE bool InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
216 :
217 : SAL_DLLPRIVATE bool InsertTransferable( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos );
218 :
219 : SAL_DLLPRIVATE void CopyToClipboard( vcl::Window* pWindow, sal_uIntPtr nPos );
220 : SAL_DLLPRIVATE void StartDrag( vcl::Window* pWindow, sal_uIntPtr nPos );
221 :
222 : public:
223 :
224 : SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
225 : SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
226 : static void InsertAllThemes( ListBox& rListBox );
227 :
228 : // for buffering PreviewBitmaps and strings for object and path
229 : SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
230 : SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
231 : };
232 :
233 : SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
234 : SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme );
235 :
236 : #endif
237 :
238 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|