Update ooo320-m1
[ooovba.git] / svtools / source / misc / inidef.cxx
blob88cdb3ccde3e0ec7003c1bd6223def5781f2b844
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: inidef.cxx,v $
10 * $Revision: 1.6 $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svtools.hxx"
35 #include <tools/string.hxx>
36 #include "inetdef.hxx"
37 #include "inidef.hxx"
39 //========================================================================
41 class SfxStdIniDef_Impl: public SfxIniDefaulter
43 public:
44 SfxStdIniDef_Impl( SfxIniDefaultManager *pDefMgr )
45 : SfxIniDefaulter( pDefMgr )
47 virtual BOOL QueryDefault( String &rValue, const SfxIniEntry &rEntry );
50 //-------------------------------------------------------------------------
52 BOOL SfxStdIniDef_Impl::QueryDefault( String &rValue, const SfxIniEntry &rEntry )
54 switch ( rEntry.GetKey() )
56 case SFX_KEY_BROWSERRESTORE:
58 rValue = "1";
59 return TRUE;
62 case SFX_KEY_INET_HOME:
64 if ( System::GetLanguage() == LANGUAGE_GERMAN )
65 rValue = "http://www.stardivision.de";
66 else
67 rValue = "http://www.stardivision.com";
68 return TRUE;
71 case SFX_KEY_INET_MEMCACHE:
72 rValue = "4";
73 return TRUE;
75 case SFX_KEY_INET_DISKCACHE:
76 rValue = "2048";
77 return TRUE;
79 case SFX_KEY_INET_CACHEEXPIRATION:
80 rValue = "3";
81 return TRUE;
83 case SFX_KEY_INET_MAXHTTPCONS:
84 rValue = "4";
85 return TRUE;
87 case SFX_KEY_INET_MAXFTPCONS:
88 rValue = "2";
89 return TRUE;
91 // case SFX_KEY_INET_JAVAMINHEAP:
92 // rValue = "256";
93 // return TRUE;
95 // case SFX_KEY_INET_JAVAMAXHEAP:
96 // rValue = "";
97 // return TRUE;
99 case SFX_KEY_INET_USERAGENT:
100 rValue = INET_DEF_CALLERNAME;
101 return TRUE;
103 case SFX_KEY_INET_EXE_JAVASCRIPT:
104 #ifdef SOLAR_JAVA
105 rValue = "0"; // noch "0", solange es noch soviel Bugs gibt
106 #else
107 rValue = "0"; // immer "0"
108 #endif
109 return TRUE;
111 case SFX_KEY_INET_EXE_PLUGIN:
112 rValue = "1";
113 return TRUE;
115 /* case SFX_KEY_INET_JAVA_ENABLE:
116 #ifdef SOLAR_JAVA
117 rValue = "1";
118 #else
119 rValue = "0";
120 #endif
121 return TRUE; */
123 // case SFX_KEY_INET_NETACCESS:
124 // rValue = "2";
125 // return TRUE;
127 case SFX_KEY_INET_CHANNELS:
128 rValue = "1";
129 return TRUE;
131 case SFX_KEY_BASIC_ENABLE:
132 rValue = "1";
133 return TRUE;
135 case SFX_KEY_INET_COOKIES:
136 rValue = "1";
137 return TRUE;
139 case SFX_KEY_ICONGRID:
140 rValue = "100;70;0";
141 return TRUE;
143 case SFX_KEY_METAFILEPRINT:
144 rValue = "1";
145 return TRUE;
148 return SfxIniDefaulter::QueryDefault( rValue, rEntry );
151 //=========================================================================
153 SfxIniDefaultManager::SfxIniDefaultManager()
154 : _pList( new SfxIniDefaulterList )
156 new SfxStdIniDef_Impl( this );
159 //-------------------------------------------------------------------------
161 SfxIniDefaultManager::~SfxIniDefaultManager()
163 if ( _pList )
165 for ( USHORT n = _pList->Count(); n--; )
166 delete _pList->GetObject(n);
167 delete _pList;
171 //-------------------------------------------------------------------------
173 BOOL SfxIniDefaultManager::QueryDefault
175 String& rValue, /* out: Default-Wert f"ur 'rEntry'
176 (Default ist Leerstring) */
177 const SfxIniEntry& rEntry // in: Beschreibung des Eintrags
180 /* [Beschreibung]
182 "Uber diese interne Methode besorgt sich der <SfxIniManager> den
183 Default f"ur einen in 'rEntry' beschriebenen Eintrag.
187 for ( USHORT n = _pList->Count(); n--; )
188 if ( _pList->GetObject(n)->QueryDefault( rValue, rEntry ) )
189 return TRUE;
190 return FALSE;
193 //=========================================================================
195 SfxIniDefaulter::SfxIniDefaulter( SfxIniDefaultManager *pManager )
197 /* [Beschreibung]
199 Der Ctor dieser Klasse meldet die neue Instanz automatisch am
200 <SfxiniDefaultManager> 'pManager' an.
203 : _pManager( pManager )
206 pManager->Insert( this );
209 //-------------------------------------------------------------------------
211 SfxIniDefaulter::~SfxIniDefaulter()
213 /* [Beschreibung]
215 Der Dtor dieser Klasse meldet die neue Instanz automatisch am
216 <SfxiniDefaultManager> ab, der im Ctor angegeben wurde.
220 _pManager->Remove( this );
223 //-------------------------------------------------------------------------
225 BOOL SfxIniDefaulter::QueryDefault
227 String& rValue, /* out: Default-Wert f"ur 'rEntry'
228 (Default ist Leerstring) */
229 const SfxIniEntry& rEntry // in: Beschreibung des Eintrags
232 /* [Beschreibung]
234 Diese virtuelle Methode mu\s "uberladen werden. Sie soll dann in
235 'rValue' einen Default-Wert f"ur den in 'rEntry' beschriebenen
236 ini-Eintrag setzen, falls ihr dieser bekannt ist.
239 [Returnwert]
241 TRUE In 'rValue' befindet sich der Default-Wert.
243 FALSE F"ur diesen Eintrag ist kein Default-Wert bekannt.
248 return FALSE;
251 //========================================================================
253 SfxIniEntry::SfxIniEntry
255 const String& aGroup,
256 const String& aKey,
257 SfxIniGroup eGroup,
258 SfxIniKey eKey,
259 USHORT nIndex
261 : _aGroup( aGroup ),
262 _aKey( aKey ),
263 _eGroup( eGroup ),
264 _eKey( eKey ),
265 _nIndex( nIndex )