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