diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-26 16:26:15 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-26 16:26:39 +0100 |
commit | 252e599b22f08a8138b78e4215c33a86f5889fef (patch) | |
tree | 6c25bcb3bee68d59eedeeda1806fa57bc2a36338 | |
parent | 5e51960dede5015b862df05b7b16f02884647889 (diff) |
Replace SvtInetOptions with (simplified) direct configuration access.
-rw-r--r-- | cui/source/options/optinet2.cxx | 1 | ||||
-rw-r--r-- | fpicker/source/office/iodlg.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/appl/app.cxx | 1 | ||||
-rw-r--r-- | sfx2/source/appl/appcfg.cxx | 103 | ||||
-rw-r--r-- | unotools/Library_utl.mk | 1 | ||||
-rw-r--r-- | unotools/Package_inc.mk | 1 | ||||
-rw-r--r-- | unotools/inc/unotools/inetoptions.hxx | 102 | ||||
-rw-r--r-- | unotools/inc/unotools/itemholderbase.hxx | 1 | ||||
-rw-r--r-- | unotools/source/config/inetoptions.cxx | 485 | ||||
-rw-r--r-- | unotools/source/config/itemholder1.cxx | 5 |
10 files changed, 71 insertions, 630 deletions
diff --git a/cui/source/options/optinet2.cxx b/cui/source/options/optinet2.cxx index bcf0c6000a40..361ce967b2b8 100644 --- a/cui/source/options/optinet2.cxx +++ b/cui/source/options/optinet2.cxx @@ -43,7 +43,6 @@ #include <tools/inetdef.hxx> #include <svl/urihelper.hxx> #include <svl/cntwids.hrc> -#include <unotools/inetoptions.hxx> #include <sfx2/app.hxx> #include <sfx2/objsh.hxx> #include <unotools/bootstrap.hxx> diff --git a/fpicker/source/office/iodlg.cxx b/fpicker/source/office/iodlg.cxx index fd02d6b9ffe9..014388ff1706 100644 --- a/fpicker/source/office/iodlg.cxx +++ b/fpicker/source/office/iodlg.cxx @@ -42,7 +42,6 @@ #include "unotools/pathoptions.hxx" #include "unotools/viewoptions.hxx" #include "svtools/fileview.hxx" -#include "unotools/inetoptions.hxx" #include "svtools/sfxecode.hxx" #include "svl/svarray.hxx" #include "svtools/svtabbx.hxx" diff --git a/sfx2/source/appl/app.cxx b/sfx2/source/appl/app.cxx index 4931518e54dc..7e29777fa6b6 100644 --- a/sfx2/source/appl/app.cxx +++ b/sfx2/source/appl/app.cxx @@ -125,7 +125,6 @@ #include <unotools/startoptions.hxx> #include <unotools/securityoptions.hxx> #include <unotools/localisationoptions.hxx> -#include <unotools/inetoptions.hxx> #include <unotools/fontoptions.hxx> #include <unotools/internaloptions.hxx> #include <unotools/workingsetoptions.hxx> diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx index f68f72d1f7fc..cd91d40f98b2 100644 --- a/sfx2/source/appl/appcfg.cxx +++ b/sfx2/source/appl/appcfg.cxx @@ -51,6 +51,7 @@ #include <svl/isethint.hxx> +#include <officecfg/Inet.hxx> #include <unotools/configmgr.hxx> #include <tools/urlobj.hxx> #include <unotools/saveopt.hxx> @@ -58,7 +59,6 @@ #include <unotools/undoopt.hxx> #include <unotools/securityoptions.hxx> #include <unotools/pathoptions.hxx> -#include <unotools/inetoptions.hxx> #include <svtools/miscopt.hxx> #include <vcl/toolbox.hxx> #include <unotools/localfilehelper.hxx> @@ -171,7 +171,6 @@ sal_Bool SfxApplication::GetOptions( SfxItemSet& rSet ) SvtSaveOptions aSaveOptions; SvtUndoOptions aUndoOptions; SvtHelpOptions aHelpOptions; - SvtInetOptions aInetOptions; SvtSecurityOptions aSecurityOptions; SvtMiscOptions aMiscOptions; @@ -395,33 +394,54 @@ sal_Bool SfxApplication::GetOptions( SfxItemSet& rSet ) #endif break; case SID_INET_PROXY_TYPE : - { - if( rSet.Put( SfxUInt16Item ( rPool.GetWhich( SID_INET_PROXY_TYPE ), - (sal_uInt16)aInetOptions.GetProxyType() ))) - bRet = sal_True; + if (rSet.Put( + SfxUInt16Item( + rPool.GetWhich(SID_INET_PROXY_TYPE), + officecfg::Inet::Settings::ooInetProxyType::get( + comphelper::getProcessComponentContext())))) + { + bRet = true; + } break; - } case SID_INET_HTTP_PROXY_NAME : - { - if ( rSet.Put( SfxStringItem ( rPool.GetWhich(SID_INET_HTTP_PROXY_NAME ), - aInetOptions.GetProxyHttpName() ))) - bRet = sal_True; + if (rSet.Put( + SfxStringItem( + rPool.GetWhich(SID_INET_HTTP_PROXY_NAME), + officecfg::Inet::Settings::ooInetHTTPProxyName::get( + comphelper::getProcessComponentContext())))) + { + bRet = true; + } break; - } case SID_INET_HTTP_PROXY_PORT : - if ( rSet.Put( SfxInt32Item( rPool.GetWhich(SID_INET_HTTP_PROXY_PORT ), - aInetOptions.GetProxyHttpPort() ))) - bRet = sal_True; + if (rSet.Put( + SfxInt32Item( + rPool.GetWhich(SID_INET_HTTP_PROXY_PORT), + officecfg::Inet::Settings::ooInetHTTPProxyPort::get( + comphelper::getProcessComponentContext())))) + { + bRet = true; + } break; case SID_INET_FTP_PROXY_NAME : - if ( rSet.Put( SfxStringItem ( rPool.GetWhich(SID_INET_FTP_PROXY_NAME ), - aInetOptions.GetProxyFtpName() ))) - bRet = sal_True; + if (rSet.Put( + SfxStringItem( + rPool.GetWhich(SID_INET_FTP_PROXY_NAME), + officecfg::Inet::Settings::ooInetFTPProxyName::get( + comphelper::getProcessComponentContext())))) + { + bRet = true; + } break; case SID_INET_FTP_PROXY_PORT : - if ( rSet.Put( SfxInt32Item ( rPool.GetWhich(SID_INET_FTP_PROXY_PORT ), - aInetOptions.GetProxyFtpPort() ))) - bRet = sal_True; + if (rSet.Put( + SfxInt32Item( + rPool.GetWhich(SID_INET_FTP_PROXY_PORT), + officecfg::Inet::Settings::ooInetFTPProxyPort::get( + comphelper::getProcessComponentContext())))) + { + bRet = true; + } break; case SID_INET_SECURITY_PROXY_NAME : case SID_INET_SECURITY_PROXY_PORT : @@ -430,9 +450,14 @@ sal_Bool SfxApplication::GetOptions( SfxItemSet& rSet ) #endif break; case SID_INET_NOPROXY : - if( rSet.Put( SfxStringItem ( rPool.GetWhich( SID_INET_NOPROXY), - aInetOptions.GetProxyNoProxy() ))) - bRet = sal_True; + if (rSet.Put( + SfxStringItem( + rPool.GetWhich( SID_INET_NOPROXY), + officecfg::Inet::Settings::ooInetNoProxy::get( + comphelper::getProcessComponentContext())))) + { + bRet = true; + } break; case SID_ATTR_PATHNAME : case SID_ATTR_PATHGROUP : @@ -510,8 +535,10 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) SvtHelpOptions aHelpOptions; SvtSecurityOptions aSecurityOptions; SvtPathOptions aPathOptions; - SvtInetOptions aInetOptions; SvtMiscOptions aMiscOptions; + boost::shared_ptr< unotools::ConfigurationChanges > batch( + unotools::ConfigurationChanges::create( + comphelper::getProcessComponentContext())); if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_ATTR_BUTTON_OUTSTYLE3D), sal_True, &pItem) ) { DBG_ASSERT(pItem->ISA(SfxBoolItem), "BoolItem expected"); @@ -724,33 +751,45 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) if ( SFX_ITEM_SET == rSet.GetItemState(rPool.GetWhich(SID_INET_PROXY_TYPE), sal_True, &pItem)) { DBG_ASSERT( pItem->ISA(SfxUInt16Item), "UInt16Item expected" ); - aInetOptions.SetProxyType((SvtInetOptions::ProxyType)( (const SfxUInt16Item*)pItem )->GetValue()); + officecfg::Inet::Settings::ooInetProxyType::set( + comphelper::getProcessComponentContext(), batch, + static_cast< SfxUInt16Item const * >(pItem)->GetValue()); } if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_NAME ), sal_True, &pItem ) ) { DBG_ASSERT( pItem->ISA(SfxStringItem), "StringItem expected" ); - aInetOptions.SetProxyHttpName( ((const SfxStringItem *)pItem)->GetValue() ); + officecfg::Inet::Settings::ooInetHTTPProxyName::set( + comphelper::getProcessComponentContext(), batch, + static_cast< SfxStringItem const * >(pItem)->GetValue()); } if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_HTTP_PROXY_PORT ), sal_True, &pItem ) ) { DBG_ASSERT( pItem->ISA(SfxInt32Item), "Int32Item expected" ); - aInetOptions.SetProxyHttpPort( ( (const SfxInt32Item*)pItem )->GetValue() ); + officecfg::Inet::Settings::ooInetHTTPProxyPort::set( + comphelper::getProcessComponentContext(), batch, + static_cast< SfxInt32Item const * >(pItem)->GetValue()); } if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_NAME ), sal_True, &pItem ) ) { DBG_ASSERT( pItem->ISA(SfxStringItem), "StringItem expected" ); - aInetOptions.SetProxyFtpName( ((const SfxStringItem *)pItem)->GetValue() ); + officecfg::Inet::Settings::ooInetFTPProxyName::set( + comphelper::getProcessComponentContext(), batch, + static_cast< SfxStringItem const * >(pItem)->GetValue()); } if ( SFX_ITEM_SET == rSet.GetItemState( rPool.GetWhich( SID_INET_FTP_PROXY_PORT ), sal_True, &pItem ) ) { DBG_ASSERT( pItem->ISA(SfxInt32Item), "Int32Item expected" ); - aInetOptions.SetProxyFtpPort( ( (const SfxInt32Item*)pItem )->GetValue() ); + officecfg::Inet::Settings::ooInetFTPProxyPort::set( + comphelper::getProcessComponentContext(), batch, + static_cast< SfxInt32Item const * >(pItem)->GetValue()); } if ( SFX_ITEM_SET == rSet.GetItemState(SID_INET_NOPROXY, sal_True, &pItem)) { DBG_ASSERT(pItem->ISA(SfxStringItem), "StringItem expected"); - aInetOptions.SetProxyNoProxy(((const SfxStringItem *)pItem)->GetValue()); + officecfg::Inet::Settings::ooInetNoProxy::set( + comphelper::getProcessComponentContext(), batch, + static_cast< SfxStringItem const * >(pItem)->GetValue()); } // Secure-Referers @@ -786,7 +825,7 @@ void SfxApplication::SetOptions_Impl( const SfxItemSet& rSet ) } // Store changed data - aInetOptions.flush(); + batch->commit(); } //-------------------------------------------------------------------- diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index 2b68a95d65ee..724acd34db06 100644 --- a/unotools/Library_utl.mk +++ b/unotools/Library_utl.mk @@ -92,7 +92,6 @@ $(eval $(call gb_Library_add_exception_objects,utl,\ unotools/source/config/fontcfg \ unotools/source/config/fontoptions \ unotools/source/config/historyoptions \ - unotools/source/config/inetoptions \ unotools/source/config/internaloptions \ unotools/source/config/itemholder1 \ unotools/source/config/lingucfg \ diff --git a/unotools/Package_inc.mk b/unotools/Package_inc.mk index 41a2aa132cfd..1a4abc75ee36 100644 --- a/unotools/Package_inc.mk +++ b/unotools/Package_inc.mk @@ -64,7 +64,6 @@ $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/fontoptions.hxx,unot $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/historyoptions_const.hxx,unotools/historyoptions_const.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/historyoptions.hxx,unotools/historyoptions.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/idhelper.hxx,unotools/idhelper.hxx)) -$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/inetoptions.hxx,unotools/inetoptions.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/internaloptions.hxx,unotools/internaloptions.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/intlwrapper.hxx,unotools/intlwrapper.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/itemholderbase.hxx,unotools/itemholderbase.hxx)) diff --git a/unotools/inc/unotools/inetoptions.hxx b/unotools/inc/unotools/inetoptions.hxx deleted file mode 100644 index fb749d3d4421..000000000000 --- a/unotools/inc/unotools/inetoptions.hxx +++ /dev/null @@ -1,102 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _unotools_INETOPTIONS_HXX_ -#define _unotools_INETOPTIONS_HXX_ - -#include "unotools/unotoolsdllapi.h" -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <sal/types.h> -#include <unotools/options.hxx> - -namespace com { namespace sun { namespace star { namespace beans { - class XPropertiesChangeListener; -} } } } -namespace rtl { class OUString; } - -//============================================================================ -/** The names of all the properties (options) accessible through - SvtInetOptions. - */ -#define SVT_INET_OPTION_PROXY_NO_PROXY "Inet/Proxy/NoProxy" -#define SVT_INET_OPTION_PROXY_TYPE "Inet/Proxy/Type" -#define SVT_INET_OPTION_PROXY_FTP_NAME "Inet/Proxy/FTP/Name" -#define SVT_INET_OPTION_PROXY_FTP_PORT "Inet/Proxy/FTP/Port" -#define SVT_INET_OPTION_PROXY_HTTP_NAME "Inet/Proxy/HTTP/Name" -#define SVT_INET_OPTION_PROXY_HTTP_PORT "Inet/Proxy/HTTP/Port" - -//============================================================================ -/** Interface to access those configuration database entries that are related - to the various Internet services. - - @descr The Set...() methods all have a second parameter bFlush. If false - is passed (the default), the new value is not written back directly, but - only cached within this class. If the value in the configuration database - is also changed, the cached change will get lost. If, on the other hand, - true is passed, the new value is instantly written back to the - configuration database. - */ -class UNOTOOLS_DLLPUBLIC SvtInetOptions: public utl::detail::Options -{ -public: - SvtInetOptions(); - - virtual ~SvtInetOptions(); - - enum ProxyType { NONE, AUTOMATIC, MANUAL }; - - rtl::OUString GetProxyNoProxy() const; - sal_Int32 GetProxyType() const; - - rtl::OUString GetProxyFtpName() const; - sal_Int32 GetProxyFtpPort() const; - - rtl::OUString GetProxyHttpName() const; - sal_Int32 GetProxyHttpPort() const; - - void SetProxyNoProxy(rtl::OUString const & rValue, bool bFlush = false); - void SetProxyType(ProxyType eValue, bool bFlush = false); - - void SetProxyFtpName(rtl::OUString const & rValue, bool bFlush = false); - void SetProxyFtpPort(sal_Int32 nValue, bool bFlush = false); - - void SetProxyHttpName(rtl::OUString const & rValue, bool bFlush = false); - void SetProxyHttpPort(sal_Int32 nValue, bool bFlush = false); - - void flush(); - -private: - class Impl; - - static Impl * m_pImpl; -}; - -#endif // _unotools_INETOPTIONS_HXX_ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/inc/unotools/itemholderbase.hxx b/unotools/inc/unotools/itemholderbase.hxx index fa9ed48b5f78..67a5d356eb2a 100644 --- a/unotools/inc/unotools/itemholderbase.hxx +++ b/unotools/inc/unotools/itemholderbase.hxx @@ -71,7 +71,6 @@ enum EItem E_HELPOPTIONS , // 2 E_HISTORYOPTIONS , // - E_INETOPTIONS , // E_INTERNALOPTIONS , // E_JAVAOPTIONS , // diff --git a/unotools/source/config/inetoptions.cxx b/unotools/source/config/inetoptions.cxx deleted file mode 100644 index d49726b90998..000000000000 --- a/unotools/source/config/inetoptions.cxx +++ /dev/null @@ -1,485 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <unotools/inetoptions.hxx> -#include "rtl/instance.hxx" - -#include <algorithm> -#include <map> -#include <set> -#include <vector> -#include <utility> -#include <com/sun/star/beans/PropertyChangeEvent.hpp> -#include <com/sun/star/beans/XPropertiesChangeListener.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/system/XProxySettings.hpp> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Exception.hpp> -#include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/uno/RuntimeException.hpp> -#include <osl/mutex.hxx> -#include <rtl/ustring.h> -#include <rtl/ustring.hxx> -#include <sal/types.h> -#include <unotools/configitem.hxx> -#include <osl/diagnose.h> -#include <salhelper/refobj.hxx> -#include <rtl/logfile.hxx> -#include "itemholder1.hxx" - -using namespace com::sun; - -//============================================================================ -// -// takeAny -// -//============================================================================ - -namespace { - -template< typename T > inline T takeAny(star::uno::Any const & rAny) -{ - T aValue = T(); - rAny >>= aValue; - return aValue; -} - -} - -//============================================================================ -// -// SvtInetOptions::Impl -// -//============================================================================ - -class SvtInetOptions::Impl: public salhelper::ReferenceObject, - public utl::ConfigItem -{ -public: - enum Index - { - INDEX_NO_PROXY, - INDEX_PROXY_TYPE, - INDEX_FTP_PROXY_NAME, - INDEX_FTP_PROXY_PORT, - INDEX_HTTP_PROXY_NAME, - INDEX_HTTP_PROXY_PORT - }; - - Impl(); - - star::uno::Any getProperty(Index nIndex); - - void - setProperty(Index nIndex, star::uno::Any const & rValue, bool bFlush); - - inline void flush() { Commit(); } - -private: - enum { ENTRY_COUNT = INDEX_HTTP_PROXY_PORT + 1 }; - - struct Entry - { - enum State { UNKNOWN, KNOWN, MODIFIED }; - - inline Entry(): m_eState(UNKNOWN) {} - - rtl::OUString m_aName; - star::uno::Any m_aValue; - State m_eState; - }; - - // MSVC has problems with the below Map type when - // star::uno::Reference< star::beans::XPropertiesChangeListener > is not - // wrapped in class Listener: - class Listener: - public star::uno::Reference< star::beans::XPropertiesChangeListener > - { - public: - Listener(star::uno::Reference< - star::beans::XPropertiesChangeListener > const & - rListener): - star::uno::Reference< star::beans::XPropertiesChangeListener >( - rListener) - {} - }; - - typedef std::map< Listener, std::set< rtl::OUString > > Map; - - osl::Mutex m_aMutex; - Entry m_aEntries[ENTRY_COUNT]; - Map m_aListeners; - - virtual inline ~Impl() { Commit(); } - - virtual void Notify(star::uno::Sequence< rtl::OUString > const & rKeys); - - virtual void Commit(); - - void notifyListeners(star::uno::Sequence< rtl::OUString > const & rKeys); -}; - -//============================================================================ -// virtual -void -SvtInetOptions::Impl::Notify(star::uno::Sequence< rtl::OUString > const & - rKeys) -{ - { - osl::MutexGuard aGuard(m_aMutex); - for (sal_Int32 i = 0; i < rKeys.getLength(); ++i) - for (sal_Int32 j = 0; j < ENTRY_COUNT; ++j) - if (rKeys[i] == m_aEntries[j].m_aName) - { - m_aEntries[j].m_eState = Entry::UNKNOWN; - break; - } - } - notifyListeners(rKeys); -} - -//============================================================================ -// virtual -void SvtInetOptions::Impl::Commit() -{ - star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT); - star::uno::Sequence< star::uno::Any > aValues(ENTRY_COUNT); - sal_Int32 nCount = 0; - { - osl::MutexGuard aGuard(m_aMutex); - for (sal_Int32 i = 0; i < ENTRY_COUNT; ++i) - if (m_aEntries[i].m_eState == Entry::MODIFIED) - { - aKeys[nCount] = m_aEntries[i].m_aName; - aValues[nCount] = m_aEntries[i].m_aValue; - ++nCount; - m_aEntries[i].m_eState = Entry::KNOWN; - } - } - if (nCount > 0) - { - aKeys.realloc(nCount); - aValues.realloc(nCount); - PutProperties(aKeys, aValues); - } -} - -//============================================================================ -void -SvtInetOptions::Impl::notifyListeners( - star::uno::Sequence< rtl::OUString > const & rKeys) -{ - typedef - std::vector< std::pair< star::uno::Reference< - star::beans::XPropertiesChangeListener >, - star::uno::Sequence< - star::beans::PropertyChangeEvent > > > - List; - List aNotifications; - { - osl::MutexGuard aGuard(m_aMutex); - aNotifications.reserve(m_aListeners.size()); - Map::const_iterator aMapEnd(m_aListeners.end()); - for (Map::const_iterator aIt(m_aListeners.begin()); aIt != aMapEnd; - ++aIt) - { - const Map::mapped_type &rSet = aIt->second; - Map::mapped_type::const_iterator aSetEnd(rSet.end()); - star::uno::Sequence< star::beans::PropertyChangeEvent > - aEvents(rKeys.getLength()); - sal_Int32 nCount = 0; - for (sal_Int32 i = 0; i < rKeys.getLength(); ++i) - { - rtl::OUString - aTheKey(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "Inet/"))); - aTheKey += rKeys[i]; - if (rSet.find(aTheKey) != aSetEnd) - { - aEvents[nCount].PropertyName = aTheKey; - aEvents[nCount].PropertyHandle = -1; - ++nCount; - } - } - if (nCount > 0) - { - aEvents.realloc(nCount); - aNotifications. - push_back(std::pair< List::value_type::first_type, - List::value_type::second_type >( - aIt->first, aEvents)); - } - } - } - for (List::size_type i = 0; i < aNotifications.size(); ++i) - if (aNotifications[i].first.is()) - aNotifications[i].first-> - propertiesChange(aNotifications[i].second); -} - -//============================================================================ -SvtInetOptions::Impl::Impl(): - ConfigItem(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Inet/Settings"))) -{ - m_aEntries[INDEX_NO_PROXY].m_aName - = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetNoProxy")); - m_aEntries[INDEX_PROXY_TYPE].m_aName - = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetProxyType")); - m_aEntries[INDEX_FTP_PROXY_NAME].m_aName - = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyName")); - m_aEntries[INDEX_FTP_PROXY_PORT].m_aName - = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetFTPProxyPort")); - m_aEntries[INDEX_HTTP_PROXY_NAME].m_aName - = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyName")); - m_aEntries[INDEX_HTTP_PROXY_PORT].m_aName - = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ooInetHTTPProxyPort")); - - star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT); - for (sal_Int32 i = 0; i < ENTRY_COUNT; ++i) - aKeys[i] = m_aEntries[i].m_aName; - if (!EnableNotification(aKeys)) - OSL_FAIL("SvtInetOptions::Impl::Impl(): Bad EnableNotifications()"); -} - -//============================================================================ -star::uno::Any SvtInetOptions::Impl::getProperty(Index nPropIndex) -{ - for (int nTryCount = 0; nTryCount < 10; ++nTryCount) - { - { - osl::MutexGuard aGuard(m_aMutex); - if (m_aEntries[nPropIndex].m_eState != Entry::UNKNOWN) - return m_aEntries[nPropIndex].m_aValue; - } - star::uno::Sequence< rtl::OUString > aKeys(ENTRY_COUNT); - int nIndices[ENTRY_COUNT]; - sal_Int32 nCount = 0; - { - osl::MutexGuard aGuard(m_aMutex); - for (int i = 0; i < ENTRY_COUNT; ++i) - if (m_aEntries[i].m_eState == Entry::UNKNOWN) - { - aKeys[nCount] = m_aEntries[i].m_aName; - nIndices[nCount] = i; - ++nCount; - } - } - if (nCount > 0) - { - aKeys.realloc(nCount); - star::uno::Sequence< star::uno::Any > - aValues(GetProperties(aKeys)); - OSL_ENSURE(aValues.getLength() == nCount, - "SvtInetOptions::Impl::getProperty():" - " Bad GetProperties() result"); - nCount = std::min(nCount, aValues.getLength()); - { - osl::MutexGuard aGuard(m_aMutex); - for (sal_Int32 i = 0; i < nCount; ++i) - { - int nIndex = nIndices[i]; - if (m_aEntries[nIndex].m_eState == Entry::UNKNOWN) - { - m_aEntries[nIndices[i]].m_aValue = aValues[i]; - m_aEntries[nIndices[i]].m_eState = Entry::KNOWN; - } - } - } - } - } - OSL_FAIL("SvtInetOptions::Impl::getProperty(): Possible life lock"); - { - osl::MutexGuard aGuard(m_aMutex); - return m_aEntries[nPropIndex].m_aValue; - } -} - -//============================================================================ -void SvtInetOptions::Impl::setProperty(Index nIndex, - star::uno::Any const & rValue, - bool bFlush) -{ - SetModified(); - { - osl::MutexGuard aGuard(m_aMutex); - m_aEntries[nIndex].m_aValue = rValue; - m_aEntries[nIndex].m_eState = bFlush ? Entry::KNOWN : Entry::MODIFIED; - } - - star::uno::Sequence< rtl::OUString > aKeys(1); - aKeys[0] = m_aEntries[nIndex].m_aName; - if (bFlush) - { - star::uno::Sequence< star::uno::Any > aValues(1); - aValues[0] = rValue; - PutProperties(aKeys, aValues); - } - else - notifyListeners(aKeys); -} - -//============================================================================ -// -// SvtInetOptions -// -//============================================================================ - -namespace -{ - class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton > - { - }; -} - -// static -SvtInetOptions::Impl * SvtInetOptions::m_pImpl = 0; - -//============================================================================ -SvtInetOptions::SvtInetOptions() -{ - osl::MutexGuard aGuard(LocalSingleton::get()); - if (!m_pImpl) - { - RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtInetOptions_Impl::ctor()"); - m_pImpl = new Impl; - - ItemHolder1::holdConfigItem(E_INETOPTIONS); - } - m_pImpl->acquire(); -} - -//============================================================================ -SvtInetOptions::~SvtInetOptions() -{ - osl::MutexGuard aGuard(LocalSingleton::get()); - if (m_pImpl->release() == 0) - m_pImpl = 0; -} - -//============================================================================ -rtl::OUString SvtInetOptions::GetProxyNoProxy() const -{ - return takeAny< rtl::OUString >(m_pImpl-> - getProperty(Impl::INDEX_NO_PROXY)); -} - -//============================================================================ -sal_Int32 SvtInetOptions::GetProxyType() const -{ - return takeAny< sal_Int32 >(m_pImpl-> - getProperty(Impl::INDEX_PROXY_TYPE)); -} - -//============================================================================ -rtl::OUString SvtInetOptions::GetProxyFtpName() const -{ - return takeAny< rtl::OUString >(m_pImpl-> - getProperty( - Impl::INDEX_FTP_PROXY_NAME)); -} - -//============================================================================ -sal_Int32 SvtInetOptions::GetProxyFtpPort() const -{ - return takeAny< sal_Int32 >(m_pImpl-> - getProperty(Impl::INDEX_FTP_PROXY_PORT)); -} - -//============================================================================ -rtl::OUString SvtInetOptions::GetProxyHttpName() const -{ - return takeAny< rtl::OUString >(m_pImpl-> - getProperty( - Impl::INDEX_HTTP_PROXY_NAME)); -} - -//============================================================================ -sal_Int32 SvtInetOptions::GetProxyHttpPort() const -{ - return takeAny< sal_Int32 >(m_pImpl-> - getProperty(Impl::INDEX_HTTP_PROXY_PORT)); -} - -//============================================================================ -void SvtInetOptions::SetProxyNoProxy(rtl::OUString const & rValue, - bool bFlush) -{ - m_pImpl->setProperty(Impl::INDEX_NO_PROXY, - star::uno::makeAny(rValue), - bFlush); -} - -//============================================================================ -void SvtInetOptions::SetProxyType(ProxyType eValue, bool bFlush) -{ - m_pImpl->setProperty(Impl::INDEX_PROXY_TYPE, - star::uno::makeAny(sal_Int32(eValue)), - bFlush); -} - -//============================================================================ -void SvtInetOptions::SetProxyFtpName(rtl::OUString const & rValue, - bool bFlush) -{ - m_pImpl->setProperty(Impl::INDEX_FTP_PROXY_NAME, - star::uno::makeAny(rValue), - bFlush); -} - -//============================================================================ -void SvtInetOptions::SetProxyFtpPort(sal_Int32 nValue, bool bFlush) -{ - m_pImpl->setProperty(Impl::INDEX_FTP_PROXY_PORT, - star::uno::makeAny(nValue), - bFlush); -} - -//============================================================================ -void SvtInetOptions::SetProxyHttpName(rtl::OUString const & rValue, - bool bFlush) -{ - m_pImpl->setProperty(Impl::INDEX_HTTP_PROXY_NAME, - star::uno::makeAny(rValue), - bFlush); -} - -//============================================================================ -void SvtInetOptions::SetProxyHttpPort(sal_Int32 nValue, bool bFlush) -{ - m_pImpl->setProperty(Impl::INDEX_HTTP_PROXY_PORT, - star::uno::makeAny(nValue), - bFlush); -} - -//============================================================================ -void SvtInetOptions::flush() -{ - m_pImpl->flush(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx index 8eee7ba1b00a..fcc803ecd416 100644 --- a/unotools/source/config/itemholder1.cxx +++ b/unotools/source/config/itemholder1.cxx @@ -48,7 +48,6 @@ #include <unotools/fltrcfg.hxx> #include <unotools/fontoptions.hxx> #include <unotools/historyoptions.hxx> -#include <unotools/inetoptions.hxx> #include <unotools/internaloptions.hxx> #include <unotools/lingucfg.hxx> #include <unotools/localisationoptions.hxx> @@ -210,10 +209,6 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem) rItem.pItem = new SvtHistoryOptions(); break; - case E_INETOPTIONS : - rItem.pItem = new SvtInetOptions(); - break; - case E_INTERNALOPTIONS : rItem.pItem = new SvtInternalOptions(); break; |