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>
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 
34 {
35 private:
36 
37  OUString aName;
42  sal_uInt32 nId;
43  bool const bReadOnly;
44  bool bModified;
46 
47  static INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL );
48 
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 );
55 
56  const OUString& GetThemeName() const { return aName; }
57 
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; }
62 
63  OUString ReadStrFromIni(const OUString &aKeyName );
64 
65  bool IsReadOnly() const { return bReadOnly; }
66  bool IsDefault() const;
67 
68  bool IsHidden() const { return aName.match("private://gallery/hidden/"); }
69 
70  bool IsModified() const { return bModified; }
71  void SetModified( bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
72 
73  void SetName( const OUString& rNewName );
74  bool IsNameFromResource() const { return bThemeNameFromResource; }
75 
76  sal_uInt32 GetId() const { return nId; }
77  void SetId( sal_uInt32 nNewId, bool bResetThemeName );
78 };
79 
80 class SfxListener;
81 class GalleryTheme;
83 
84 
86 {
87  typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
88 
89 private:
90 
91  std::vector< std::unique_ptr<GalleryThemeEntry> > aThemeList;
92  GalleryCacheThemeList aThemeCache;
95  bool bMultiPath;
96 
97  SAL_DLLPRIVATE void ImplLoad( const OUString& rMultiPath );
98  SAL_DLLPRIVATE void ImplLoadSubDirs( const INetURLObject& rBaseURL, bool& rbIsReadOnly );
99 
100  GalleryThemeEntry* ImplGetThemeEntry( const OUString& rThemeName );
101 
102  SAL_DLLPRIVATE GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
103  SAL_DLLPRIVATE void ImplDeleteCachedTheme( GalleryTheme const * pTheme );
104 
105  Gallery& operator=( Gallery const & ) = delete; // MSVC2015 workaround
106  Gallery( Gallery const & ) = delete; // MSVC2015 workaround
107 
108 public:
109  // only for gengal utility!
110  Gallery( const OUString& rMultiPath );
111  virtual ~Gallery() override;
112 
113  static Gallery* GetGalleryInstance();
114 
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 ); }
119 
120  bool HasTheme( const OUString& rThemeName );
121  SAL_DLLPRIVATE OUString GetThemeName( sal_uInt32 nThemeId ) const;
122 
123  bool CreateTheme( const OUString& rThemeName );
124  SAL_DLLPRIVATE void RenameTheme( const OUString& rOldName, const OUString& rNewName );
125  bool RemoveTheme( const OUString& rThemeName );
126 
127  GalleryTheme* AcquireTheme( const OUString& rThemeName, SfxListener& rListener );
128  void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
129 
130 public:
131 
132  SAL_DLLPRIVATE const INetURLObject& GetUserURL() const { return aUserURL; }
133  SAL_DLLPRIVATE const INetURLObject& GetRelativeURL() const { return aRelURL; }
134 };
135 
136 #endif // INCLUDED_SVX_GALLERY1_HXX
137 
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const INetURLObject & GetStrURL() const
Definition: gallery1.hxx:61
bool IsModified() const
Definition: gallery1.hxx:70
INetURLObject aStrURL
Definition: gallery1.hxx:41
INetURLObject aSdgURL
Definition: gallery1.hxx:39
SAL_DLLPRIVATE const GalleryThemeEntry * GetThemeInfo(const OUString &rThemeName)
Definition: gallery1.hxx:118
INetURLObject aSdvURL
Definition: gallery1.hxx:40
SAL_DLLPRIVATE const INetURLObject & GetRelativeURL() const
Definition: gallery1.hxx:133
bool IsReadOnly() const
Definition: gallery1.hxx:65
const SfxBroadcaster & operator=(const SfxBroadcaster &)=delete
INetURLObject aUserURL
Definition: gallery1.hxx:94
std::vector< GalleryThemeCacheEntry * > GalleryCacheThemeList
Definition: gallery1.hxx:87
sal_uInt32 nId
Definition: gallery1.hxx:42
bool bThemeNameFromResource
Definition: gallery1.hxx:45
bool IsHidden() const
Definition: gallery1.hxx:68
sal_uInt32 GetId() const
Definition: gallery1.hxx:76
SAL_DLLPRIVATE const INetURLObject & GetUserURL() const
Definition: gallery1.hxx:132
void SetModified(bool bSet)
Definition: gallery1.hxx:71
INetURLObject aThmURL
Definition: gallery1.hxx:38
bool IsNameFromResource() const
Definition: gallery1.hxx:74
bool IsDefault() const
Definition: gallery1.cxx:761
SAL_DLLPRIVATE size_t GetThemeCount() const
Definition: gallery1.hxx:115
void SetName(const OUString &rNewName)
Definition: gallery1.cxx:216
INetURLObject aRelURL
Definition: gallery1.hxx:93
bool bMultiPath
Definition: gallery1.hxx:95
SAL_DLLPRIVATE const GalleryThemeEntry * GetThemeInfo(size_t nPos)
Definition: gallery1.hxx:116
void SetId(sal_uInt32 nNewId, bool bResetThemeName)
Definition: gallery1.cxx:226
#define SVXCORE_DLLPUBLIC
Definition: svxdllapi.h:35
bool const bReadOnly
Definition: gallery1.hxx:43
GalleryCacheThemeList aThemeCache
Definition: gallery1.hxx:92
static INetURLObject ImplGetURLIgnoreCase(const INetURLObject &rURL)
Definition: gallery1.cxx:196
GalleryThemeEntry(bool bCreateUniqueURL, const INetURLObject &rBaseURL, const OUString &rName, bool bReadOnly, bool bNewFile, sal_uInt32 nId, bool bThemeNameFromResource)
Definition: gallery1.cxx:115
OUString aName
Definition: gallery1.hxx:37
OUString ReadStrFromIni(const OUString &aKeyName)
Definition: galini.cxx:26
const INetURLObject & GetSdvURL() const
Definition: gallery1.hxx:60
const OUString & GetThemeName() const
Definition: gallery1.hxx:56
const INetURLObject & GetSdgURL() const
Definition: gallery1.hxx:59
std::vector< std::unique_ptr< GalleryThemeEntry > > aThemeList
Definition: gallery1.hxx:91
const INetURLObject & GetThmURL() const
Definition: gallery1.hxx:58