build fix
[LibreOffice.git] / include / svx / galtheme.hxx
blobf93fd1b40df5e74b5f3a3ab5a149f335dd1c0e00
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;
39 struct GalleryObject
41 INetURLObject aURL;
42 sal_uInt32 nOffset;
43 SgaObjKind eObjKind;
44 bool mbDelete;
46 //UI visualization buffering
47 BitmapEx maPreviewBitmapEx;
48 Size maPreparedSize;
49 OUString maTitle;
50 OUString maPath;
54 typedef ::std::vector< GalleryObject* > GalleryObjectList;
56 class GalleryThemeEntry;
57 class SgaObject;
58 class FmFormModel;
59 class ListBox;
61 class Gallery;
62 class GalleryProgress;
64 namespace unogallery
66 class GalleryTheme;
67 class GalleryItem;
71 class SVX_DLLPUBLIC GalleryTheme : public SfxBroadcaster
73 friend class Gallery;
74 friend class GalleryThemeCacheEntry;
75 friend class ::unogallery::GalleryTheme;
76 friend class ::unogallery::GalleryItem;
78 private:
80 GalleryObjectList aObjectList;
81 OUString m_aDestDir;
82 bool m_bDestDirRelative;
83 tools::SvRef<SotStorage> aSvDrawStorageRef;
84 Gallery* pParent;
85 GalleryThemeEntry* pThm;
86 sal_uIntPtr mnThemeLockCount;
87 sal_uIntPtr mnBroadcasterLockCount;
88 sal_uIntPtr nDragPos;
89 bool bDragging;
90 bool bAbortActualize;
92 SAL_DLLPRIVATE void ImplCreateSvDrawStorage();
93 SgaObject* ImplReadSgaObject( GalleryObject* pEntry );
94 SAL_DLLPRIVATE bool ImplWriteSgaObject( const SgaObject& rObj, size_t nPos, GalleryObject* pExistentEntry );
95 SAL_DLLPRIVATE void ImplWrite();
96 SAL_DLLPRIVATE const GalleryObject* ImplGetGalleryObject( size_t nPos ) const
97 { return ( nPos < aObjectList.size() ) ? aObjectList[ nPos ] : nullptr; }
98 const GalleryObject* ImplGetGalleryObject( const INetURLObject& rURL );
100 SAL_DLLPRIVATE size_t ImplGetGalleryObjectPos( const GalleryObject* pObj ) const
102 for ( size_t i = 0, n = aObjectList.size(); i < n; ++i )
103 if ( pObj == aObjectList[ i ] )
104 return i;
105 return size_t(-1);
107 SAL_DLLPRIVATE static INetURLObject ImplGetURL( const GalleryObject* pObject );
108 SAL_DLLPRIVATE INetURLObject ImplCreateUniqueURL( SgaObjKind eObjKind, ConvertDataFormat nFormat = ConvertDataFormat::Unknown );
109 SAL_DLLPRIVATE void ImplSetModified( bool bModified );
110 SAL_DLLPRIVATE void ImplBroadcast( sal_uIntPtr nUpdatePos );
112 SAL_DLLPRIVATE GalleryTheme( Gallery* pGallery, GalleryThemeEntry* pThemeEntry );
113 SAL_DLLPRIVATE virtual ~GalleryTheme() override;
115 GalleryTheme(GalleryTheme const &) = delete;
116 void operator =(GalleryTheme const &) = delete;
118 public:
120 SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly );
122 SAL_DLLPRIVATE size_t GetObjectCount() const { return aObjectList.size(); }
124 SgaObject* AcquireObject( size_t nPos );
125 static void ReleaseObject( SgaObject* pObj );
127 bool InsertObject( const SgaObject& rObj, sal_uIntPtr nPos = CONTAINER_APPEND );
128 bool RemoveObject( size_t nPos );
129 SAL_DLLPRIVATE bool ChangeObjectPos( size_t nOldPos, size_t nNewPos );
131 const OUString& GetName() const;
133 // used for building gallery themes during compilation:
134 SAL_DLLPRIVATE void SetDestDir(const OUString& rDestDir, bool bRelative)
135 { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
137 SAL_DLLPRIVATE const INetURLObject& GetThmURL() const;
138 const INetURLObject& GetSdgURL() const;
139 SAL_DLLPRIVATE const INetURLObject& GetSdvURL() const;
141 sal_uInt32 GetId() const;
142 SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
144 SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
145 SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
147 SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
148 SAL_DLLPRIVATE bool UnlockTheme();
150 SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
151 void UnlockBroadcaster();
152 SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
154 SAL_DLLPRIVATE void SetDragPos( sal_uIntPtr nPos ) { nDragPos = nPos; }
155 SAL_DLLPRIVATE sal_uIntPtr GetDragPos() const { return nDragPos; }
157 SAL_DLLPRIVATE bool IsThemeNameFromResource() const;
159 bool IsReadOnly() const;
160 bool IsDefault() const;
162 void Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress = nullptr );
163 SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
165 SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
166 SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
168 public:
170 SAL_DLLPRIVATE SgaObjKind GetObjectKind( sal_uIntPtr nPos ) const
172 DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
173 return ImplGetGalleryObject( nPos )->eObjKind;
177 SAL_DLLPRIVATE const INetURLObject& GetObjectURL( sal_uIntPtr nPos ) const
179 DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
180 return ImplGetGalleryObject( nPos )->aURL;
183 SAL_DLLPRIVATE bool GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp, bool bProgress = false );
185 bool GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, bool bProgress = false );
186 bool InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos );
188 bool GetModel( sal_uIntPtr nPos, SdrModel& rModel, bool bProgress = false );
189 bool InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos );
191 SAL_DLLPRIVATE bool GetModelStream( sal_uIntPtr nPos, tools::SvRef<SotStorageStream>& rModelStreamRef );
192 SAL_DLLPRIVATE bool InsertModelStream( const tools::SvRef<SotStorageStream>& rModelStream, sal_uIntPtr nInsertPos );
194 SAL_DLLPRIVATE bool GetURL( sal_uIntPtr nPos, INetURLObject& rURL );
195 bool InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
196 SAL_DLLPRIVATE bool InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos );
198 SAL_DLLPRIVATE bool InsertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos );
200 SAL_DLLPRIVATE void CopyToClipboard( vcl::Window* pWindow, sal_uIntPtr nPos );
201 SAL_DLLPRIVATE void StartDrag( vcl::Window* pWindow, sal_uIntPtr nPos );
203 public:
205 SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
206 SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
207 static void InsertAllThemes( ListBox& rListBox );
209 // for buffering PreviewBitmaps and strings for object and path
210 SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
211 SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
214 SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
215 SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme );
217 #endif // INCLUDED_SVX_GALTHEME_HXX
219 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */