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