LibreOffice Module svx (master) 1
gallery1.hxx
Go to the documentation of this file.
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_GALLERY1_HXX
21#define INCLUDED_SVX_GALLERY1_HXX
22
23#include <rtl/ustring.hxx>
25#include <svx/svxdllapi.h>
26#include <tools/urlobj.hxx>
29
30#include <cstdio>
31#include <memory>
32#include <vector>
33
36class GalleryTheme;
37
39{
40private:
41
42 std::unique_ptr<GalleryBinaryEngineEntry> mpGalleryStorageEngineEntry;
43 OUString aName;
44 sal_uInt32 nId;
48
49public:
50 GalleryThemeEntry( bool bCreateUniqueURL,
51 const INetURLObject& rBaseURL,
52 const OUString& rName,
53 bool bReadOnly, bool bNewFile,
54 sal_uInt32 nId, bool bThemeNameFromResource );
55
56 const std::unique_ptr<GalleryBinaryEngineEntry>& getGalleryStorageEngineEntry() const { return mpGalleryStorageEngineEntry; }
57
58 GalleryStorageLocations& getGalleryStorageLocations() const { return *mpGalleryStorageEngineEntry->getGalleryStorageLocations(); }
59
61
62 std::unique_ptr<GalleryBinaryEngine> createGalleryStorageEngine(GalleryObjectCollection& mrGalleryObjectCollection);
63
64 const OUString& GetThemeName() const { return aName; }
65
66 bool IsReadOnly() const { return bReadOnly; }
67 bool IsDefault() const;
68
69 bool IsHidden() const { return aName.match("private://gallery/hidden/"); }
70
71 bool IsModified() const { return bModified; }
72 void SetModified( bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
73
74 void SetName( const OUString& rNewName );
76
77 sal_uInt32 GetId() const { return nId; }
78 void SetId( sal_uInt32 nNewId, bool bResetThemeName );
79
80
81 void removeTheme();
82
83 std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery);
84
86};
87
88class SfxListener;
89class GalleryTheme;
91
92
94{
95 typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
96
97private:
98
99 std::vector< std::unique_ptr<GalleryThemeEntry> > aThemeList;
104
105 SAL_DLLPRIVATE void ImplLoad( std::u16string_view rMultiPath );
106 SAL_DLLPRIVATE void ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbIsReadOnly );
107
108 GalleryThemeEntry* ImplGetThemeEntry( std::u16string_view rThemeName );
109
110 SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( GalleryThemeEntry* pThemeEntry );
111 SAL_DLLPRIVATE void ImplDeleteCachedTheme( GalleryTheme const * pTheme );
112
113 Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
114 Gallery( Gallery const & ) = delete; // MSVC2015 workaround
115
116public:
117 // only for gengal utility!
118 Gallery( std::u16string_view rMultiPath );
119 virtual ~Gallery() override;
120
121 static Gallery* GetGalleryInstance();
122
123 size_t GetThemeCount() const { return aThemeList.size(); }
124 SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( size_t nPos )
125 { return nPos < aThemeList.size() ? aThemeList[ nPos ].get() : nullptr; }
126 const GalleryThemeEntry* GetThemeInfo( std::u16string_view rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
127
128 bool HasTheme( std::u16string_view rThemeName );
129 SAL_DLLPRIVATE OUString GetThemeName( sal_uInt32 nThemeId ) const;
130
131 bool CreateTheme( const OUString& rThemeName );
132 void RenameTheme( const OUString& rOldName, const OUString& rNewName );
133 bool RemoveTheme( const OUString& rThemeName );
134
135 GalleryTheme* AcquireTheme( std::u16string_view rThemeName, SfxListener& rListener );
136 void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
137
138public:
139
140 SAL_DLLPRIVATE const INetURLObject& GetUserURL() const { return aUserURL; }
141 SAL_DLLPRIVATE const INetURLObject& GetRelativeURL() const { return aRelURL; }
142};
143
144#endif // INCLUDED_SVX_GALLERY1_HXX
145
146/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const std::unique_ptr< GalleryBinaryEngineEntry > & getGalleryStorageEngineEntry() const
Definition: gallery1.hxx:56
const OUString & GetThemeName() const
Definition: gallery1.hxx:64
sal_uInt32 nId
Definition: gallery1.hxx:44
bool IsReadOnly() const
Definition: gallery1.hxx:66
std::unique_ptr< GalleryBinaryEngineEntry > mpGalleryStorageEngineEntry
Definition: gallery1.hxx:42
bool IsNameFromResource() const
Definition: gallery1.hxx:75
GalleryThemeEntry(bool bCreateUniqueURL, const INetURLObject &rBaseURL, const OUString &rName, bool bReadOnly, bool bNewFile, sal_uInt32 nId, bool bThemeNameFromResource)
Definition: gallery1.cxx:111
GalleryTheme * createGalleryTheme(Gallery *pGallery)
Definition: gallery1.cxx:171
GalleryStorageLocations & getGalleryStorageLocations() const
Definition: gallery1.hxx:58
sal_uInt32 GetId() const
Definition: gallery1.hxx:77
void setStorageLocations(INetURLObject &rURL)
Definition: gallery1.cxx:166
bool IsDefault() const
Definition: gallery1.cxx:719
OUString aName
Definition: gallery1.hxx:43
std::unique_ptr< GalleryBinaryEngine > createGalleryStorageEngine(GalleryObjectCollection &mrGalleryObjectCollection)
Definition: gallery1.cxx:176
bool bThemeNameFromResource
Definition: gallery1.hxx:47
void SetModified(bool bSet)
Definition: gallery1.hxx:72
std::unique_ptr< GalleryTheme > getCachedTheme(Gallery *pGallery)
Definition: gallery1.cxx:650
bool IsHidden() const
Definition: gallery1.hxx:69
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: gallery1.cxx:200
bool IsModified() const
Definition: gallery1.hxx:71
void SetName(const OUString &rNewName)
Definition: gallery1.cxx:190
std::vector< GalleryThemeCacheEntry * > GalleryCacheThemeList
Definition: gallery1.hxx:95
bool bMultiPath
Definition: gallery1.hxx:103
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
Definition: gallery1.hxx:140
const GalleryThemeEntry * GetThemeInfo(std::u16string_view rThemeName)
Definition: gallery1.hxx:126
Gallery(Gallery const &)=delete
INetURLObject aUserURL
Definition: gallery1.hxx:102
size_t GetThemeCount() const
Definition: gallery1.hxx:123
SAL_DLLPRIVATE const GalleryThemeEntry * GetThemeInfo(size_t nPos)
Definition: gallery1.hxx:124
std::vector< std::unique_ptr< GalleryThemeEntry > > aThemeList
Definition: gallery1.hxx:99
GalleryCacheThemeList aThemeCache
Definition: gallery1.hxx:100
INetURLObject aRelURL
Definition: gallery1.hxx:101
SAL_DLLPRIVATE const INetURLObject & GetRelativeURL() const
Definition: gallery1.hxx:141
Gallery & operator=(Gallery const &)=delete
sal_uInt16 nPos
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35