Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / svx / gallery1.hxx
blob6f159e3b51398ba55f39fa3990be7cec7c2b76cb
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_GALLERY1_HXX
21 #define INCLUDED_SVX_GALLERY1_HXX
23 #include <rtl/ustring.hxx>
24 #include <svl/SfxBroadcaster.hxx>
25 #include <svx/svxdllapi.h>
26 #include <tools/urlobj.hxx>
28 #include <cstdio>
29 #include <memory>
30 #include <vector>
32 class Gallery;
33 class GalleryFileStorage;
34 class GalleryFileStorageEntry;
35 class GalleryObjectCollection;
36 class GalleryStorageLocations;
37 class GalleryTheme;
39 class SVXCORE_DLLPUBLIC GalleryThemeEntry
41 private:
43 std::unique_ptr<GalleryFileStorageEntry> mpGalleryStorageEngineEntry;
44 OUString aName;
45 sal_uInt32 nId;
46 bool bReadOnly;
47 bool bModified;
48 bool bThemeNameFromResource;
50 public:
51 GalleryThemeEntry( bool bCreateUniqueURL,
52 const INetURLObject& rBaseURL,
53 const OUString& rName,
54 bool bReadOnly, bool bNewFile,
55 sal_uInt32 nId, bool bThemeNameFromResource );
56 ~GalleryThemeEntry();
58 const std::unique_ptr<GalleryFileStorageEntry>& getGalleryStorageEngineEntry() const { return mpGalleryStorageEngineEntry; }
60 GalleryStorageLocations& getGalleryStorageLocations() const;
62 GalleryTheme* createGalleryTheme(Gallery* pGallery);
64 std::unique_ptr<GalleryFileStorage> createGalleryStorageEngine(GalleryObjectCollection& mrGalleryObjectCollection);
66 const OUString& GetThemeName() const { return aName; }
68 bool IsReadOnly() const { return bReadOnly; }
69 bool IsDefault() const;
71 bool IsHidden() const { return aName.match("private://gallery/hidden/"); }
73 bool IsModified() const { return bModified; }
74 void SetModified( bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
76 void SetName( const OUString& rNewName );
77 bool IsNameFromResource() const { return bThemeNameFromResource; }
79 sal_uInt32 GetId() const { return nId; }
80 void SetId( sal_uInt32 nNewId, bool bResetThemeName );
83 void removeTheme();
85 std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery);
87 void setStorageLocations(INetURLObject& rURL);
90 class SfxListener;
91 class GalleryTheme;
92 class GalleryThemeCacheEntry;
95 class SVXCORE_DLLPUBLIC Gallery final : public SfxBroadcaster
97 typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
99 private:
101 std::vector< std::unique_ptr<GalleryThemeEntry> > aThemeList;
102 GalleryCacheThemeList aThemeCache;
103 INetURLObject aRelURL;
104 INetURLObject aUserURL;
105 bool bMultiPath;
107 SAL_DLLPRIVATE void ImplLoad( std::u16string_view rMultiPath );
108 SAL_DLLPRIVATE void ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbIsReadOnly );
110 GalleryThemeEntry* ImplGetThemeEntry( std::u16string_view rThemeName );
112 SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( GalleryThemeEntry* pThemeEntry );
113 SAL_DLLPRIVATE void ImplDeleteCachedTheme( GalleryTheme const * pTheme );
115 Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
116 Gallery( Gallery const & ) = delete; // MSVC2015 workaround
118 public:
119 // only for gengal utility!
120 Gallery( std::u16string_view rMultiPath );
121 virtual ~Gallery() override;
123 static Gallery* GetGalleryInstance();
125 size_t GetThemeCount() const { return aThemeList.size(); }
126 SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( size_t nPos )
127 { return nPos < aThemeList.size() ? aThemeList[ nPos ].get() : nullptr; }
128 const GalleryThemeEntry* GetThemeInfo( std::u16string_view rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
130 bool HasTheme( std::u16string_view rThemeName );
131 SAL_DLLPRIVATE OUString GetThemeName( sal_uInt32 nThemeId ) const;
133 bool CreateTheme( const OUString& rThemeName );
134 void RenameTheme( const OUString& rOldName, const OUString& rNewName );
135 bool RemoveTheme( const OUString& rThemeName );
137 GalleryTheme* AcquireTheme( std::u16string_view rThemeName, SfxListener& rListener );
138 void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
140 public:
142 SAL_DLLPRIVATE const INetURLObject& GetUserURL() const { return aUserURL; }
143 SAL_DLLPRIVATE const INetURLObject& GetRelativeURL() const { return aRelURL; }
146 #endif // INCLUDED_SVX_GALLERY1_HXX
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */