1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <vcl/weld.hxx>
29 #include <svl/SfxBroadcaster.hxx>
30 #include <svl/lstner.hxx>
31 #include <vcl/transfer.hxx>
32 #include <svx/svdmodel.hxx>
33 #include <svx/galmisc.hxx>
38 class SotStorageStream
;
48 //UI visualization buffering
49 BitmapEx maPreviewBitmapEx
;
56 class GalleryThemeEntry
;
61 class GalleryProgress
;
70 class SVX_DLLPUBLIC GalleryTheme
: public SfxBroadcaster
73 friend class GalleryThemeCacheEntry
;
74 friend class ::unogallery::GalleryTheme
;
75 friend class ::unogallery::GalleryItem
;
79 ::std::vector
< std::unique_ptr
<GalleryObject
> > aObjectList
;
81 bool m_bDestDirRelative
;
82 tools::SvRef
<SotStorage
> aSvDrawStorageRef
;
83 Gallery
* const pParent
;
84 GalleryThemeEntry
* pThm
;
85 sal_uInt32 mnThemeLockCount
;
86 sal_uInt32 mnBroadcasterLockCount
;
91 SAL_DLLPRIVATE
void ImplCreateSvDrawStorage();
92 std::unique_ptr
<SgaObject
> ImplReadSgaObject( GalleryObject
const * pEntry
);
93 SAL_DLLPRIVATE
bool ImplWriteSgaObject(const SgaObject
& rObj
, sal_uInt32 nPos
, GalleryObject
* pExistentEntry
);
94 SAL_DLLPRIVATE
void ImplWrite();
95 SAL_DLLPRIVATE
const GalleryObject
* ImplGetGalleryObject(sal_uInt32 nPos
) const
96 { return aObjectList
[ nPos
].get(); }
97 const GalleryObject
* ImplGetGalleryObject( const INetURLObject
& rURL
);
99 SAL_DLLPRIVATE sal_uInt32
ImplGetGalleryObjectPos( const GalleryObject
* pObj
) const
101 for (sal_uInt32 i
= 0, n
= aObjectList
.size(); i
< n
; ++i
)
102 if ( pObj
== aObjectList
[ i
].get() )
104 return SAL_MAX_UINT32
;
106 SAL_DLLPRIVATE
static INetURLObject
ImplGetURL( const GalleryObject
* pObject
);
107 SAL_DLLPRIVATE INetURLObject
ImplCreateUniqueURL( SgaObjKind eObjKind
, ConvertDataFormat nFormat
= ConvertDataFormat::Unknown
);
108 SAL_DLLPRIVATE
void ImplSetModified( bool bModified
);
109 SAL_DLLPRIVATE
void ImplBroadcast(sal_uInt32 nUpdatePos
);
111 SAL_DLLPRIVATE
GalleryTheme( Gallery
* pGallery
, GalleryThemeEntry
* pThemeEntry
);
113 GalleryTheme(GalleryTheme
const &) = delete;
114 void operator =(GalleryTheme
const &) = delete;
118 SAL_DLLPRIVATE
virtual ~GalleryTheme() override
;
120 SAL_DLLPRIVATE
static GalleryThemeEntry
* CreateThemeEntry( const INetURLObject
& rURL
, bool bReadOnly
);
122 SAL_DLLPRIVATE sal_uInt32
GetObjectCount() const { return aObjectList
.size(); }
124 std::unique_ptr
<SgaObject
> AcquireObject(sal_uInt32 nPos
);
126 bool InsertObject(const SgaObject
& rObj
, sal_uInt32 nPos
= SAL_MAX_UINT32
);
127 void RemoveObject(sal_uInt32 nPos
);
128 SAL_DLLPRIVATE
bool ChangeObjectPos(sal_uInt32 nOldPos
, sal_uInt32 nNewPos
);
130 const OUString
& GetName() const;
132 // used for building gallery themes during compilation:
133 SAL_DLLPRIVATE
void SetDestDir(const OUString
& rDestDir
, bool bRelative
)
134 { m_aDestDir
= rDestDir
; m_bDestDirRelative
= bRelative
; }
136 SAL_DLLPRIVATE
const INetURLObject
& GetThmURL() const;
137 const INetURLObject
& GetSdgURL() const;
138 SAL_DLLPRIVATE
const INetURLObject
& GetSdvURL() const;
139 SAL_DLLPRIVATE
const INetURLObject
& GetStrURL() 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_uInt32 nPos
) { nDragPos
= nPos
; }
155 SAL_DLLPRIVATE sal_uInt32
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;
170 SAL_DLLPRIVATE SgaObjKind
GetObjectKind(sal_uInt32 nPos
) const
172 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
173 return ImplGetGalleryObject( nPos
)->eObjKind
;
177 SAL_DLLPRIVATE
const INetURLObject
& GetObjectURL(sal_uInt32 nPos
) const
179 DBG_ASSERT( nPos
< GetObjectCount(), "Position out of range" );
180 return ImplGetGalleryObject( nPos
)->aURL
;
183 SAL_DLLPRIVATE
bool GetThumb(sal_uInt32 nPos
, BitmapEx
& rBmp
);
185 bool GetGraphic(sal_uInt32 nPos
, Graphic
& rGraphic
);
186 bool InsertGraphic(const Graphic
& rGraphic
, sal_uInt32 nInsertPos
);
188 bool GetModel(sal_uInt32 nPos
, SdrModel
& rModel
);
189 bool InsertModel(const FmFormModel
& rModel
, sal_uInt32 nInsertPos
);
191 SAL_DLLPRIVATE
bool GetModelStream(sal_uInt32 nPos
, tools::SvRef
<SotStorageStream
> const & rModelStreamRef
);
192 SAL_DLLPRIVATE
bool InsertModelStream(const tools::SvRef
<SotStorageStream
>& rModelStream
, sal_uInt32 nInsertPos
);
194 SAL_DLLPRIVATE
bool GetURL(sal_uInt32 nPos
, INetURLObject
& rURL
);
195 bool InsertURL(const INetURLObject
& rURL
, sal_uInt32 nInsertPos
= SAL_MAX_UINT32
);
196 SAL_DLLPRIVATE
bool InsertFileOrDirURL(const INetURLObject
& rFileOrDirURL
, sal_uInt32 nInsertPos
);
198 SAL_DLLPRIVATE
bool InsertTransferable(const css::uno::Reference
< css::datatransfer::XTransferable
>& rxTransferable
, sal_uInt32 nInsertPos
);
200 SAL_DLLPRIVATE
void CopyToClipboard(vcl::Window
* pWindow
, sal_uInt32 nPos
);
201 SAL_DLLPRIVATE
void StartDrag(vcl::Window
* pWindow
, sal_uInt32 nPos
);
205 SAL_DLLPRIVATE SvStream
& WriteData( SvStream
& rOut
) const;
206 SAL_DLLPRIVATE SvStream
& ReadData( SvStream
& rIn
);
207 static void InsertAllThemes(weld::ComboBox
& rListBox
);
209 // for buffering PreviewBitmaps and strings for object and path
210 SAL_DLLPRIVATE
void GetPreviewBitmapExAndStrings(sal_uInt32 nPos
, BitmapEx
& rBitmapEx
, Size
& rSize
, OUString
& rTitle
, OUString
& rPath
) const;
211 SAL_DLLPRIVATE
void SetPreviewBitmapExAndStrings(sal_uInt32 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: */