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 : : #include "sal/config.h"
30 : :
31 : : #include <algorithm>
32 : :
33 : : #include <officecfg/Office/Common.hxx>
34 : : #include <svtools/langtab.hxx>
35 : : #include <svl/zforlist.hxx>
36 : : #include <svtools/grfmgr.hxx>
37 : : #include <svl/flagitem.hxx>
38 : : #include <sfx2/dispatch.hxx>
39 : : #include <unotools/lingucfg.hxx>
40 : : #include <svl/szitem.hxx>
41 : : #include <sfx2/viewsh.hxx>
42 : : #include <sfx2/viewfrm.hxx>
43 : : #include <vcl/msgbox.hxx>
44 : : #include <rtl/math.hxx>
45 : : #include <unotools/useroptions.hxx>
46 : : #include <unotools/fontoptions.hxx>
47 : : #include <svtools/menuoptions.hxx>
48 : : #include <unotools/startoptions.hxx>
49 : : #include <svl/cjkoptions.hxx>
50 : : #include <svtools/miscopt.hxx>
51 : : #include <unotools/syslocaleoptions.hxx>
52 : : #include <svtools/helpopt.hxx>
53 : : #include <unotools/configitem.hxx>
54 : : #include <sfx2/objsh.hxx>
55 : : #include <comphelper/types.hxx>
56 : : #include <editeng/unolingu.hxx>
57 : : #include <editeng/langitem.hxx>
58 : : #include "cuioptgenrl.hxx"
59 : : #include "optpath.hxx"
60 : : #include "optsave.hxx"
61 : : #include "optlingu.hxx"
62 : : #include <svx/xpool.hxx>
63 : : #include <svx/dlgutil.hxx>
64 : : #include "cuitabarea.hxx"
65 : : #include "optmemory.hrc"
66 : : #include "optmemory.hxx"
67 : : #include <svx/ofaitem.hxx>
68 : : #include <cuires.hrc>
69 : : #include "helpid.hrc"
70 : : #include <dialmgr.hxx>
71 : :
72 : : using namespace ::com::sun::star::uno;
73 : : using namespace ::com::sun::star::lang;
74 : : using namespace ::com::sun::star::beans;
75 : : using namespace ::utl;
76 : : using namespace ::rtl;
77 : : using namespace ::sfx2;
78 : :
79 : :
80 : : #define NF2BYTES 104857.6 // 2^20/10, used for aNfGraphicObjectCache-unit -> Byte
81 : : #define BYTES2NF (1.0/NF2BYTES) // 10/2^20
82 : :
83 : :
84 : 0 : sal_Int32 OfaMemoryOptionsPage::GetNfGraphicCacheVal() const
85 : : {
86 : 0 : return aNfGraphicCache.GetValue() << 20;
87 : : }
88 : :
89 : 0 : inline void OfaMemoryOptionsPage::SetNfGraphicCacheVal( long nSizeInBytes )
90 : : {
91 : 0 : aNfGraphicCache.SetValue( nSizeInBytes >> 20 );
92 : 0 : }
93 : :
94 : 0 : long OfaMemoryOptionsPage::GetNfGraphicObjectCacheVal( void ) const
95 : : {
96 : 0 : return long( ::rtl::math::round( double( aNfGraphicObjectCache.GetValue() ) * NF2BYTES ) );
97 : : }
98 : :
99 : 0 : void OfaMemoryOptionsPage::SetNfGraphicObjectCacheVal( long nSizeInBytes )
100 : : {
101 : 0 : aNfGraphicObjectCache.SetValue( long( ::rtl::math::round( double( nSizeInBytes ) * BYTES2NF ) ) );
102 : 0 : }
103 : :
104 : 0 : inline void OfaMemoryOptionsPage::SetNfGraphicObjectCacheMax( long nSizeInBytes )
105 : : {
106 : 0 : aNfGraphicObjectCache.SetMax( long( double( nSizeInBytes ) * BYTES2NF ) );
107 : 0 : }
108 : :
109 : 0 : inline void OfaMemoryOptionsPage::SetNfGraphicObjectCacheLast( long nSizeInBytes )
110 : : {
111 : 0 : aNfGraphicObjectCache.SetLast( long( double( nSizeInBytes ) * BYTES2NF ) );
112 : 0 : }
113 : :
114 : 0 : int OfaMemoryOptionsPage::DeactivatePage( SfxItemSet* _pSet )
115 : : {
116 [ # # ]: 0 : if ( _pSet )
117 : 0 : FillItemSet( *_pSet );
118 : 0 : return LEAVE_PAGE;
119 : : }
120 : :
121 : : // -----------------------------------------------------------------------
122 : :
123 : 0 : OfaMemoryOptionsPage::OfaMemoryOptionsPage(Window* pParent, const SfxItemSet& rSet ) :
124 : :
125 : 0 : SfxTabPage( pParent, CUI_RES( OFA_TP_MEMORY ), rSet ),
126 : :
127 [ # # ]: 0 : aUndoBox ( this, CUI_RES( GB_UNDO ) ),
128 [ # # ]: 0 : aUndoText ( this, CUI_RES( FT_UNDO ) ),
129 [ # # ]: 0 : aUndoEdit ( this, CUI_RES( ED_UNDO ) ),
130 [ # # ]: 0 : aGbGraphicCache ( this, CUI_RES( GB_GRAPHICCACHE ) ),
131 [ # # ]: 0 : aFtGraphicCache ( this, CUI_RES( FT_GRAPHICCACHE ) ),
132 [ # # ]: 0 : aNfGraphicCache ( this, CUI_RES( NF_GRAPHICCACHE ) ),
133 [ # # ]: 0 : aFtGraphicCacheUnit ( this, CUI_RES( FT_GRAPHICCACHE_UNIT ) ),
134 [ # # ]: 0 : aFtGraphicObjectCache ( this, CUI_RES( FT_GRAPHICOBJECTCACHE ) ),
135 [ # # ]: 0 : aNfGraphicObjectCache ( this, CUI_RES( NF_GRAPHICOBJECTCACHE ) ),
136 [ # # ]: 0 : aFtGraphicObjectCacheUnit(this, CUI_RES( FT_GRAPHICOBJECTCACHE_UNIT ) ),
137 [ # # ]: 0 : aFtGraphicObjectTime ( this, CUI_RES( FT_GRAPHICOBJECTTIME ) ),
138 [ # # ]: 0 : aTfGraphicObjectTime ( this, CUI_RES( TF_GRAPHICOBJECTTIME ) ),
139 [ # # ]: 0 : aFtGraphicObjectTimeUnit( this, CUI_RES( FT_GRAPHICOBJECTTIME_UNIT ) ),
140 : :
141 [ # # ]: 0 : aGbOLECache ( this, CUI_RES( GB_OLECACHE ) ),
142 [ # # ]: 0 : aFtOLECache ( this, CUI_RES( FT_OLECACHE ) ),
143 [ # # ]: 0 : aNfOLECache ( this, CUI_RES( NF_OLECACHE ) ),
144 [ # # ]: 0 : aQuickLaunchFL ( this, CUI_RES( FL_QUICKLAUNCH ) ),
145 [ # # ][ # # ]: 0 : aQuickLaunchCB ( this, CUI_RES( CB_QUICKLAUNCH ) )//,
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
146 : : {
147 : : #if defined(UNX)
148 [ # # ][ # # ]: 0 : aQuickLaunchCB.SetText( CUI_RES( STR_QUICKLAUNCH_UNX ) );
[ # # ][ # # ]
149 : : #endif
150 [ # # ]: 0 : FreeResource();
151 : :
152 : : //quick launch only available in Win
153 : : #if !defined(WNT) && !defined(ENABLE_GTK)
154 : : aQuickLaunchFL.Hide();
155 : : aQuickLaunchCB.Hide();
156 : : #endif
157 : :
158 [ # # ]: 0 : aTfGraphicObjectTime.SetExtFormat( EXTTIMEF_24H_SHORT );
159 : :
160 : 0 : SetExchangeSupport();
161 : :
162 [ # # ]: 0 : aNfGraphicCache.SetModifyHdl( LINK( this, OfaMemoryOptionsPage, GraphicCacheConfigHdl ) );
163 : 0 : }
164 : :
165 : : // -----------------------------------------------------------------------
166 : :
167 [ # # ][ # # ]: 0 : OfaMemoryOptionsPage::~OfaMemoryOptionsPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
168 : : {
169 [ # # ]: 0 : }
170 : :
171 : : // -----------------------------------------------------------------------
172 : :
173 : 0 : SfxTabPage* OfaMemoryOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
174 : : {
175 [ # # ]: 0 : return new OfaMemoryOptionsPage( pParent, rAttrSet );
176 : : }
177 : :
178 : : // -----------------------------------------------------------------------
179 : :
180 : 0 : sal_Bool OfaMemoryOptionsPage::FillItemSet( SfxItemSet& rSet )
181 : : {
182 : 0 : sal_Bool bModified = sal_False;
183 : :
184 : : boost::shared_ptr< comphelper::ConfigurationChanges > batch(
185 [ # # ][ # # ]: 0 : comphelper::ConfigurationChanges::create());
186 : :
187 [ # # ][ # # ]: 0 : if ( aUndoEdit.GetText() != aUndoEdit.GetSavedValue() )
[ # # ][ # # ]
188 : : officecfg::Office::Common::Undo::Steps::set(
189 [ # # ][ # # ]: 0 : aUndoEdit.GetValue(), batch);
190 : :
191 : : // GraphicCache
192 [ # # ]: 0 : sal_Int32 totalCacheSize = GetNfGraphicCacheVal();
193 : : officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::set(
194 [ # # ]: 0 : totalCacheSize, batch);
195 [ # # ]: 0 : sal_Int32 objectCacheSize = GetNfGraphicObjectCacheVal();
196 : : officecfg::Office::Common::Cache::GraphicManager::ObjectCacheSize::set(
197 [ # # ]: 0 : objectCacheSize, batch);
198 : :
199 [ # # ]: 0 : const Time aTime( aTfGraphicObjectTime.GetTime() );
200 : : sal_Int32 objectReleaseTime =
201 : 0 : aTime.GetSec() + aTime.GetMin() * 60 + aTime.GetHour() * 3600;
202 : : officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::set(
203 [ # # ]: 0 : objectReleaseTime, batch);
204 : :
205 : : // create a dummy graphic object to get access to the common GraphicManager
206 [ # # ]: 0 : GraphicObject aDummyObject;
207 : 0 : GraphicManager& rGrfMgr = aDummyObject.GetGraphicManager();
208 : :
209 [ # # ]: 0 : rGrfMgr.SetMaxCacheSize(totalCacheSize);
210 [ # # ]: 0 : rGrfMgr.SetMaxObjCacheSize(objectCacheSize, true);
211 [ # # ]: 0 : rGrfMgr.SetCacheTimeout(objectReleaseTime);
212 : :
213 : : // OLECache
214 : : officecfg::Office::Common::Cache::Writer::OLE_Objects::set(
215 [ # # ][ # # ]: 0 : aNfOLECache.GetValue(), batch);
216 : : officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::set(
217 [ # # ][ # # ]: 0 : aNfOLECache.GetValue(), batch);
218 : :
219 [ # # ]: 0 : batch->commit();
220 : :
221 [ # # ][ # # ]: 0 : if( aQuickLaunchCB.IsChecked() != aQuickLaunchCB.GetSavedValue())
222 : : {
223 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(SID_ATTR_QUICKLAUNCHER, aQuickLaunchCB.IsChecked()));
[ # # ][ # # ]
224 : 0 : bModified = sal_True;
225 : : }
226 : :
227 [ # # ][ # # ]: 0 : return bModified;
228 : : }
229 : :
230 : : // -----------------------------------------------------------------------
231 : :
232 : 0 : void OfaMemoryOptionsPage::Reset( const SfxItemSet& rSet )
233 : : {
234 : : const SfxPoolItem* pItem;
235 : :
236 [ # # ]: 0 : aUndoEdit.SetValue(officecfg::Office::Common::Undo::Steps::get());
237 [ # # ]: 0 : aUndoEdit.SaveValue();
238 : :
239 : : // GraphicCache
240 : : long n =
241 : : officecfg::Office::Common::Cache::GraphicManager::TotalCacheSize::get();
242 [ # # ]: 0 : SetNfGraphicCacheVal( n );
243 : : SetNfGraphicObjectCacheVal(
244 : : std::min(
245 [ # # ]: 0 : GetNfGraphicCacheVal(),
246 : : (officecfg::Office::Common::Cache::GraphicManager::ObjectCacheSize::
247 [ # # ][ # # ]: 0 : get())));
248 : :
249 : : sal_Int32 nTime =
250 : : officecfg::Office::Common::Cache::GraphicManager::ObjectReleaseTime::
251 : : get();
252 [ # # ]: 0 : Time aTime( (sal_uInt16)( nTime / 3600 ), (sal_uInt16)( ( nTime % 3600 ) / 60 ), (sal_uInt16)( ( nTime % 3600 ) % 60 ) );
253 [ # # ]: 0 : aTfGraphicObjectTime.SetTime( aTime );
254 : :
255 [ # # ]: 0 : GraphicCacheConfigHdl( &aNfGraphicCache );
256 : :
257 : : // OLECache
258 : : aNfOLECache.SetValue(
259 : : std::max(
260 : : officecfg::Office::Common::Cache::Writer::OLE_Objects::get(),
261 : : (officecfg::Office::Common::Cache::DrawingEngine::OLE_Objects::
262 [ # # ][ # # ]: 0 : get())));
263 : :
264 [ # # ]: 0 : SfxItemState eState = rSet.GetItemState( SID_ATTR_QUICKLAUNCHER, sal_False, &pItem );
265 [ # # ]: 0 : if ( SFX_ITEM_SET == eState )
266 [ # # ]: 0 : aQuickLaunchCB.Check( ( (SfxBoolItem*)pItem )->GetValue() );
267 [ # # ]: 0 : else if ( SFX_ITEM_DISABLED == eState )
268 : : {
269 : : // quickstart not installed
270 [ # # ]: 0 : aQuickLaunchFL.Hide();
271 [ # # ]: 0 : aQuickLaunchCB.Hide();
272 : : }
273 : :
274 : 0 : aQuickLaunchCB.SaveValue();
275 : 0 : }
276 : :
277 : : // -----------------------------------------------------------------------
278 : :
279 : 0 : IMPL_LINK_NOARG(OfaMemoryOptionsPage, GraphicCacheConfigHdl)
280 : : {
281 : 0 : sal_Int32 n = GetNfGraphicCacheVal();
282 : 0 : SetNfGraphicObjectCacheMax( n );
283 : 0 : SetNfGraphicObjectCacheLast( n );
284 : :
285 [ # # ]: 0 : if( GetNfGraphicObjectCacheVal() > n )
286 : 0 : SetNfGraphicObjectCacheVal( n );
287 : :
288 : 0 : return 0;
289 : : }
290 : :
291 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|