1*2ee96f1cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*2ee96f1cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*2ee96f1cSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*2ee96f1cSAndrew Rist * distributed with this work for additional information
6*2ee96f1cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*2ee96f1cSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*2ee96f1cSAndrew Rist * "License"); you may not use this file except in compliance
9*2ee96f1cSAndrew Rist * with the License. You may obtain a copy of the License at
10*2ee96f1cSAndrew Rist *
11*2ee96f1cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*2ee96f1cSAndrew Rist *
13*2ee96f1cSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*2ee96f1cSAndrew Rist * software distributed under the License is distributed on an
15*2ee96f1cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2ee96f1cSAndrew Rist * KIND, either express or implied. See the License for the
17*2ee96f1cSAndrew Rist * specific language governing permissions and limitations
18*2ee96f1cSAndrew Rist * under the License.
19*2ee96f1cSAndrew Rist *
20*2ee96f1cSAndrew Rist *************************************************************/
21*2ee96f1cSAndrew Rist
22*2ee96f1cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_cui.hxx"
26cdf0e10cSrcweir #include <svtools/langtab.hxx>
27cdf0e10cSrcweir #include <svl/zforlist.hxx>
28cdf0e10cSrcweir #include <svtools/grfmgr.hxx>
29cdf0e10cSrcweir #include <svl/flagitem.hxx>
30cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
31cdf0e10cSrcweir #include <unotools/lingucfg.hxx>
32cdf0e10cSrcweir #include <svl/szitem.hxx>
33cdf0e10cSrcweir #include <sfx2/viewsh.hxx>
34cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
35cdf0e10cSrcweir #include <sfx2/filedlghelper.hxx>
36cdf0e10cSrcweir #include <vcl/msgbox.hxx>
37cdf0e10cSrcweir #include <rtl/math.hxx>
38cdf0e10cSrcweir #include <unotools/undoopt.hxx>
39cdf0e10cSrcweir #include <unotools/useroptions.hxx>
40cdf0e10cSrcweir #include <unotools/cacheoptions.hxx>
41cdf0e10cSrcweir #include <unotools/fontoptions.hxx>
42cdf0e10cSrcweir #include <svtools/menuoptions.hxx>
43cdf0e10cSrcweir #include <unotools/startoptions.hxx>
44cdf0e10cSrcweir #include <svl/cjkoptions.hxx>
45cdf0e10cSrcweir #include <svtools/miscopt.hxx>
46cdf0e10cSrcweir #include <unotools/syslocaleoptions.hxx>
47cdf0e10cSrcweir #include <svtools/helpopt.hxx>
48cdf0e10cSrcweir #include <unotools/configitem.hxx>
49cdf0e10cSrcweir #include <sfx2/objsh.hxx>
50cdf0e10cSrcweir #include <comphelper/types.hxx>
51cdf0e10cSrcweir #include <editeng/unolingu.hxx>
52cdf0e10cSrcweir #include <editeng/langitem.hxx>
53cdf0e10cSrcweir #include "cuioptgenrl.hxx"
54cdf0e10cSrcweir #include "optpath.hxx"
55cdf0e10cSrcweir #include "optsave.hxx"
56cdf0e10cSrcweir #include "optlingu.hxx"
57cdf0e10cSrcweir #include <svx/xpool.hxx>
58cdf0e10cSrcweir #include <svx/dlgutil.hxx>
59cdf0e10cSrcweir #include "cuitabarea.hxx"
60cdf0e10cSrcweir #include <cuires.hrc>
61cdf0e10cSrcweir #include "optmemory.hrc"
62cdf0e10cSrcweir #include "optmemory.hxx"
63cdf0e10cSrcweir #include <svx/ofaitem.hxx>
64cdf0e10cSrcweir #include <cuires.hrc>
65cdf0e10cSrcweir #include "helpid.hrc"
66cdf0e10cSrcweir #include <dialmgr.hxx>
67cdf0e10cSrcweir
68cdf0e10cSrcweir #define CONFIG_LANGUAGES "OfficeLanguages"
69cdf0e10cSrcweir
70cdf0e10cSrcweir using namespace ::com::sun::star::uno;
71cdf0e10cSrcweir using namespace ::com::sun::star::lang;
72cdf0e10cSrcweir using namespace ::com::sun::star::beans;
73cdf0e10cSrcweir using namespace ::utl;
74cdf0e10cSrcweir using namespace ::rtl;
75cdf0e10cSrcweir using namespace ::sfx2;
76cdf0e10cSrcweir
77cdf0e10cSrcweir
78cdf0e10cSrcweir #define NF2BYTES 104857.6 // 2^20/10, used for aNfGraphicObjectCache-unit -> Byte
79cdf0e10cSrcweir #define BYTES2NF (1.0/NF2BYTES) // 10/2^20
80cdf0e10cSrcweir
81cdf0e10cSrcweir
GetNfGraphicCacheVal(void) const82cdf0e10cSrcweir inline long OfaMemoryOptionsPage::GetNfGraphicCacheVal( void ) const
83cdf0e10cSrcweir {
84cdf0e10cSrcweir return static_cast<long>(aNfGraphicCache.GetValue() << 20);
85cdf0e10cSrcweir }
86cdf0e10cSrcweir
SetNfGraphicCacheVal(long nSizeInBytes)87cdf0e10cSrcweir inline void OfaMemoryOptionsPage::SetNfGraphicCacheVal( long nSizeInBytes )
88cdf0e10cSrcweir {
89cdf0e10cSrcweir aNfGraphicCache.SetValue( nSizeInBytes >> 20 );
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
GetNfGraphicObjectCacheVal(void) const92cdf0e10cSrcweir long OfaMemoryOptionsPage::GetNfGraphicObjectCacheVal( void ) const
93cdf0e10cSrcweir {
94cdf0e10cSrcweir return long( ::rtl::math::round( double( aNfGraphicObjectCache.GetValue() ) * NF2BYTES ) );
95cdf0e10cSrcweir }
96cdf0e10cSrcweir
SetNfGraphicObjectCacheVal(long nSizeInBytes)97cdf0e10cSrcweir void OfaMemoryOptionsPage::SetNfGraphicObjectCacheVal( long nSizeInBytes )
98cdf0e10cSrcweir {
99cdf0e10cSrcweir aNfGraphicObjectCache.SetValue( long( ::rtl::math::round( double( nSizeInBytes ) * BYTES2NF ) ) );
100cdf0e10cSrcweir }
101cdf0e10cSrcweir
SetNfGraphicObjectCacheMax(long nSizeInBytes)102cdf0e10cSrcweir inline void OfaMemoryOptionsPage::SetNfGraphicObjectCacheMax( long nSizeInBytes )
103cdf0e10cSrcweir {
104cdf0e10cSrcweir aNfGraphicObjectCache.SetMax( long( double( nSizeInBytes ) * BYTES2NF ) );
105cdf0e10cSrcweir }
106cdf0e10cSrcweir
SetNfGraphicObjectCacheLast(long nSizeInBytes)107cdf0e10cSrcweir inline void OfaMemoryOptionsPage::SetNfGraphicObjectCacheLast( long nSizeInBytes )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir aNfGraphicObjectCache.SetLast( long( double( nSizeInBytes ) * BYTES2NF ) );
110cdf0e10cSrcweir }
111cdf0e10cSrcweir
DeactivatePage(SfxItemSet * _pSet)112cdf0e10cSrcweir int OfaMemoryOptionsPage::DeactivatePage( SfxItemSet* _pSet )
113cdf0e10cSrcweir {
114cdf0e10cSrcweir if ( _pSet )
115cdf0e10cSrcweir FillItemSet( *_pSet );
116cdf0e10cSrcweir return LEAVE_PAGE;
117cdf0e10cSrcweir }
118cdf0e10cSrcweir
119cdf0e10cSrcweir // -----------------------------------------------------------------------
120cdf0e10cSrcweir
OfaMemoryOptionsPage(Window * pParent,const SfxItemSet & rSet)121cdf0e10cSrcweir OfaMemoryOptionsPage::OfaMemoryOptionsPage(Window* pParent, const SfxItemSet& rSet ) :
122cdf0e10cSrcweir
123cdf0e10cSrcweir SfxTabPage( pParent, CUI_RES( OFA_TP_MEMORY ), rSet ),
124cdf0e10cSrcweir
125cdf0e10cSrcweir aUndoBox ( this, CUI_RES( GB_UNDO ) ),
126cdf0e10cSrcweir aUndoText ( this, CUI_RES( FT_UNDO ) ),
127cdf0e10cSrcweir aUndoEdit ( this, CUI_RES( ED_UNDO ) ),
128cdf0e10cSrcweir aGbGraphicCache ( this, CUI_RES( GB_GRAPHICCACHE ) ),
129cdf0e10cSrcweir aFtGraphicCache ( this, CUI_RES( FT_GRAPHICCACHE ) ),
130cdf0e10cSrcweir aNfGraphicCache ( this, CUI_RES( NF_GRAPHICCACHE ) ),
131cdf0e10cSrcweir aFtGraphicCacheUnit ( this, CUI_RES( FT_GRAPHICCACHE_UNIT ) ),
132cdf0e10cSrcweir aFtGraphicObjectCache ( this, CUI_RES( FT_GRAPHICOBJECTCACHE ) ),
133cdf0e10cSrcweir aNfGraphicObjectCache ( this, CUI_RES( NF_GRAPHICOBJECTCACHE ) ),
134cdf0e10cSrcweir aFtGraphicObjectCacheUnit(this, CUI_RES( FT_GRAPHICOBJECTCACHE_UNIT ) ),
135cdf0e10cSrcweir aFtGraphicObjectTime ( this, CUI_RES( FT_GRAPHICOBJECTTIME ) ),
136cdf0e10cSrcweir aTfGraphicObjectTime ( this, CUI_RES( TF_GRAPHICOBJECTTIME ) ),
137cdf0e10cSrcweir aFtGraphicObjectTimeUnit( this, CUI_RES( FT_GRAPHICOBJECTTIME_UNIT ) ),
138cdf0e10cSrcweir
139cdf0e10cSrcweir aGbOLECache ( this, CUI_RES( GB_OLECACHE ) ),
140cdf0e10cSrcweir aFtOLECache ( this, CUI_RES( FT_OLECACHE ) ),
141cdf0e10cSrcweir aNfOLECache ( this, CUI_RES( NF_OLECACHE ) ),
142cdf0e10cSrcweir aQuickLaunchFL ( this, CUI_RES( FL_QUICKLAUNCH ) ),
143cdf0e10cSrcweir aQuickLaunchCB ( this, CUI_RES( CB_QUICKLAUNCH ) )//,
144cdf0e10cSrcweir {
145cdf0e10cSrcweir #if defined(UNX)
146cdf0e10cSrcweir aQuickLaunchCB.SetText( CUI_RES( STR_QUICKLAUNCH_UNX ) );
147cdf0e10cSrcweir #endif
148cdf0e10cSrcweir FreeResource();
149cdf0e10cSrcweir
150cdf0e10cSrcweir //quick launch only available in Win and OS/2
151cdf0e10cSrcweir #if !defined(WNT) && !defined(OS2) && !defined(ENABLE_GTK)
152cdf0e10cSrcweir aQuickLaunchFL.Hide();
153cdf0e10cSrcweir aQuickLaunchCB.Hide();
154cdf0e10cSrcweir #endif
155cdf0e10cSrcweir
156cdf0e10cSrcweir aTfGraphicObjectTime.SetExtFormat( EXTTIMEF_24H_SHORT );
157cdf0e10cSrcweir
158cdf0e10cSrcweir SetExchangeSupport();
159cdf0e10cSrcweir
160cdf0e10cSrcweir aNfGraphicCache.SetModifyHdl( LINK( this, OfaMemoryOptionsPage, GraphicCacheConfigHdl ) );
161cdf0e10cSrcweir }
162cdf0e10cSrcweir
163cdf0e10cSrcweir // -----------------------------------------------------------------------
164cdf0e10cSrcweir
~OfaMemoryOptionsPage()165cdf0e10cSrcweir OfaMemoryOptionsPage::~OfaMemoryOptionsPage()
166cdf0e10cSrcweir {
167cdf0e10cSrcweir }
168cdf0e10cSrcweir
169cdf0e10cSrcweir // -----------------------------------------------------------------------
170cdf0e10cSrcweir
Create(Window * pParent,const SfxItemSet & rAttrSet)171cdf0e10cSrcweir SfxTabPage* OfaMemoryOptionsPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
172cdf0e10cSrcweir {
173cdf0e10cSrcweir return new OfaMemoryOptionsPage( pParent, rAttrSet );
174cdf0e10cSrcweir }
175cdf0e10cSrcweir
176cdf0e10cSrcweir // -----------------------------------------------------------------------
177cdf0e10cSrcweir
FillItemSet(SfxItemSet & rSet)178cdf0e10cSrcweir sal_Bool OfaMemoryOptionsPage::FillItemSet( SfxItemSet& rSet )
179cdf0e10cSrcweir {
180cdf0e10cSrcweir sal_Bool bModified = sal_False;
181cdf0e10cSrcweir
182cdf0e10cSrcweir SvtCacheOptions aCacheOptions;
183cdf0e10cSrcweir
184cdf0e10cSrcweir // Undo-Schritte
185cdf0e10cSrcweir if ( aUndoEdit.GetText() != aUndoEdit.GetSavedValue() )
186cdf0e10cSrcweir SvtUndoOptions().SetUndoCount((sal_uInt16)aUndoEdit.GetValue());
187cdf0e10cSrcweir
188cdf0e10cSrcweir // GraphicCache
189cdf0e10cSrcweir aCacheOptions.SetGraphicManagerTotalCacheSize( GetNfGraphicCacheVal() );
190cdf0e10cSrcweir aCacheOptions.SetGraphicManagerObjectCacheSize( GetNfGraphicObjectCacheVal() );
191cdf0e10cSrcweir
192cdf0e10cSrcweir const Time aTime( aTfGraphicObjectTime.GetTime() );
193cdf0e10cSrcweir aCacheOptions.SetGraphicManagerObjectReleaseTime( aTime.GetSec() + aTime.GetMin() * 60 + aTime.GetHour() * 3600 );
194cdf0e10cSrcweir
195cdf0e10cSrcweir // create a dummy graphic object to get access to the common GraphicManager
196cdf0e10cSrcweir GraphicObject aDummyObject;
197cdf0e10cSrcweir GraphicManager& rGrfMgr = aDummyObject.GetGraphicManager();
198cdf0e10cSrcweir
199cdf0e10cSrcweir rGrfMgr.SetMaxCacheSize( aCacheOptions.GetGraphicManagerTotalCacheSize() );
200cdf0e10cSrcweir rGrfMgr.SetMaxObjCacheSize( aCacheOptions.GetGraphicManagerObjectCacheSize(), sal_True );
201cdf0e10cSrcweir rGrfMgr.SetCacheTimeout( aCacheOptions.GetGraphicManagerObjectReleaseTime() );
202cdf0e10cSrcweir
203cdf0e10cSrcweir // OLECache
204cdf0e10cSrcweir aCacheOptions.SetWriterOLE_Objects( static_cast<long>(aNfOLECache.GetValue()) );
205cdf0e10cSrcweir aCacheOptions.SetDrawingEngineOLE_Objects( static_cast<long>(aNfOLECache.GetValue()) );
206cdf0e10cSrcweir
207cdf0e10cSrcweir if( aQuickLaunchCB.IsChecked() != aQuickLaunchCB.GetSavedValue())
208cdf0e10cSrcweir {
209cdf0e10cSrcweir rSet.Put(SfxBoolItem(SID_ATTR_QUICKLAUNCHER, aQuickLaunchCB.IsChecked()));
210cdf0e10cSrcweir bModified = sal_True;
211cdf0e10cSrcweir }
212cdf0e10cSrcweir
213cdf0e10cSrcweir return bModified;
214cdf0e10cSrcweir }
215cdf0e10cSrcweir
216cdf0e10cSrcweir // -----------------------------------------------------------------------
217cdf0e10cSrcweir
Reset(const SfxItemSet & rSet)218cdf0e10cSrcweir void OfaMemoryOptionsPage::Reset( const SfxItemSet& rSet )
219cdf0e10cSrcweir {
220cdf0e10cSrcweir SvtCacheOptions aCacheOptions;
221cdf0e10cSrcweir const SfxPoolItem* pItem;
222cdf0e10cSrcweir
223cdf0e10cSrcweir // Undo-Schritte
224cdf0e10cSrcweir aUndoEdit.SetValue( SvtUndoOptions().GetUndoCount() );
225cdf0e10cSrcweir aUndoEdit.SaveValue();
226cdf0e10cSrcweir
227cdf0e10cSrcweir // GraphicCache
228cdf0e10cSrcweir long n = aCacheOptions.GetGraphicManagerTotalCacheSize();
229cdf0e10cSrcweir SetNfGraphicCacheVal( n );
230cdf0e10cSrcweir SetNfGraphicObjectCacheVal( Min( static_cast<sal_Int32>(GetNfGraphicCacheVal()), aCacheOptions.GetGraphicManagerObjectCacheSize() ) );
231cdf0e10cSrcweir
232cdf0e10cSrcweir sal_Int32 nTime = aCacheOptions.GetGraphicManagerObjectReleaseTime();
233cdf0e10cSrcweir Time aTime( (sal_uInt16)( nTime / 3600 ), (sal_uInt16)( ( nTime % 3600 ) / 60 ), (sal_uInt16)( ( nTime % 3600 ) % 60 ) );
234cdf0e10cSrcweir aTfGraphicObjectTime.SetTime( aTime );
235cdf0e10cSrcweir
236cdf0e10cSrcweir GraphicCacheConfigHdl( &aNfGraphicCache );
237cdf0e10cSrcweir
238cdf0e10cSrcweir // OLECache
239cdf0e10cSrcweir aNfOLECache.SetValue( Max( aCacheOptions.GetWriterOLE_Objects(), aCacheOptions.GetDrawingEngineOLE_Objects() ) );
240cdf0e10cSrcweir
241cdf0e10cSrcweir SfxItemState eState = rSet.GetItemState( SID_ATTR_QUICKLAUNCHER, sal_False, &pItem );
242cdf0e10cSrcweir if ( SFX_ITEM_SET == eState )
243cdf0e10cSrcweir aQuickLaunchCB.Check( ( (SfxBoolItem*)pItem )->GetValue() );
244cdf0e10cSrcweir else if ( SFX_ITEM_DISABLED == eState )
245cdf0e10cSrcweir {
246cdf0e10cSrcweir // quickstart not installed
247cdf0e10cSrcweir aQuickLaunchFL.Hide();
248cdf0e10cSrcweir aQuickLaunchCB.Hide();
249cdf0e10cSrcweir }
250cdf0e10cSrcweir
251cdf0e10cSrcweir aQuickLaunchCB.SaveValue();
252cdf0e10cSrcweir }
253cdf0e10cSrcweir
254cdf0e10cSrcweir // -----------------------------------------------------------------------
255cdf0e10cSrcweir
IMPL_LINK(OfaMemoryOptionsPage,GraphicCacheConfigHdl,NumericField *,EMPTYARG)256cdf0e10cSrcweir IMPL_LINK( OfaMemoryOptionsPage, GraphicCacheConfigHdl, NumericField*, EMPTYARG )
257cdf0e10cSrcweir {
258cdf0e10cSrcweir long n = GetNfGraphicCacheVal();
259cdf0e10cSrcweir SetNfGraphicObjectCacheMax( n );
260cdf0e10cSrcweir SetNfGraphicObjectCacheLast( n );
261cdf0e10cSrcweir
262cdf0e10cSrcweir if( GetNfGraphicObjectCacheVal() > n )
263cdf0e10cSrcweir SetNfGraphicObjectCacheVal( n );
264cdf0e10cSrcweir
265cdf0e10cSrcweir return 0;
266cdf0e10cSrcweir }
267cdf0e10cSrcweir
268