Update ooo320-m1
[ooovba.git] / svx / inc / gallery1.hxx
blob6c508c2311b6fcec574254c480d7de9c1d9bb765
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: gallery1.hxx,v $
10 * $Revision: 1.8.216.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVX_GALLERY1_HXX_
32 #define _SVX_GALLERY1_HXX_
34 #include <tools/string.hxx>
35 #include <tools/list.hxx>
36 #include <tools/urlobj.hxx>
37 #include <svtools/brdcst.hxx>
38 #include "svx/svxdllapi.h"
39 #include "gallery.hrc"
41 #include <cstdio>
42 #include <list>
44 // ---------------------
45 // - GalleryThemeEntry -
46 // ---------------------
48 class SvStream;
50 class GalleryThemeEntry
52 private:
54 String aName;
55 INetURLObject aThmURL;
56 INetURLObject aSdgURL;
57 INetURLObject aSdvURL;
58 UINT32 nFileNumber;
59 UINT32 nId;
60 BOOL bReadOnly;
61 BOOL bImported;
62 BOOL bModified;
63 BOOL bThemeNameFromResource;
65 GalleryThemeEntry();
66 INetURLObject ImplGetURLIgnoreCase( const INetURLObject& rURL ) const;
68 public:
70 GalleryThemeEntry( const INetURLObject& rBaseURL, const String& rName,
71 UINT32 nFileNumber, BOOL bReadOnly, BOOL bImported,
72 BOOL bNewFile, UINT32 nId, BOOL bThemeNameFromResource );
73 ~GalleryThemeEntry() {};
75 const String& GetThemeName() const { return aName; }
76 UINT32 GetFileNumber() const { return nFileNumber; }
78 const INetURLObject& GetThmURL() const { return aThmURL; }
79 const INetURLObject& GetSdgURL() const { return aSdgURL; }
80 const INetURLObject& GetSdvURL() const { return aSdvURL; }
82 BOOL IsImported() const { return bImported; }
83 BOOL IsReadOnly() const { return bReadOnly; }
84 BOOL IsDefault() const { return( ( nId > 0 ) && ( nId != ( RID_GALLERYSTR_THEME_MYTHEME - RID_GALLERYSTR_THEME_START ) ) ); }
86 BOOL IsHidden() const { return aName.SearchAscii( "private://gallery/hidden/" ) == 0; }
88 BOOL IsModified() const { return bModified; }
89 void SetModified( BOOL bSet ) { bModified = ( bSet && !IsImported() && !IsReadOnly() ); }
91 void SetName( const String& rNewName );
92 BOOL IsNameFromResource() const { return bThemeNameFromResource; }
94 UINT32 GetId() const { return nId; }
95 void SetId( UINT32 nNewId, BOOL bResetThemeName );
98 DECLARE_LIST( GalleryThemeList, GalleryThemeEntry* )
100 // ---------------------------
101 // - GalleryImportThemeEntry -
102 // ---------------------------
104 struct GalleryImportThemeEntry
106 String aThemeName;
107 String aUIName;
108 INetURLObject aURL;
109 String aImportName;
111 DECLARE_LIST( GalleryImportThemeList, GalleryImportThemeEntry* )
113 // -----------------------------------------------------------------------------
115 SvStream& operator<<( SvStream& rOut, const GalleryImportThemeEntry& rEntry );
116 SvStream& operator>>( SvStream& rIn, GalleryImportThemeEntry& rEntry );
118 // -----------
119 // - Gallery -
120 // -----------
122 class SfxListener;
123 class GalleryTheme;
125 class Gallery : public SfxBroadcaster
127 // only for gengal utility!
128 friend Gallery* createGallery( const rtl::OUString& );
129 friend void disposeGallery( Gallery* );
131 private:
133 GalleryThemeList aThemeList;
134 GalleryImportThemeList aImportList;
135 List aThemeCache;
136 INetURLObject aRelURL;
137 INetURLObject aUserURL;
138 rtl_TextEncoding nReadTextEncoding;
139 ULONG nLastFileNumber;
140 BOOL bMultiPath;
142 void ImplLoad( const String& rMultiPath );
143 void ImplLoadSubDirs( const INetURLObject& rBaseURL, sal_Bool& rbIsReadOnly );
144 void ImplLoadImports();
145 void ImplWriteImportList();
147 SVX_DLLPUBLIC GalleryThemeEntry* ImplGetThemeEntry( const String& rThemeName );
148 GalleryThemeEntry* ImplGetThemeEntry( ULONG nThemeId );
149 GalleryImportThemeEntry* ImplGetImportThemeEntry( const String& rImportName );
151 GalleryTheme* ImplGetCachedTheme( const GalleryThemeEntry* pThemeEntry );
152 void ImplDeleteCachedTheme( GalleryTheme* pTheme );
154 SVX_DLLPUBLIC Gallery( const String& rMultiPath );
155 SVX_DLLPUBLIC ~Gallery();
157 public:
159 SVX_DLLPUBLIC static Gallery* GetGalleryInstance();
161 ULONG GetThemeCount() const { return aThemeList.Count(); }
162 const GalleryThemeEntry* GetThemeInfo( ULONG nPos ) { return aThemeList.GetObject( nPos ); }
163 const GalleryThemeEntry* GetThemeInfo( const String& rThemeName ) { return ImplGetThemeEntry( rThemeName ); }
165 SVX_DLLPUBLIC BOOL HasTheme( const String& rThemeName );
166 String GetThemeName( ULONG nThemeId ) const;
168 SVX_DLLPUBLIC BOOL CreateTheme( const String& rThemeName, UINT32 nNumFrom = 0 );
169 BOOL CreateImportTheme( const INetURLObject& rURL, const String& rFileName );
170 BOOL RenameTheme( const String& rOldName, const String& rNewName );
171 SVX_DLLPUBLIC BOOL RemoveTheme( const String& rThemeName );
173 SVX_DLLPUBLIC GalleryTheme* AcquireTheme( const String& rThemeName, SfxListener& rListener );
174 SVX_DLLPUBLIC void ReleaseTheme( GalleryTheme* pTheme, SfxListener& rListener );
176 public:
178 INetURLObject GetImportURL( const String& rThemeName );
180 const INetURLObject& GetUserURL() const { return aUserURL; }
181 const INetURLObject& GetRelativeURL() const { return aRelURL; }
183 BOOL IsMultiPath() const { return bMultiPath; }
186 #endif // _SVX_GALLERY1_HXX_