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 : rtl::OUString aName;
42 : INetURLObject aThmURL;
43 : INetURLObject aSdgURL;
44 : INetURLObject aSdvURL;
45 : sal_uInt32 nFileNumber;
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_uInt32 nFileNumber, sal_Bool bReadOnly,
58 : sal_Bool bNewFile, sal_uInt32 nId, sal_Bool bThemeNameFromResource );
59 : ~GalleryThemeEntry() {};
60 :
61 0 : const rtl::OUString& GetThemeName() const { return aName; }
62 : sal_uInt32 GetFileNumber() const { return nFileNumber; }
63 :
64 : const INetURLObject& GetThmURL() const { return aThmURL; }
65 : const INetURLObject& GetSdgURL() const { return aSdgURL; }
66 : const INetURLObject& GetSdvURL() const { return aSdvURL; }
67 :
68 : sal_Bool IsReadOnly() const { return bReadOnly; }
69 : sal_Bool IsDefault() const;
70 :
71 : sal_Bool IsHidden() const { return aName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("private://gallery/hidden/")); }
72 :
73 : sal_Bool IsModified() const { return bModified; }
74 : void SetModified( sal_Bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
75 :
76 : void SetName( const rtl::OUString& rNewName );
77 : sal_Bool IsNameFromResource() const { return bThemeNameFromResource; }
78 :
79 0 : sal_uInt32 GetId() const { return nId; }
80 : void SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName );
81 : };
82 :
83 : typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList;
84 :
85 : // ---------------------------
86 : // - GalleryImportThemeEntry -
87 : // ---------------------------
88 :
89 : struct GalleryImportThemeEntry
90 : {
91 : rtl::OUString aThemeName;
92 : rtl::OUString aUIName;
93 : INetURLObject aURL;
94 : };
95 :
96 : typedef ::std::vector< GalleryImportThemeEntry* > GalleryImportThemeList;
97 :
98 : // -----------------------------------------------------------------------------
99 :
100 : SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry );
101 : SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry );
102 :
103 : // -----------
104 : // - Gallery -
105 : // -----------
106 :
107 : class SfxListener;
108 : class GalleryTheme;
109 : class GalleryThemeCacheEntry;
110 :
111 : class Gallery : public SfxBroadcaster
112 : {
113 : // only for gengal utility!
114 : friend Gallery* createGallery( const rtl::OUString& );
115 : friend void disposeGallery( Gallery* );
116 :
117 : typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
118 :
119 : private:
120 :
121 : GalleryThemeList aThemeList;
122 : GalleryImportThemeList aImportList;
123 : GalleryCacheThemeList aThemeCache;
124 : INetURLObject aRelURL;
125 : INetURLObject aUserURL;
126 : rtl_TextEncoding nReadTextEncoding;
127 : sal_uIntPtr nLastFileNumber;
128 : sal_Bool bMultiPath;
129 :
130 : void ImplLoad( const rtl::OUString& rMultiPath );
131 : void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly );
132 :
133 : SVX_DLLPUBLIC GalleryThemeEntry* ImplGetThemeEntry( const rtl::OUString& rThemeName );
134 : GalleryThemeEntry* ImplGetThemeEntry( sal_uIntPtr nThemeId );
135 :
136 : GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
137 : void ImplDeleteCachedTheme( GalleryTheme* pTheme );
138 :
139 : SVX_DLLPUBLIC Gallery( const rtl::OUString& rMultiPath );
140 : SVX_DLLPUBLIC ~Gallery();
141 :
142 : public:
143 :
144 : SVX_DLLPUBLIC static Gallery* GetGalleryInstance();
145 :
146 0 : size_t GetThemeCount() const { return aThemeList.size(); }
147 0 : const GalleryThemeEntry* GetThemeInfo( size_t nPos )
148 0 : { return nPos < aThemeList.size() ? aThemeList[ nPos ] : NULL; }
149 : const GalleryThemeEntry* GetThemeInfo( const String& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
150 :
151 : SVX_DLLPUBLIC sal_Bool HasTheme( const String& rThemeName );
152 : rtl::OUString GetThemeName( sal_uIntPtr nThemeId ) const;
153 :
154 : SVX_DLLPUBLIC sal_Bool CreateTheme( const String& rThemeName, sal_uInt32 nNumFrom = 0 );
155 : sal_Bool RenameTheme( const String& rOldName, const String& rNewName );
156 : SVX_DLLPUBLIC sal_Bool RemoveTheme( const String& rThemeName );
157 :
158 : SVX_DLLPUBLIC GalleryTheme* AcquireTheme( const String& rThemeName, SfxListener& rListener );
159 : SVX_DLLPUBLIC void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
160 :
161 : public:
162 :
163 : const INetURLObject& GetUserURL() const { return aUserURL; }
164 : const INetURLObject& GetRelativeURL() const { return aRelURL; }
165 :
166 : sal_Bool IsMultiPath() const { return bMultiPath; }
167 : };
168 :
169 : #endif // _SVX_GALLERY1_HXX_
170 :
171 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|