diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-27 15:03:39 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-27 15:04:26 +0100 |
commit | 452d86c9cbfb6b4b7e86426931a0d982dd8bb180 (patch) | |
tree | 4f80b7cc380d731c71f566ee7e91b2e300126360 /unotools | |
parent | db59e4481614f58e111a86a1926e49fb523ebbae (diff) |
Replace SvtUndoOptions with (simplified) direct configuration access.
Also, code in sw can be simplified under the premise that always
/org.openoffice.Office.Common/Undo/Steps > 0.
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/Library_utl.mk | 1 | ||||
-rw-r--r-- | unotools/Package_inc.mk | 1 | ||||
-rw-r--r-- | unotools/inc/unotools/itemholderbase.hxx | 1 | ||||
-rw-r--r-- | unotools/inc/unotools/undoopt.hxx | 51 | ||||
-rw-r--r-- | unotools/source/config/itemholder1.cxx | 5 | ||||
-rw-r--r-- | unotools/source/config/undoopt.cxx | 201 |
6 files changed, 0 insertions, 260 deletions
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index 687c8d314e40..71ca9c895734 100644 --- a/unotools/Library_utl.mk +++ b/unotools/Library_utl.mk @@ -106,7 +106,6 @@ $(eval $(call gb_Library_add_exception_objects,utl,\ unotools/source/config/securityoptions \ unotools/source/config/startoptions \ unotools/source/config/syslocaleoptions \ - unotools/source/config/undoopt \ unotools/source/config/useroptions \ unotools/source/config/viewoptions \ unotools/source/config/workingsetoptions \ diff --git a/unotools/Package_inc.mk b/unotools/Package_inc.mk index 1e54854b901f..426a8c0df48a 100644 --- a/unotools/Package_inc.mk +++ b/unotools/Package_inc.mk @@ -99,7 +99,6 @@ $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/transliterationwrapp $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/ucbhelper.hxx,unotools/ucbhelper.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/ucblockbytes.hxx,unotools/ucblockbytes.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/ucbstreamhelper.hxx,unotools/ucbstreamhelper.hxx)) -$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/undoopt.hxx,unotools/undoopt.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/unotoolsdllapi.h,unotools/unotoolsdllapi.h)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/useroptions_const.hxx,unotools/useroptions_const.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/useroptions.hxx,unotools/useroptions.hxx)) diff --git a/unotools/inc/unotools/itemholderbase.hxx b/unotools/inc/unotools/itemholderbase.hxx index 67a5d356eb2a..34bf43fb6748 100644 --- a/unotools/inc/unotools/itemholderbase.hxx +++ b/unotools/inc/unotools/itemholderbase.hxx @@ -99,7 +99,6 @@ enum EItem E_STARTOPTIONS , // E_SYSLOCALEOPTIONS , // 2 - E_UNDOOPTIONS , // 2 E_USEROPTIONS , // 2 E_VIEWOPTIONS_DIALOG , // diff --git a/unotools/inc/unotools/undoopt.hxx b/unotools/inc/unotools/undoopt.hxx deleted file mode 100644 index 840687b4b1cb..000000000000 --- a/unotools/inc/unotools/undoopt.hxx +++ /dev/null @@ -1,51 +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 INCLUDED_unotools_UNDOOPT_HXX -#define INCLUDED_unotools_UNDOOPT_HXX - -#include "unotools/unotoolsdllapi.h" -#include <sal/types.h> -#include <unotools/options.hxx> - -class SvtUndoOptions_Impl; - -class UNOTOOLS_DLLPUBLIC SvtUndoOptions: public utl::detail::Options -{ - SvtUndoOptions_Impl* pImp; - -public: - SvtUndoOptions(); - virtual ~SvtUndoOptions(); - - void SetUndoCount( sal_Int32 n ); - sal_Int32 GetUndoCount() const; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx index 5df8afc357eb..0c83cb826bfb 100644 --- a/unotools/source/config/itemholder1.cxx +++ b/unotools/source/config/itemholder1.cxx @@ -35,7 +35,6 @@ #include <com/sun/star/lang/XComponent.hpp> #include <unotools/misccfg.hxx> -#include <unotools/undoopt.hxx> #include <unotools/useroptions.hxx> #include <unotools/accelcfg.hxx> #include <unotools/cmdoptions.hxx> @@ -284,10 +283,6 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem) // ??? TODO break; - case E_UNDOOPTIONS : - rItem.pItem = new SvtUndoOptions(); - break; - case E_USEROPTIONS : rItem.pItem = new SvtUserOptions(); break; diff --git a/unotools/source/config/undoopt.cxx b/unotools/source/config/undoopt.cxx deleted file mode 100644 index 3233b855e7f4..000000000000 --- a/unotools/source/config/undoopt.cxx +++ /dev/null @@ -1,201 +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/undoopt.hxx> -#include "rtl/instance.hxx" -#include <unotools/configmgr.hxx> -#include <unotools/configitem.hxx> -#include <tools/debug.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <osl/mutex.hxx> -#include <osl/mutex.hxx> -#include <rtl/logfile.hxx> -#include "itemholder1.hxx" - -using namespace utl; -using namespace com::sun::star::uno; -using ::rtl::OUString; - -static SvtUndoOptions_Impl* pOptions = NULL; -static sal_Int32 nRefCount = 0; - -#define STEPS 0 - -class SvtUndoOptions_Impl : public utl::ConfigItem -{ - sal_Int32 nUndoCount; - Sequence< rtl::OUString > m_aPropertyNames; - -public: - SvtUndoOptions_Impl(); - - virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); - virtual void Commit(); - void Load(); - - void SetUndoCount( sal_Int32 n ) { nUndoCount = n; SetModified(); } - sal_Int32 GetUndoCount() const { return nUndoCount; } -}; - -// ----------------------------------------------------------------------- - -SvtUndoOptions_Impl::SvtUndoOptions_Impl() - : ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Undo")) ) - , nUndoCount( 20 ) -{ - Load(); -} - -void SvtUndoOptions_Impl::Commit() -{ - Sequence< Any > aValues( m_aPropertyNames.getLength() ); - Any* pValues = aValues.getArray(); - for ( int nProp = 0; nProp < m_aPropertyNames.getLength(); nProp++ ) - { - switch ( nProp ) - { - case STEPS : - pValues[nProp] <<= nUndoCount; - break; - default: - SAL_WARN( "unotools.config", "invalid index to save a path" ); - } - } - - PutProperties( m_aPropertyNames, aValues ); - NotifyListeners(0); -} - -// ----------------------------------------------------------------------- -void SvtUndoOptions_Impl::Load() -{ - if(!m_aPropertyNames.getLength()) - { - static const char* aPropNames[] = - { - "Steps", - }; - - const int nCount = sizeof( aPropNames ) / sizeof( const char* ); - m_aPropertyNames.realloc(nCount); - OUString* pNames = m_aPropertyNames.getArray(); - for ( int i = 0; i < nCount; i++ ) - pNames[i] = OUString::createFromAscii( aPropNames[i] ); - EnableNotification( m_aPropertyNames ); - } - - Sequence< Any > aValues = GetProperties( m_aPropertyNames ); - const Any* pValues = aValues.getConstArray(); - DBG_ASSERT( aValues.getLength() == m_aPropertyNames.getLength(), "GetProperties failed" ); - if ( aValues.getLength() == m_aPropertyNames.getLength() ) - { - for ( int nProp = 0; nProp < m_aPropertyNames.getLength(); nProp++ ) - { - if ( pValues[nProp].hasValue() ) - { - switch ( nProp ) - { - case STEPS : - { - sal_Int32 nTemp = 0; - if ( pValues[nProp] >>= nTemp ) - nUndoCount = nTemp; - else - { - OSL_FAIL( "Wrong Type!" ); - } - break; - } - - default: - OSL_FAIL( "Wrong Type!" ); - break; - } - } - } - } -} -// ----------------------------------------------------------------------- -void SvtUndoOptions_Impl::Notify( const Sequence<rtl::OUString>& ) -{ - Load(); -} - -// ----------------------------------------------------------------------- -namespace -{ - class LocalSingleton : public rtl::Static< osl::Mutex, LocalSingleton > - { - }; -} - -// ----------------------------------------------------------------------- -SvtUndoOptions::SvtUndoOptions() -{ - // Global access, must be guarded (multithreading) - ::osl::MutexGuard aGuard( LocalSingleton::get() ); - if ( !pOptions ) - { - RTL_LOGFILE_CONTEXT(aLog, "unotools ( ??? ) ::SvtUndoOptions_Impl::ctor()"); - pOptions = new SvtUndoOptions_Impl; - - ItemHolder1::holdConfigItem(E_UNDOOPTIONS); - } - ++nRefCount; - pImp = pOptions; - pImp->AddListener(this); -} - -// ----------------------------------------------------------------------- - -SvtUndoOptions::~SvtUndoOptions() -{ - // Global access, must be guarded (multithreading) - ::osl::MutexGuard aGuard( LocalSingleton::get() ); - pImp->RemoveListener(this); - if ( !--nRefCount ) - { - if ( pOptions->IsModified() ) - pOptions->Commit(); - DELETEZ( pOptions ); - } -} - -void SvtUndoOptions::SetUndoCount( sal_Int32 n ) -{ - pImp->SetUndoCount( n ); -} - -sal_Int32 SvtUndoOptions::GetUndoCount() const -{ - return pImp->GetUndoCount(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |