Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _SVX_GALLERY1_HXX_
30 : : #define _SVX_GALLERY1_HXX_
31 : :
32 : : #include <tools/string.hxx>
33 : : #include <tools/urlobj.hxx>
34 : : #include <svl/brdcst.hxx>
35 : : #include "svx/svxdllapi.h"
36 : :
37 : : #include <cstdio>
38 : : #include <vector>
39 : :
40 : : // ---------------------
41 : : // - GalleryThemeEntry -
42 : : // ---------------------
43 : :
44 : : class SvStream;
45 : :
46 : : class GalleryThemeEntry
47 : : {
48 : : private:
49 : :
50 : : rtl::OUString aName;
51 : : INetURLObject aThmURL;
52 : : INetURLObject aSdgURL;
53 : : INetURLObject aSdvURL;
54 : : sal_uInt32 nFileNumber;
55 : : sal_uInt32 nId;
56 : : sal_Bool bReadOnly;
57 : : sal_Bool bModified;
58 : : sal_Bool bThemeNameFromResource;
59 : :
60 : : GalleryThemeEntry();
61 : : INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL ) const;
62 : :
63 : : public:
64 : :
65 : : GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
66 : : sal_uInt32 nFileNumber, sal_Bool bReadOnly,
67 : : sal_Bool bNewFile, sal_uInt32 nId, sal_Bool bThemeNameFromResource );
68 : : ~GalleryThemeEntry() {};
69 : :
70 : 0 : const rtl::OUString& GetThemeName() const { return aName; }
71 : : sal_uInt32 GetFileNumber() const { return nFileNumber; }
72 : :
73 : : const INetURLObject& GetThmURL() const { return aThmURL; }
74 : : const INetURLObject& GetSdgURL() const { return aSdgURL; }
75 : : const INetURLObject& GetSdvURL() const { return aSdvURL; }
76 : :
77 : : sal_Bool IsReadOnly() const { return bReadOnly; }
78 : : sal_Bool IsDefault() const;
79 : :
80 : : sal_Bool IsHidden() const { return aName.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("private://gallery/hidden/")); }
81 : :
82 : : sal_Bool IsModified() const { return bModified; }
83 : : void SetModified( sal_Bool bSet ) { bModified = ( bSet && !IsReadOnly() ); }
84 : :
85 : : void SetName( const rtl::OUString& rNewName );
86 : : sal_Bool IsNameFromResource() const { return bThemeNameFromResource; }
87 : :
88 : 0 : sal_uInt32 GetId() const { return nId; }
89 : : void SetId( sal_uInt32 nNewId, sal_Bool bResetThemeName );
90 : : };
91 : :
92 : : typedef ::std::vector< GalleryThemeEntry* > GalleryThemeList;
93 : :
94 : : // ---------------------------
95 : : // - GalleryImportThemeEntry -
96 : : // ---------------------------
97 : :
98 : : struct GalleryImportThemeEntry
99 : : {
100 : : rtl::OUString aThemeName;
101 : : rtl::OUString aUIName;
102 : : INetURLObject aURL;
103 : : };
104 : :
105 : : typedef ::std::vector< GalleryImportThemeEntry* > GalleryImportThemeList;
106 : :
107 : : // -----------------------------------------------------------------------------
108 : :
109 : : SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry );
110 : : SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry );
111 : :
112 : : // -----------
113 : : // - Gallery -
114 : : // -----------
115 : :
116 : : class SfxListener;
117 : : class GalleryTheme;
118 : : class GalleryThemeCacheEntry;
119 : :
120 : : class Gallery : public SfxBroadcaster
121 : : {
122 : : // only for gengal utility!
123 : : friend Gallery* createGallery( const rtl::OUString& );
124 : : friend void disposeGallery( Gallery* );
125 : :
126 : : typedef std::vector<GalleryThemeCacheEntry*> GalleryCacheThemeList;
127 : :
128 : : private:
129 : :
130 : : GalleryThemeList aThemeList;
131 : : GalleryImportThemeList aImportList;
132 : : GalleryCacheThemeList aThemeCache;
133 : : INetURLObject aRelURL;
134 : : INetURLObject aUserURL;
135 : : rtl_TextEncoding nReadTextEncoding;
136 : : sal_uIntPtr nLastFileNumber;
137 : : sal_Bool bMultiPath;
138 : :
139 : : void ImplLoad( const rtl::OUString& rMultiPath );
140 : : void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly );
141 : :
142 : : SVX_DLLPUBLIC GalleryThemeEntry* ImplGetThemeEntry( const rtl::OUString& rThemeName );
143 : : GalleryThemeEntry* ImplGetThemeEntry( sal_uIntPtr nThemeId );
144 : :
145 : : GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
146 : : void ImplDeleteCachedTheme( GalleryTheme* pTheme );
147 : :
148 : : SVX_DLLPUBLIC Gallery( const rtl::OUString& rMultiPath );
149 : : SVX_DLLPUBLIC ~Gallery();
150 : :
151 : : public:
152 : :
153 : : SVX_DLLPUBLIC static Gallery* GetGalleryInstance();
154 : :
155 : 0 : size_t GetThemeCount() const { return aThemeList.size(); }
156 : 0 : const GalleryThemeEntry* GetThemeInfo( size_t nPos )
157 [ # # ]: 0 : { return nPos < aThemeList.size() ? aThemeList[ nPos ] : NULL; }
158 : : const GalleryThemeEntry* GetThemeInfo( const String& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
159 : :
160 : : SVX_DLLPUBLIC sal_Bool HasTheme( const String& rThemeName );
161 : : rtl::OUString GetThemeName( sal_uIntPtr nThemeId ) const;
162 : :
163 : : SVX_DLLPUBLIC sal_Bool CreateTheme( const String& rThemeName, sal_uInt32 nNumFrom = 0 );
164 : : sal_Bool RenameTheme( const String& rOldName, const String& rNewName );
165 : : SVX_DLLPUBLIC sal_Bool RemoveTheme( const String& rThemeName );
166 : :
167 : : SVX_DLLPUBLIC GalleryTheme* AcquireTheme( const String& rThemeName, SfxListener& rListener );
168 : : SVX_DLLPUBLIC void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
169 : :
170 : : public:
171 : :
172 : : const INetURLObject& GetUserURL() const { return aUserURL; }
173 : : const INetURLObject& GetRelativeURL() const { return aRelURL; }
174 : :
175 : : sal_Bool IsMultiPath() const { return bMultiPath; }
176 : : };
177 : :
178 : : #endif // _SVX_GALLERY1_HXX_
179 : :
180 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|