Bump version to 6.4-15
[LibreOffice.git] / include / svx / gallery1.hxx
blobe0f4c4511bf6fc68143904627ddfa323ec0f3ffb
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>
33 class GalleryThemeEntry
35 private:
37 OUString aName;
38 INetURLObject aThmURL;
39 INetURLObject aSdgURL;
40 INetURLObject aSdvURL;
41 INetURLObject aStrURL;
42 sal_uInt32 nId;
43 bool const bReadOnly;
44 bool bModified;
45 bool bThemeNameFromResource;
47 static INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL );
49 public:
50 GalleryThemeEntry( bool bCreateUniqueURL,
51 const INetURLObject& rBaseURL,
52 const OUString& rName,
53 bool bReadOnly, bool bNewFile,
54 sal_uInt32 nId, bool bThemeNameFromResource );
56 const OUString& GetThemeName() const { return aName; }
58 const INetURLObject& GetThmURL() const { return aThmURL; }
59 const INetURLObject& GetSdgURL() const { return aSdgURL; }
60 const INetURLObject& GetSdvURL() const { return aSdvURL; }
61 const INetURLObject& GetStrURL() const { return aStrURL; }
63 OUString ReadStrFromIni(const OUString &aKeyName );
65 bool IsReadOnly() const { return bReadOnly; }
66 bool IsDefault() const;
68 bool IsHidden() const { return aName.match("private://gallery/hidden/"); }
70 bool IsModified() const { return bModified; }
71 void SetModified( bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
73 void SetName( const OUString& rNewName );
74 bool IsNameFromResource() const { return bThemeNameFromResource; }
76 sal_uInt32 GetId() const { return nId; }
77 void SetId( sal_uInt32 nNewId, bool bResetThemeName );
80 class SfxListener;
81 class GalleryTheme;
82 class GalleryThemeCacheEntry;
85 class SVX_DLLPUBLIC Gallery final : public SfxBroadcaster
87 typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
89 private:
91 std::vector< std::unique_ptr<GalleryThemeEntry> > aThemeList;
92 GalleryCacheThemeList aThemeCache;
93 INetURLObject aRelURL;
94 INetURLObject aUserURL;
95 bool bMultiPath;
97 SAL_DLLPRIVATE void ImplLoad( const OUString& rMultiPath );
98 SAL_DLLPRIVATE void ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbIsReadOnly );
100 GalleryThemeEntry* ImplGetThemeEntry( const OUString& rThemeName );
102 SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
103 SAL_DLLPRIVATE void ImplDeleteCachedTheme( GalleryTheme const * pTheme );
105 Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
106 Gallery( Gallery const & ) = delete; // MSVC2015 workaround
108 public:
109 // only for gengal utility!
110 Gallery( const OUString& rMultiPath );
111 virtual ~Gallery() override;
113 static Gallery* GetGalleryInstance();
115 SAL_DLLPRIVATE size_t GetThemeCount() const { return aThemeList.size(); }
116 SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( size_t nPos )
117 { return nPos < aThemeList.size() ? aThemeList[ nPos ].get() : nullptr; }
118 SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( const OUString& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
120 bool HasTheme( const OUString& rThemeName );
121 SAL_DLLPRIVATE OUString GetThemeName( sal_uInt32 nThemeId ) const;
123 bool CreateTheme( const OUString& rThemeName );
124 SAL_DLLPRIVATE void RenameTheme( const OUString& rOldName, const OUString& rNewName );
125 bool RemoveTheme( const OUString& rThemeName );
127 GalleryTheme* AcquireTheme( const OUString& rThemeName, SfxListener& rListener );
128 void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
130 public:
132 SAL_DLLPRIVATE const INetURLObject& GetUserURL() const { return aUserURL; }
133 SAL_DLLPRIVATE const INetURLObject& GetRelativeURL() const { return aRelURL; }
136 #endif // INCLUDED_SVX_GALLERY1_HXX
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */