Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/gallery1.hxx
Line
Count
Source
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>
24
#include <svl/SfxBroadcaster.hxx>
25
#include <svx/svxdllapi.h>
26
#include <tools/urlobj.hxx>
27
28
#include <cstdio>
29
#include <memory>
30
#include <vector>
31
32
class Gallery;
33
class GalleryFileStorage;
34
class GalleryFileStorageEntry;
35
class GalleryObjectCollection;
36
class GalleryStorageLocations;
37
class GalleryTheme;
38
39
class SVXCORE_DLLPUBLIC GalleryThemeEntry
40
{
41
private:
42
43
    std::unique_ptr<GalleryFileStorageEntry> mpGalleryStorageEngineEntry;
44
    OUString                maName;
45
    sal_uInt32              mnId;
46
    bool                    mbReadOnly;
47
    bool                    mbModified;
48
    bool                    mbThemeNameFromResource;
49
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();
57
    
58
    GalleryStorageLocations& getGalleryStorageLocations() const;
59
60
    GalleryTheme* createGalleryTheme(Gallery* pGallery);
61
62
    std::unique_ptr<GalleryFileStorage> createGalleryStorageEngine(GalleryObjectCollection& mrGalleryObjectCollection);
63
64
0
    const OUString&         GetThemeName() const { return maName; }
65
66
0
    bool                    IsReadOnly() const { return mbReadOnly; }
67
    bool                    IsDefault() const;
68
69
0
    bool                    IsHidden() const { return maName.match("private://gallery/hidden/"); }
70
71
0
    bool                    IsModified() const { return mbModified; }
72
0
    void                    SetModified( bool bSet ) { mbModified = ( bSet && !IsReadOnly() ); }
73
74
    void                    SetName( const OUString& rNewName );
75
0
    bool                    IsNameFromResource() const { return mbThemeNameFromResource; }
76
77
0
    sal_uInt32              GetId() const { return mnId; }
78
    void                    SetId( sal_uInt32 nNewId, bool bResetThemeName );
79
80
81
    void removeTheme();
82
83
    std::unique_ptr<GalleryTheme> getCachedTheme(Gallery* pGallery);
84
85
    void setStorageLocations(INetURLObject& rURL);
86
};
87
88
class SfxListener;
89
class GalleryThemeCacheEntry;
90
91
92
class SVXCORE_DLLPUBLIC Gallery final : public SfxBroadcaster
93
{
94
    typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
95
96
private:
97
98
    std::vector< std::unique_ptr<GalleryThemeEntry> > m_aThemeList;
99
    GalleryCacheThemeList       m_aThemeCache;
100
    INetURLObject               m_aRelURL;
101
    INetURLObject               m_aUserURL;
102
    bool                        m_bMultiPath;
103
104
    SAL_DLLPRIVATE void         ImplLoad( std::u16string_view rMultiPath );
105
    SAL_DLLPRIVATE void         ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbIsReadOnly );
106
107
    GalleryThemeEntry*          ImplGetThemeEntry( std::u16string_view rThemeName );
108
109
    SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( GalleryThemeEntry* pThemeEntry );
110
    SAL_DLLPRIVATE void         ImplDeleteCachedTheme( GalleryTheme const * pTheme );
111
112
    Gallery&                    operator=( Gallery const & ) = delete; // MSVC2015 workaround
113
                                Gallery( Gallery const & ) = delete; // MSVC2015 workaround
114
115
public:
116
                                // only for gengal utility!
117
                                Gallery( std::u16string_view rMultiPath );
118
                                virtual ~Gallery() override;
119
120
    static Gallery*             GetGalleryInstance();
121
122
0
    size_t                      GetThemeCount() const { return m_aThemeList.size(); }
123
    SAL_DLLPRIVATE const GalleryThemeEntry* GetThemeInfo( size_t nPos )
124
0
                                { return nPos < m_aThemeList.size() ? m_aThemeList[ nPos ].get() : nullptr; }
125
0
    const GalleryThemeEntry* GetThemeInfo( std::u16string_view rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
126
127
    bool                        HasTheme( std::u16string_view rThemeName );
128
    SAL_DLLPRIVATE OUString     GetThemeName( sal_uInt32 nThemeId ) const;
129
130
    bool                        CreateTheme( const OUString& rThemeName );
131
    void                        RenameTheme( const OUString& rOldName, const OUString& rNewName );
132
    bool                        RemoveTheme( const OUString& rThemeName );
133
134
    SAL_RET_MAYBENULL GalleryTheme* AcquireTheme( std::u16string_view rThemeName, SfxListener& rListener );
135
    void                        ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
136
137
public:
138
139
0
    SAL_DLLPRIVATE const INetURLObject& GetUserURL() const { return m_aUserURL; }
140
0
    SAL_DLLPRIVATE const INetURLObject& GetRelativeURL() const { return m_aRelURL; }
141
};
142
143
#endif // INCLUDED_SVX_GALLERY1_HXX
144
145
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */