Line data Source code
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 _SVX_GALLERY1_HXX_
21 : #define _SVX_GALLERY1_HXX_
22 :
23 : #include <tools/string.hxx>
24 : #include <tools/urlobj.hxx>
25 : #include <svl/brdcst.hxx>
26 : #include "svx/svxdllapi.h"
27 :
28 : #include <cstdio>
29 : #include <vector>
30 :
31 : // ---------------------
32 : // - GalleryThemeEntry -
33 : // ---------------------
34 :
35 : class SvStream;
36 :
37 : class GalleryThemeEntry
38 : {
39 : private:
40 :
41 : OUString aName;
42 : INetURLObject aThmURL;
43 : INetURLObject aSdgURL;
44 : INetURLObject aSdvURL;
45 : INetURLObject aStrURL;
46 : sal_uInt32 nId;
47 : sal_Bool bReadOnly;
48 : sal_Bool bModified;
49 : sal_Bool bThemeNameFromResource;
50 :
51 : GalleryThemeEntry();
52 : INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL ) const;
53 :
54 : public:
55 :
56 : GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
57 : sal_Bool bReadOnly, sal_Bool bNewFile,
58 : sal_uInt32 nId, sal_Bool bThemeNameFromResource );
59 11 : ~GalleryThemeEntry() {};
60 :
61 1542 : const OUString& GetThemeName() const { return aName; }
62 :
63 55 : const INetURLObject& GetThmURL() const { return aThmURL; }
64 503 : const INetURLObject& GetSdgURL() const { return aSdgURL; }
65 22 : const INetURLObject& GetSdvURL() const { return aSdvURL; }
66 11 : const INetURLObject& GetStrURL() const { return aStrURL; }
67 :
68 : OUString ReadStrFromIni(const OUString &aKeyName );
69 :
70 547 : sal_Bool IsReadOnly() const { return bReadOnly; }
71 : sal_Bool IsDefault() const;
72 :
73 0 : sal_Bool IsHidden() const { return aName.match("private://gallery/hidden/"); }
74 :
75 22 : sal_Bool IsModified() const { return bModified; }
76 558 : void SetModified( sal_Bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
77 :
78 : void SetName( const OUString& rNewName );
79 22 : sal_Bool IsNameFromResource() const { return bThemeNameFromResource; }
80 :
81 22 : sal_uInt32 GetId() const { return nId; }
82 : void SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName );
83 : };
84 :
85 : typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList;
86 :
87 : // -----------
88 : // - Gallery -
89 : // -----------
90 :
91 : class SfxListener;
92 : class GalleryTheme;
93 : class GalleryThemeCacheEntry;
94 :
95 : class Gallery : public SfxBroadcaster
96 : {
97 : // only for gengal utility!
98 : friend Gallery* createGallery( const OUString& );
99 : friend void disposeGallery( Gallery* );
100 :
101 : typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
102 :
103 : private:
104 :
105 : GalleryThemeList aThemeList;
106 : GalleryCacheThemeList aThemeCache;
107 : INetURLObject aRelURL;
108 : INetURLObject aUserURL;
109 : rtl_TextEncoding nReadTextEncoding;
110 : sal_Bool bMultiPath;
111 :
112 : void ImplLoad( const OUString& rMultiPath );
113 : void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly );
114 :
115 : SVX_DLLPUBLIC GalleryThemeEntry* ImplGetThemeEntry( const OUString& rThemeName );
116 : GalleryThemeEntry* ImplGetThemeEntry( sal_uIntPtr nThemeId );
117 :
118 : GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
119 : void ImplDeleteCachedTheme( GalleryTheme* pTheme );
120 :
121 : SVX_DLLPUBLIC Gallery( const OUString& rMultiPath );
122 : SVX_DLLPUBLIC ~Gallery();
123 :
124 : public:
125 :
126 : SVX_DLLPUBLIC static Gallery* GetGalleryInstance();
127 :
128 22 : size_t GetThemeCount() const { return aThemeList.size(); }
129 0 : const GalleryThemeEntry* GetThemeInfo( size_t nPos )
130 0 : { return nPos < aThemeList.size() ? aThemeList[ nPos ] : NULL; }
131 0 : const GalleryThemeEntry* GetThemeInfo( const String& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
132 :
133 : SVX_DLLPUBLIC sal_Bool HasTheme( const String& rThemeName );
134 : OUString GetThemeName( sal_uIntPtr nThemeId ) const;
135 :
136 : SVX_DLLPUBLIC sal_Bool CreateTheme( const String& rThemeName );
137 : sal_Bool RenameTheme( const String& rOldName, const String& rNewName );
138 : SVX_DLLPUBLIC sal_Bool RemoveTheme( const String& rThemeName );
139 :
140 : SVX_DLLPUBLIC GalleryTheme* AcquireTheme( const String& rThemeName, SfxListener& rListener );
141 : SVX_DLLPUBLIC void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
142 :
143 : public:
144 :
145 55 : const INetURLObject& GetUserURL() const { return aUserURL; }
146 33 : const INetURLObject& GetRelativeURL() const { return aRelURL; }
147 :
148 : sal_Bool IsMultiPath() const { return bMultiPath; }
149 : };
150 :
151 : #endif // _SVX_GALLERY1_HXX_
152 :
153 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|