Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / galtheme.hxx
blob2b6b15ce92366312ba55359b0a89aec23a186283
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 );
114 GalleryTheme(GalleryTheme const &) = delete;
115 void operator =(GalleryTheme const &) = delete;
117 public:
119 SAL_DLLPRIVATE virtual ~GalleryTheme() override;
121 SAL_DLLPRIVATE static GalleryThemeEntry* CreateThemeEntry( const INetURLObject& rURL, bool bReadOnly );
123 SAL_DLLPRIVATE size_t GetObjectCount() const { return aObjectList.size(); }
125 SgaObject* AcquireObject( size_t nPos );
126 static void ReleaseObject( SgaObject* pObj );
128 bool InsertObject( const SgaObject& rObj, sal_uIntPtr nPos = CONTAINER_APPEND );
129 bool RemoveObject( size_t nPos );
130 SAL_DLLPRIVATE bool ChangeObjectPos( size_t nOldPos, size_t nNewPos );
132 const OUString& GetName() const;
134 // used for building gallery themes during compilation:
135 SAL_DLLPRIVATE void SetDestDir(const OUString& rDestDir, bool bRelative)
136 { m_aDestDir = rDestDir; m_bDestDirRelative = bRelative; }
138 SAL_DLLPRIVATE const INetURLObject& GetThmURL() const;
139 const INetURLObject& GetSdgURL() const;
140 SAL_DLLPRIVATE const INetURLObject& GetSdvURL() const;
142 sal_uInt32 GetId() const;
143 SAL_DLLPRIVATE void SetId( sal_uInt32 nNewId, bool bResetThemeName );
145 SAL_DLLPRIVATE void SetDragging( bool bSet ) { bDragging = bSet; }
146 SAL_DLLPRIVATE bool IsDragging() const { return bDragging; }
148 SAL_DLLPRIVATE void LockTheme() { ++mnThemeLockCount; }
149 SAL_DLLPRIVATE bool UnlockTheme();
151 SAL_DLLPRIVATE void LockBroadcaster() { mnBroadcasterLockCount++; }
152 void UnlockBroadcaster();
153 SAL_DLLPRIVATE bool IsBroadcasterLocked() const { return mnBroadcasterLockCount > 0; }
155 SAL_DLLPRIVATE void SetDragPos( sal_uIntPtr nPos ) { nDragPos = nPos; }
156 SAL_DLLPRIVATE sal_uIntPtr GetDragPos() const { return nDragPos; }
158 SAL_DLLPRIVATE bool IsThemeNameFromResource() const;
160 bool IsReadOnly() const;
161 bool IsDefault() const;
163 void Actualize( const Link<const INetURLObject&, void>& rActualizeLink, GalleryProgress* pProgress = nullptr );
164 SAL_DLLPRIVATE void AbortActualize() { bAbortActualize = true; }
166 SAL_DLLPRIVATE Gallery* GetParent() const { return pParent; }
167 SAL_DLLPRIVATE const tools::SvRef<SotStorage>& GetSvDrawStorage() const;
169 public:
171 SAL_DLLPRIVATE SgaObjKind GetObjectKind( sal_uIntPtr nPos ) const
173 DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
174 return ImplGetGalleryObject( nPos )->eObjKind;
178 SAL_DLLPRIVATE const INetURLObject& GetObjectURL( sal_uIntPtr nPos ) const
180 DBG_ASSERT( nPos < GetObjectCount(), "Position out of range" );
181 return ImplGetGalleryObject( nPos )->aURL;
184 SAL_DLLPRIVATE bool GetThumb( sal_uIntPtr nPos, BitmapEx& rBmp );
186 bool GetGraphic( sal_uIntPtr nPos, Graphic& rGraphic, bool bProgress = false );
187 bool InsertGraphic( const Graphic& rGraphic, sal_uIntPtr nInsertPos );
189 bool GetModel( sal_uIntPtr nPos, SdrModel& rModel );
190 bool InsertModel( const FmFormModel& rModel, sal_uIntPtr nInsertPos );
192 SAL_DLLPRIVATE bool GetModelStream( sal_uIntPtr nPos, tools::SvRef<SotStorageStream>& rModelStreamRef );
193 SAL_DLLPRIVATE bool InsertModelStream( const tools::SvRef<SotStorageStream>& rModelStream, sal_uIntPtr nInsertPos );
195 SAL_DLLPRIVATE bool GetURL( sal_uIntPtr nPos, INetURLObject& rURL );
196 bool InsertURL( const INetURLObject& rURL, sal_uIntPtr nInsertPos = CONTAINER_APPEND );
197 SAL_DLLPRIVATE bool InsertFileOrDirURL( const INetURLObject& rFileOrDirURL, sal_uIntPtr nInsertPos );
199 SAL_DLLPRIVATE bool InsertTransferable( const css::uno::Reference< css::datatransfer::XTransferable >& rxTransferable, sal_uIntPtr nInsertPos );
201 SAL_DLLPRIVATE void CopyToClipboard( vcl::Window* pWindow, sal_uIntPtr nPos );
202 SAL_DLLPRIVATE void StartDrag( vcl::Window* pWindow, sal_uIntPtr nPos );
204 public:
206 SAL_DLLPRIVATE SvStream& WriteData( SvStream& rOut ) const;
207 SAL_DLLPRIVATE SvStream& ReadData( SvStream& rIn );
208 static void InsertAllThemes( ListBox& rListBox );
210 // for buffering PreviewBitmaps and strings for object and path
211 SAL_DLLPRIVATE void GetPreviewBitmapExAndStrings(sal_uIntPtr nPos, BitmapEx& rBitmapEx, Size& rSize, OUString& rTitle, OUString& rPath) const;
212 SAL_DLLPRIVATE void SetPreviewBitmapExAndStrings(sal_uIntPtr nPos, const BitmapEx& rBitmapEx, const Size& rSize, const OUString& rTitle, const OUString& rPath);
215 SvStream& WriteGalleryTheme( SvStream& rOut, const GalleryTheme& rTheme );
216 SvStream& ReadGalleryTheme( SvStream& rIn, GalleryTheme& rTheme );
218 #endif // INCLUDED_SVX_GALTHEME_HXX
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */