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