diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2012-01-25 18:18:18 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-01-25 18:18:52 +0100 |
commit | a2195b2dc301a6c2cfd0bf1a7ff74483bcc5998a (patch) | |
tree | ed7d466e0c75fcc7bf9ca0a0dfa9b8b23ef0a89a /unotools | |
parent | d70aa23c2d3af951c8846b4aea83c87c06a37a35 (diff) |
Replace SourceViewConfig with (simplified) direct configuration access.
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/sourceviewconfig.hxx | 62 | ||||
-rw-r--r-- | unotools/source/config/itemholder1.cxx | 5 | ||||
-rw-r--r-- | unotools/source/config/sourceviewconfig.cxx | 242 |
6 files changed, 0 insertions, 312 deletions
diff --git a/unotools/Library_utl.mk b/unotools/Library_utl.mk index 01571459d571..2b68a95d65ee 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/saveopt \ unotools/source/config/searchopt \ unotools/source/config/securityoptions \ - unotools/source/config/sourceviewconfig \ unotools/source/config/startoptions \ unotools/source/config/syslocaleoptions \ unotools/source/config/undoopt \ diff --git a/unotools/Package_inc.mk b/unotools/Package_inc.mk index 7d031fbb76fb..41a2aa132cfd 100644 --- a/unotools/Package_inc.mk +++ b/unotools/Package_inc.mk @@ -89,7 +89,6 @@ $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/saveopt.hxx,unotools $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/searchopt.hxx,unotools/searchopt.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/securityoptions.hxx,unotools/securityoptions.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/sharedunocomponent.hxx,unotools/sharedunocomponent.hxx)) -$(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/sourceviewconfig.hxx,unotools/sourceviewconfig.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/startoptions.hxx,unotools/startoptions.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/streamhelper.hxx,unotools/streamhelper.hxx)) $(eval $(call gb_Package_add_file,unotools_inc,inc/unotools/streamsection.hxx,unotools/streamsection.hxx)) diff --git a/unotools/inc/unotools/itemholderbase.hxx b/unotools/inc/unotools/itemholderbase.hxx index 8f14f9a17f11..fa9ed48b5f78 100644 --- a/unotools/inc/unotools/itemholderbase.hxx +++ b/unotools/inc/unotools/itemholderbase.hxx @@ -97,7 +97,6 @@ enum EItem E_SAVEOPTIONS , // E_SEARCHOPT , // E_SECURITYOPTIONS , // - E_SOURCEVIEWCONFIG , // E_STARTOPTIONS , // E_SYSLOCALEOPTIONS , // 2 diff --git a/unotools/inc/unotools/sourceviewconfig.hxx b/unotools/inc/unotools/sourceviewconfig.hxx deleted file mode 100644 index 02b2ab0ab79b..000000000000 --- a/unotools/inc/unotools/sourceviewconfig.hxx +++ /dev/null @@ -1,62 +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_SOURCEVIEWCONFIG_HXX -#define _unotools_SOURCEVIEWCONFIG_HXX - -// include --------------------------------------------------------------- - -#include "unotools/unotoolsdllapi.h" -#include <osl/mutex.hxx> -#include <rtl/ustring.hxx> -#include <unotools/options.hxx> - -namespace utl -{ - class SourceViewConfig_Impl; - class UNOTOOLS_DLLPUBLIC SourceViewConfig: public utl::detail::Options - { - static SourceViewConfig_Impl* m_pImplConfig; - static sal_Int32 m_nRefCount; - - public: - SourceViewConfig(); - virtual ~SourceViewConfig(); - - const rtl::OUString& GetFontName() const; - void SetFontName(const rtl::OUString& rName); - - sal_Int16 GetFontHeight() const; - void SetFontHeight(sal_Int16 nHeight); - - sal_Bool IsShowProportionalFontsOnly() const; - void SetShowProportionalFontsOnly(sal_Bool bSet); - }; -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/config/itemholder1.cxx b/unotools/source/config/itemholder1.cxx index c20128bf4773..8eee7ba1b00a 100644 --- a/unotools/source/config/itemholder1.cxx +++ b/unotools/source/config/itemholder1.cxx @@ -59,7 +59,6 @@ #include <unotools/saveopt.hxx> #include <unotools/searchopt.hxx> #include <unotools/securityoptions.hxx> -#include <unotools/sourceviewconfig.hxx> #include <unotools/startoptions.hxx> #include <unotools/viewoptions.hxx> #include <unotools/workingsetoptions.hxx> @@ -263,10 +262,6 @@ void ItemHolder1::impl_newItem(TItemInfo& rItem) rItem.pItem = new SvtSecurityOptions(); break; - case E_SOURCEVIEWCONFIG : - rItem.pItem = new ::utl::SourceViewConfig(); - break; - case E_STARTOPTIONS : rItem.pItem = new SvtStartOptions(); break; diff --git a/unotools/source/config/sourceviewconfig.cxx b/unotools/source/config/sourceviewconfig.cxx deleted file mode 100644 index 7f5bdbe5d428..000000000000 --- a/unotools/source/config/sourceviewconfig.cxx +++ /dev/null @@ -1,242 +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/sourceviewconfig.hxx> -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/Sequence.hxx> -#include <unotools/configitem.hxx> -#include <tools/debug.hxx> -#include <rtl/instance.hxx> - -#include <itemholder1.hxx> - -using namespace utl; -using namespace com::sun::star::uno; - -using ::rtl::OUString; - -namespace utl -{ -class SourceViewConfig_Impl : public utl::ConfigItem -{ -private: - OUString m_sFontName; - sal_Int16 m_nFontHeight; - sal_Bool m_bProportionalFontOnly; - - void Load(); - - static Sequence< OUString > GetPropertyNames(); - -public: - SourceViewConfig_Impl(); - ~SourceViewConfig_Impl(); - - virtual void Notify( const Sequence< rtl::OUString >& aPropertyNames ); - virtual void Commit(); - - const rtl::OUString& GetFontName() const - {return m_sFontName;} - void SetFontName(const rtl::OUString& rName) - { - if(rName != m_sFontName) - { - m_sFontName = rName; - SetModified(); - } - } - - sal_Int16 GetFontHeight() const - {return m_nFontHeight;} - void SetFontHeight(sal_Int16 nHeight) - { - if(m_nFontHeight != nHeight) - { - m_nFontHeight = nHeight; - SetModified(); - } - } - - sal_Bool IsShowProportionalFontsOnly() const - {return m_bProportionalFontOnly;} - void SetShowProportionalFontsOnly(sal_Bool bSet) - { - if(m_bProportionalFontOnly != bSet) - { - m_bProportionalFontOnly = bSet; - SetModified(); - } - } -}; -// initialization of static members -------------------------------------- -SourceViewConfig_Impl* SourceViewConfig::m_pImplConfig = 0; -sal_Int32 SourceViewConfig::m_nRefCount = 0; -namespace { struct lclMutex : public rtl::Static< ::osl::Mutex, lclMutex > {}; } - -SourceViewConfig_Impl::SourceViewConfig_Impl() : - ConfigItem(OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Font/SourceViewFont"))), - m_nFontHeight(12), - m_bProportionalFontOnly(sal_False) -{ - Load(); -} - -SourceViewConfig_Impl::~SourceViewConfig_Impl() -{ -} - -Sequence< OUString > SourceViewConfig_Impl::GetPropertyNames() -{ - //this list needs exactly to mach the enum PropertyNameIndex - static const char* aPropNames[] = - { - "FontName" // 0 - ,"FontHeight" // 1 - ,"NonProportionalFontsOnly" // 2 - }; - const int nCount = sizeof( aPropNames ) / sizeof( const char* ); - Sequence< OUString > aNames( nCount ); - OUString* pNames = aNames.getArray(); - for ( int i = 0; i < nCount; i++ ) - pNames[i] = OUString::createFromAscii( aPropNames[i] ); - - return aNames; -} - -void SourceViewConfig_Impl::Load() -{ - Sequence< OUString > aNames = GetPropertyNames(); - Sequence< Any > aValues = GetProperties( aNames ); - EnableNotification( aNames ); - const Any* pValues = aValues.getConstArray(); - DBG_ASSERT( aValues.getLength() == aNames.getLength(), "GetProperties failed" ); - if ( aValues.getLength() == aNames.getLength() ) - { - for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) - { - if ( pValues[nProp].hasValue() ) - { - switch( nProp ) - { - case 0: pValues[nProp] >>= m_sFontName; break; - case 1: pValues[nProp] >>= m_nFontHeight; break; - case 2: pValues[nProp] >>= m_bProportionalFontOnly; break; - } - } - } - } -} - -void SourceViewConfig_Impl::Notify( const Sequence< OUString >& ) -{ - Load(); -} - -void SourceViewConfig_Impl::Commit() -{ - ClearModified(); - Sequence< OUString > aNames = GetPropertyNames(); - Sequence< Any > aValues( aNames.getLength() ); - Any* pValues = aValues.getArray(); - for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) - { - switch( nProp ) - { - case 0: pValues[nProp] <<= m_sFontName; break; - case 1: pValues[nProp] <<= m_nFontHeight; break; - case 2: pValues[nProp] <<= m_bProportionalFontOnly; break; - default: - SAL_WARN( "unotools.config", "invalid index to save a user token" ); - } - } - PutProperties( aNames, aValues ); - - NotifyListeners(0); -} - -SourceViewConfig::SourceViewConfig() -{ - { - ::osl::MutexGuard aGuard( lclMutex::get() ); - if(!m_pImplConfig) - { - m_pImplConfig = new SourceViewConfig_Impl; - ItemHolder1::holdConfigItem(E_SOURCEVIEWCONFIG); - } - - ++m_nRefCount; - } - - m_pImplConfig->AddListener( this ); -} - -SourceViewConfig::~SourceViewConfig() -{ - m_pImplConfig->RemoveListener( this ); - ::osl::MutexGuard aGuard( lclMutex::get() ); - if( !--m_nRefCount ) - { - if( m_pImplConfig->IsModified() ) - m_pImplConfig->Commit(); - DELETEZ( m_pImplConfig ); - } -} - -const OUString& SourceViewConfig::GetFontName() const -{ - return m_pImplConfig->GetFontName(); -} - -void SourceViewConfig::SetFontName(const OUString& rName) -{ - m_pImplConfig->SetFontName(rName); -} - -sal_Int16 SourceViewConfig::GetFontHeight() const -{ - return m_pImplConfig->GetFontHeight(); -} - -void SourceViewConfig::SetFontHeight(sal_Int16 nHeight) -{ - m_pImplConfig->SetFontHeight(nHeight); -} - -sal_Bool SourceViewConfig::IsShowProportionalFontsOnly() const -{ - return m_pImplConfig->IsShowProportionalFontsOnly(); -} - -void SourceViewConfig::SetShowProportionalFontsOnly(sal_Bool bSet) -{ - m_pImplConfig->SetShowProportionalFontsOnly(bSet); -} -} -// namespace utl - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |