diff options
Diffstat (limited to 'svtools/source/config')
-rw-r--r-- | svtools/source/config/accessibilityoptions.cxx | 649 | ||||
-rw-r--r-- | svtools/source/config/apearcfg.cxx | 321 | ||||
-rw-r--r-- | svtools/source/config/colorcfg.cxx | 686 | ||||
-rw-r--r-- | svtools/source/config/extcolorcfg.cxx | 827 | ||||
-rw-r--r-- | svtools/source/config/fontsubstconfig.cxx | 229 | ||||
-rw-r--r-- | svtools/source/config/helpopt.cxx | 764 | ||||
-rw-r--r-- | svtools/source/config/htmlcfg.cxx | 523 | ||||
-rw-r--r-- | svtools/source/config/itemholder2.cxx | 209 | ||||
-rw-r--r-- | svtools/source/config/itemholder2.hxx | 89 | ||||
-rw-r--r-- | svtools/source/config/makefile.mk | 58 | ||||
-rw-r--r-- | svtools/source/config/menuoptions.cxx | 565 | ||||
-rw-r--r-- | svtools/source/config/miscopt.cxx | 831 | ||||
-rw-r--r-- | svtools/source/config/optionsdrawinglayer.cxx | 1713 | ||||
-rw-r--r-- | svtools/source/config/printoptions.cxx | 870 | ||||
-rw-r--r-- | svtools/source/config/test/makefile.mk | 62 | ||||
-rw-r--r-- | svtools/source/config/test/test.cxx | 270 |
16 files changed, 8666 insertions, 0 deletions
diff --git a/svtools/source/config/accessibilityoptions.cxx b/svtools/source/config/accessibilityoptions.cxx new file mode 100644 index 000000000000..b2d2c54232b0 --- /dev/null +++ b/svtools/source/config/accessibilityoptions.cxx @@ -0,0 +1,649 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include <svtools/accessibilityoptions.hxx> +#include "configitems/accessibilityoptions_const.hxx" + +#include <unotools/configmgr.hxx> +#include <tools/debug.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif +#ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_ +#include <comphelper/configurationhelper.hxx> +#endif +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif +#ifndef _SVT_LOGHELPER_HXX_ +#include <unotools/loghelper.hxx> +#endif + +#include <svl/smplhint.hxx> + +#include <vcl/settings.hxx> +#include <vcl/svapp.hxx> +#include <rtl/instance.hxx> + +#include <itemholder2.hxx> + +using namespace utl; +using namespace rtl; +using namespace com::sun::star::uno; +namespace css = com::sun::star; + +#define HELP_TIP_TIMEOUT 0xffff // max. timeout setting to pretend a non-timeout + + +// class SvtAccessibilityOptions_Impl --------------------------------------------- + +class SvtAccessibilityOptions_Impl +{ +private: + css::uno::Reference< css::container::XNameAccess > m_xCfg; + sal_Bool bIsModified; + +public: + SvtAccessibilityOptions_Impl(); + ~SvtAccessibilityOptions_Impl(); + + void SetVCLSettings(); + sal_Bool GetAutoDetectSystemHC(); + sal_Bool GetIsForPagePreviews() const; + sal_Bool GetIsHelpTipsDisappear() const; + sal_Bool GetIsAllowAnimatedGraphics() const; + sal_Bool GetIsAllowAnimatedText() const; + sal_Bool GetIsAutomaticFontColor() const; + sal_Bool GetIsSystemFont() const; + sal_Int16 GetHelpTipSeconds() const; + sal_Bool IsSelectionInReadonly() const; + + void SetAutoDetectSystemHC(sal_Bool bSet); + void SetIsForPagePreviews(sal_Bool bSet); + void SetIsHelpTipsDisappear(sal_Bool bSet); + void SetIsAllowAnimatedGraphics(sal_Bool bSet); + void SetIsAllowAnimatedText(sal_Bool bSet); + void SetIsAutomaticFontColor(sal_Bool bSet); + void SetIsSystemFont(sal_Bool bSet); + void SetHelpTipSeconds(sal_Int16 nSet); + void SetSelectionInReadonly(sal_Bool bSet); + + sal_Bool IsModified() const { return bIsModified; }; +}; + +// initialization of static members -------------------------------------- + +SvtAccessibilityOptions_Impl* volatile SvtAccessibilityOptions::sm_pSingleImplConfig =NULL; +sal_Int32 volatile SvtAccessibilityOptions::sm_nAccessibilityRefCount(0); + +namespace +{ + struct SingletonMutex + : public rtl::Static< ::osl::Mutex, SingletonMutex > {}; +} + +// ----------------------------------------------------------------------- +// class SvtAccessibilityOptions_Impl --------------------------------------------- + +SvtAccessibilityOptions_Impl::SvtAccessibilityOptions_Impl() +{ + try + { + m_xCfg = css::uno::Reference< css::container::XNameAccess >( + ::comphelper::ConfigurationHelper::openConfig( + utl::getProcessServiceFactory(), + s_sAccessibility, + ::comphelper::ConfigurationHelper::E_STANDARD), + css::uno::UNO_QUERY); + + bIsModified = sal_False; + } + catch(const css::uno::Exception& ex) + { + m_xCfg.clear(); + LogHelper::logIt(ex); + } +} + +SvtAccessibilityOptions_Impl::~SvtAccessibilityOptions_Impl() +{ +} + +// ----------------------------------------------------------------------- +sal_Bool SvtAccessibilityOptions_Impl::GetAutoDetectSystemHC() +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_True; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sAutoDetectSystemHC) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::GetIsForPagePreviews() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_True; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsForPagePreviews) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + return bRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::GetIsHelpTipsDisappear() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_True; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsHelpTipsDisappear) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedGraphics() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_True; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsAllowAnimatedGraphics) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::GetIsAllowAnimatedText() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_True; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsAllowAnimatedText) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::GetIsAutomaticFontColor() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_False; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsAutomaticFontColor) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::GetIsSystemFont() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_True; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsSystemFont) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Int16 SvtAccessibilityOptions_Impl::GetHelpTipSeconds() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Int16 nRet = 4; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sHelpTipSeconds) >>= nRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return nRet; +} + +sal_Bool SvtAccessibilityOptions_Impl::IsSelectionInReadonly() const +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + sal_Bool bRet = sal_False; + + try + { + if(xNode.is()) + xNode->getPropertyValue(s_sIsSelectionInReadonly) >>= bRet; + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +void SvtAccessibilityOptions_Impl::SetAutoDetectSystemHC(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sAutoDetectSystemHC)!=bSet) + { + xNode->setPropertyValue(s_sAutoDetectSystemHC, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetIsForPagePreviews(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsForPagePreviews)!=bSet) + { + xNode->setPropertyValue(s_sIsForPagePreviews, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetIsHelpTipsDisappear(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsHelpTipsDisappear)!=bSet) + { + xNode->setPropertyValue(s_sIsHelpTipsDisappear, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetIsAllowAnimatedGraphics(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsAllowAnimatedGraphics)!=bSet) + { + xNode->setPropertyValue(s_sIsAllowAnimatedGraphics, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetIsAllowAnimatedText(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsAllowAnimatedText)!=bSet) + { + xNode->setPropertyValue(s_sIsAllowAnimatedText, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetIsAutomaticFontColor(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsAutomaticFontColor)!=bSet) + { + xNode->setPropertyValue(s_sIsAutomaticFontColor, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetIsSystemFont(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsSystemFont)!=bSet) + { + xNode->setPropertyValue(s_sIsSystemFont, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetHelpTipSeconds(sal_Int16 nSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sHelpTipSeconds)!=nSet) + { + xNode->setPropertyValue(s_sHelpTipSeconds, css::uno::makeAny(nSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetSelectionInReadonly(sal_Bool bSet) +{ + css::uno::Reference< css::beans::XPropertySet > xNode(m_xCfg, css::uno::UNO_QUERY); + + try + { + if(xNode.is() && xNode->getPropertyValue(s_sIsSelectionInReadonly)!=bSet) + { + xNode->setPropertyValue(s_sIsSelectionInReadonly, css::uno::makeAny(bSet)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + + bIsModified = sal_True; + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtAccessibilityOptions_Impl::SetVCLSettings() +{ + AllSettings aAllSettings = Application::GetSettings(); + HelpSettings aHelpSettings = aAllSettings.GetHelpSettings(); + aHelpSettings.SetTipTimeout( GetIsHelpTipsDisappear() ? GetHelpTipSeconds() * 1000 : HELP_TIP_TIMEOUT); + aAllSettings.SetHelpSettings(aHelpSettings); + if(aAllSettings.GetStyleSettings().GetUseSystemUIFonts() != GetIsSystemFont() ) + { + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + aStyleSettings.SetUseSystemUIFonts( GetIsSystemFont() ); + aAllSettings.SetStyleSettings(aStyleSettings); + Application::MergeSystemSettings( aAllSettings ); + } + + Application::SetSettings(aAllSettings); +} + +// ----------------------------------------------------------------------- +// class SvtAccessibilityOptions -------------------------------------------------- + +SvtAccessibilityOptions::SvtAccessibilityOptions() +{ + { + ::osl::MutexGuard aGuard( SingletonMutex::get() ); + if(!sm_pSingleImplConfig) + { + sm_pSingleImplConfig = new SvtAccessibilityOptions_Impl; + ItemHolder2::holdConfigItem(E_ACCESSIBILITYOPTIONS); + } + ++sm_nAccessibilityRefCount; + } + //StartListening( *sm_pSingleImplConfig, TRUE ); +} + +// ----------------------------------------------------------------------- + +SvtAccessibilityOptions::~SvtAccessibilityOptions() +{ + //EndListening( *sm_pSingleImplConfig, TRUE ); + ::osl::MutexGuard aGuard( SingletonMutex::get() ); + if( !--sm_nAccessibilityRefCount ) + { + //if( sm_pSingleImplConfig->IsModified() ) + // sm_pSingleImplConfig->Commit(); + DELETEZ( sm_pSingleImplConfig ); + } +} + +// ----------------------------------------------------------------------- + +void SvtAccessibilityOptions::Notify( SfxBroadcaster&, const SfxHint& rHint ) +{ + NotifyListeners(0); + if ( rHint.IsA(TYPE(SfxSimpleHint)) ) + { + if ( ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_ACCESSIBILITY_CHANGED ) + SetVCLSettings(); + } +} + +// ----------------------------------------------------------------------- + +sal_Bool SvtAccessibilityOptions::IsModified() const +{ + return sm_pSingleImplConfig->IsModified(); +} +void SvtAccessibilityOptions::Commit() +{ + //sm_pSingleImplConfig->Commit(); +} + +// ----------------------------------------------------------------------- + +sal_Bool SvtAccessibilityOptions::GetIsForDrawings() const +{ + DBG_ERROR( "SvtAccessibilityOptions::GetIsForDrawings: is obsolete!" ); + return sal_False; +} +sal_Bool SvtAccessibilityOptions::GetIsForBorders() const +{ + DBG_ERROR( "SvtAccessibilityOptions::GetIsForBorders: is obsolete!" ); + return sal_False; +} +sal_Bool SvtAccessibilityOptions::GetAutoDetectSystemHC() const +{ + return sm_pSingleImplConfig->GetAutoDetectSystemHC(); +} +sal_Bool SvtAccessibilityOptions::GetIsForPagePreviews() const +{ + return sm_pSingleImplConfig->GetIsForPagePreviews(); +} +sal_Bool SvtAccessibilityOptions::GetIsHelpTipsDisappear() const +{ + return sm_pSingleImplConfig->GetIsHelpTipsDisappear(); +} +sal_Bool SvtAccessibilityOptions::GetIsAllowAnimatedGraphics() const +{ + return sm_pSingleImplConfig->GetIsAllowAnimatedGraphics(); +} +sal_Bool SvtAccessibilityOptions::GetIsAllowAnimatedText() const +{ + return sm_pSingleImplConfig->GetIsAllowAnimatedText(); +} +sal_Bool SvtAccessibilityOptions::GetIsAutomaticFontColor() const +{ + return sm_pSingleImplConfig->GetIsAutomaticFontColor(); +} +sal_Bool SvtAccessibilityOptions::GetIsSystemFont() const +{ + return sm_pSingleImplConfig->GetIsSystemFont(); +} +sal_Int16 SvtAccessibilityOptions::GetHelpTipSeconds() const +{ + return sm_pSingleImplConfig->GetHelpTipSeconds(); +} +sal_Bool SvtAccessibilityOptions::IsSelectionInReadonly() const +{ + return sm_pSingleImplConfig->IsSelectionInReadonly(); +} + +// ----------------------------------------------------------------------- +void SvtAccessibilityOptions::SetAutoDetectSystemHC(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetAutoDetectSystemHC(bSet); +} +void SvtAccessibilityOptions::SetIsForPagePreviews(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetIsForPagePreviews(bSet); +} +void SvtAccessibilityOptions::SetIsHelpTipsDisappear(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetIsHelpTipsDisappear(bSet); +} +void SvtAccessibilityOptions::SetIsAllowAnimatedGraphics(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetIsAllowAnimatedGraphics(bSet); +} +void SvtAccessibilityOptions::SetIsAllowAnimatedText(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetIsAllowAnimatedText(bSet); +} +void SvtAccessibilityOptions::SetIsAutomaticFontColor(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetIsAutomaticFontColor(bSet); +} +void SvtAccessibilityOptions::SetIsSystemFont(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetIsSystemFont(bSet); +} +void SvtAccessibilityOptions::SetHelpTipSeconds(sal_Int16 nSet) +{ + sm_pSingleImplConfig->SetHelpTipSeconds(nSet); +} +void SvtAccessibilityOptions::SetSelectionInReadonly(sal_Bool bSet) +{ + sm_pSingleImplConfig->SetSelectionInReadonly(bSet); +} + +void SvtAccessibilityOptions::SetVCLSettings() +{ + sm_pSingleImplConfig->SetVCLSettings(); +} +// ----------------------------------------------------------------------- diff --git a/svtools/source/config/apearcfg.cxx b/svtools/source/config/apearcfg.cxx new file mode 100644 index 000000000000..316e6ab34656 --- /dev/null +++ b/svtools/source/config/apearcfg.cxx @@ -0,0 +1,321 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "apearcfg.hxx" +#include "com/sun/star/uno/Any.hxx" + +#include "tools/debug.hxx" +#include "vcl/settings.hxx" +#include "vcl/svapp.hxx" +#include <rtl/logfile.hxx> + +#define DEFAULT_LOOKNFEEL 0 +#define DEFAULT_DRAGMODE 2 +#define DEFAULT_SNAPMODE 0 +#define DEFAULT_SCALEFACTOR 100 +#define DEFAULT_AAMINHEIGHT 8 + +using namespace ::rtl; +using namespace ::com::sun::star::uno; + +sal_Bool SvtTabAppearanceCfg::bInitialized = sal_False; + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +SvtTabAppearanceCfg::SvtTabAppearanceCfg() + :ConfigItem(OUString::createFromAscii("Office.Common/View")) + ,nLookNFeel ( DEFAULT_LOOKNFEEL ) + ,nDragMode ( DEFAULT_DRAGMODE ) + ,nScaleFactor ( DEFAULT_SCALEFACTOR ) + ,nSnapMode ( DEFAULT_SNAPMODE ) + ,nMiddleMouse ( MOUSE_MIDDLE_AUTOSCROLL ) +#if defined( UNX ) || defined ( FS_PRIV_DEBUG ) + ,nAAMinPixelHeight ( DEFAULT_AAMINHEIGHT ) +#endif + ,bMenuMouseFollow(FALSE) + ,bSingleLineTabCtrl(FALSE) + ,bColoredTabCtrl(FALSE) +#if defined( UNX ) || defined ( FS_PRIV_DEBUG ) + ,bFontAntialiasing ( TRUE ) +#endif +{ + RTL_LOGFILE_CONTEXT(aLog, "svtools SvtTabAppearanceCfg::SvtTabAppearanceCfg()"); + + const Sequence<OUString>& rNames = GetPropertyNames(); + Sequence<Any> aValues = GetProperties(rNames); + const Any* pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == rNames.getLength(), "GetProperties failed"); + + if(aValues.getLength() == rNames.getLength()) + { + for(int nProp = 0; nProp < rNames.getLength(); ++nProp, ++pValues) + { + if(pValues->hasValue()) + { + switch(nProp) + { + case 0: *pValues >>= nScaleFactor; break; //"FontScaling", + case 1: *pValues >>= nLookNFeel; break; //"LookAndFeel", + case 2: *pValues >>= nDragMode; break; //"Window/Drag", + case 3: bMenuMouseFollow = *(sal_Bool*)pValues->getValue(); break; //"Menu/FollowMouse", + case 4: bSingleLineTabCtrl = *(sal_Bool*)pValues->getValue(); break; //"Dialog/SingleLineTab", + case 5: bColoredTabCtrl = *(sal_Bool*)pValues->getValue(); break; //"Dialog/ColoredTab", + case 6: *pValues >>= nSnapMode; break; //"Dialog/MousePositioning", + case 7: *pValues >>= nMiddleMouse; break; //"Dialog/MiddleMouseButton", +#if defined( UNX ) || defined ( FS_PRIV_DEBUG ) + case 8: bFontAntialiasing = *(sal_Bool*)pValues->getValue(); break; // "FontAntialising/Enabled", + case 9: *pValues >>= nAAMinPixelHeight; break; // "FontAntialising/MinPixelHeight", +#endif + } + } + } + } +} +/* -----------------------------22.05.01 11:53-------------------------------- + + ---------------------------------------------------------------------------*/ +SvtTabAppearanceCfg::~SvtTabAppearanceCfg( ) +{ +} +/* -----------------------------22.05.01 11:54-------------------------------- + + ---------------------------------------------------------------------------*/ +const Sequence<OUString>& SvtTabAppearanceCfg::GetPropertyNames() +{ + static Sequence<OUString> aNames; + if(!aNames.getLength()) + { + static const sal_Char* aPropNames[] = + { + "FontScaling" // 0 + ,"LookAndFeel" // 1 + ,"Window/Drag" // 2 + ,"Menu/FollowMouse" // 3 + ,"Dialog/SingleLineTab" // 4 + ,"Dialog/ColoredTab" // 5 + ,"Dialog/MousePositioning" // 6 + ,"Dialog/MiddleMouseButton" // 7 +#if defined( UNX ) || defined ( FS_PRIV_DEBUG ) + ,"FontAntiAliasing/Enabled" // 8 + ,"FontAntiAliasing/MinPixelHeight" // 9 +#endif + }; + const int nCount = sizeof( aPropNames ) / sizeof( aPropNames[0] ); + aNames.realloc(nCount); + + const sal_Char** pAsciiNames = aPropNames; + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; ++i, ++pNames, ++pAsciiNames) + *pNames = OUString::createFromAscii( *pAsciiNames ); + } + return aNames; +} +/* -----------------------------22.05.01 11:54-------------------------------- + + ---------------------------------------------------------------------------*/ +void SvtTabAppearanceCfg::Commit() +{ + const Sequence<OUString>& rNames = GetPropertyNames(); + Sequence<Any> aValues(rNames.getLength()); + Any* pValues = aValues.getArray(); + + const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < rNames.getLength(); nProp++) + { + switch(nProp) + { + case 0: pValues[nProp] <<= nScaleFactor; break; // "FontScaling", + case 1: pValues[nProp] <<= nLookNFeel; break; //"LookAndFeel", + case 2: pValues[nProp] <<= nDragMode; break; //"Window/Drag", + case 3: pValues[nProp].setValue(&bMenuMouseFollow, rType); break; //"Menu/FollowMouse", + case 4: pValues[nProp].setValue(&bSingleLineTabCtrl, rType); break; //"Dialog/SingleLineTab", + case 5: pValues[nProp].setValue(&bColoredTabCtrl, rType); break; //"Dialog/ColoredTab", + case 6: pValues[nProp] <<= nSnapMode; break; //"Dialog/MousePositioning", + case 7: pValues[nProp] <<= nMiddleMouse; break; //"Dialog/MiddleMouseButton", +#if defined( UNX ) || defined ( FS_PRIV_DEBUG ) + case 8: pValues[nProp].setValue(&bFontAntialiasing, rType); break; // "FontAntialising/Enabled", + case 9: pValues[nProp] <<= nAAMinPixelHeight; break; // "FontAntialising/MinPixelHeight", +#endif + } + } + PutProperties(rNames, aValues); +} + +void SvtTabAppearanceCfg::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) +{ +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SvtTabAppearanceCfg::SetLookNFeel ( USHORT nSet ) +{ + nLookNFeel = nSet; + SetModified(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SvtTabAppearanceCfg::SetDragMode ( USHORT nSet ) +{ + nDragMode = nSet; + SetModified(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SvtTabAppearanceCfg::SetScaleFactor ( USHORT nSet ) +{ + nScaleFactor = nSet; + SetModified(); +} + +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SvtTabAppearanceCfg::SetSnapMode ( USHORT nSet ) +{ + nSnapMode = nSet; + SetModified(); +} +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ +void SvtTabAppearanceCfg::SetMiddleMouseButton ( USHORT nSet ) +{ + nMiddleMouse = nSet; + SetModified(); +} +/*-------------------------------------------------------------------- + Beschreibung: + --------------------------------------------------------------------*/ + +void SvtTabAppearanceCfg::SetApplicationDefaults ( Application* pApp ) +{ + AllSettings hAppSettings = pApp->GetSettings(); + StyleSettings hAppStyle = hAppSettings.GetStyleSettings(); + + // Look & Feel + + // SetStandard...Styles() resets the UseSystemUIFonts flag, + // but we don't want to change it now, so save the flag before ... + BOOL bUseSystemUIFonts = hAppStyle.GetUseSystemUIFonts(); + + switch ( nLookNFeel ) + { + case LookMotif: + hAppStyle.SetStandardUnixStyles(); break; + + case LookOSTwo: + hAppStyle.SetStandardOS2Styles(); break; + + case LookMacintosh: + hAppStyle.SetStandardMacStyles(); break; + + case LookWindows: + hAppStyle.SetStandardWinStyles(); break; + + case LookStardivision: + default: + hAppStyle.SetStandardStyles(); break; + } + + // and set it here + hAppStyle.SetUseSystemUIFonts( bUseSystemUIFonts ); + + // Screen and ScreenFont Scaling + + hAppStyle.SetScreenZoom( nScaleFactor ); + hAppStyle.SetScreenFontZoom( nScaleFactor ); + +#if defined( UNX ) || defined ( FS_PRIV_DEBUG ) + // font anti aliasing + hAppStyle.SetAntialiasingMinPixelHeight( nAAMinPixelHeight ); + hAppStyle.SetDisplayOptions( bFontAntialiasing ? 0 : DISPLAY_OPTION_AA_DISABLE ); +#endif + + // Mouse Snap + + MouseSettings hMouseSettings = hAppSettings.GetMouseSettings(); + ULONG nMouseOptions = hMouseSettings.GetOptions(); + + nMouseOptions &= ! (MOUSE_OPTION_AUTOCENTERPOS | MOUSE_OPTION_AUTODEFBTNPOS); + + switch ( nSnapMode ) + { + case SnapToButton: + nMouseOptions |= MOUSE_OPTION_AUTODEFBTNPOS; + break; + case SnapToMiddle: + nMouseOptions |= MOUSE_OPTION_AUTOCENTERPOS; + break; + case NoSnap: + default: + break; + } + hMouseSettings.SetOptions(nMouseOptions); + hMouseSettings.SetMiddleButtonAction(nMiddleMouse); + + // Merge and Publish Settings + + ULONG nFollow = hMouseSettings.GetFollow(); + if(bMenuMouseFollow) + nFollow |= MOUSE_FOLLOW_MENU; + else + nFollow &= ~MOUSE_FOLLOW_MENU; + hMouseSettings.SetFollow( nFollow ); + sal_uInt16 nTabStyle = 0; + if(bSingleLineTabCtrl) + nTabStyle |= STYLE_TABCONTROL_SINGLELINE; + + if(bColoredTabCtrl) + nTabStyle |= STYLE_TABCONTROL_COLOR; + hAppStyle.SetTabControlStyle(nTabStyle); + + + hAppSettings.SetMouseSettings( hMouseSettings ); + + hAppSettings.SetStyleSettings( hAppStyle ); + pApp->MergeSystemSettings ( hAppSettings ); // Allow system-settings to apply + pApp->SystemSettingsChanging ( hAppSettings, NULL );// Allow overruling of system-settings + //is concerned with window drag + + pApp->SetSettings ( hAppSettings ); +} + + + diff --git a/svtools/source/config/colorcfg.cxx b/svtools/source/config/colorcfg.cxx new file mode 100644 index 000000000000..7a151d609e6e --- /dev/null +++ b/svtools/source/config/colorcfg.cxx @@ -0,0 +1,686 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include <svtools/colorcfg.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <tools/color.hxx> +#include <tools/debug.hxx> +#include <unotools/configitem.hxx> +#include <unotools/configpathes.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <svl/poolitem.hxx> //Any2Bool +#include <svl/smplhint.hxx> +#include <vos/mutex.hxx> + +#include <itemholder2.hxx> + + /* #100822# ---- +#include <vcl/wrkwin.hxx> + ------------- */ +#include <vcl/svapp.hxx> +#include <vcl/event.hxx> +#include <rtl/instance.hxx> + +//----------------------------------------------------------------------------- +using namespace utl; +using namespace rtl; +using namespace com::sun::star; + +namespace svtools +{ + +#define C2U(cChar) OUString::createFromAscii(cChar) +static const sal_Char cColor[] = "/Color"; +static const sal_Char cColorSchemes[] = "ColorSchemes/"; +sal_Int32 nColorRefCount_Impl = 0; +namespace +{ + struct ColorMutex_Impl + : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {}; +} + +ColorConfig_Impl* ColorConfig::m_pImpl = NULL; + +/* -----------------------------16.01.01 15:36-------------------------------- + ---------------------------------------------------------------------------*/ +class ColorConfig_Impl : public utl::ConfigItem +{ + ColorConfigValue m_aConfigValues[ColorConfigEntryCount]; + sal_Bool m_bEditMode; + rtl::OUString m_sIsVisible; + rtl::OUString m_sLoadedScheme; + + uno::Sequence< ::rtl::OUString> GetPropertyNames(const rtl::OUString& rScheme); +public: + ColorConfig_Impl(sal_Bool bEditMode = sal_False); + virtual ~ColorConfig_Impl(); + + void Load(const rtl::OUString& rScheme); + void CommitCurrentSchemeName(); + //changes the name of the current scheme but doesn't load it! + void SetCurrentSchemeName(const rtl::OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;} + virtual void Commit(); + virtual void Notify( const uno::Sequence<rtl::OUString>& aPropertyNames); + + const ColorConfigValue& GetColorConfigValue(ColorConfigEntry eValue) + {return m_aConfigValues[eValue];} + void SetColorConfigValue(ColorConfigEntry eValue, + const ColorConfigValue& rValue ); + + const rtl::OUString& GetLoadedScheme() const {return m_sLoadedScheme;} + + uno::Sequence< ::rtl::OUString> GetSchemeNames(); + + sal_Bool AddScheme(const rtl::OUString& rNode); + sal_Bool RemoveScheme(const rtl::OUString& rNode); + void SetModified(){ConfigItem::SetModified();} + void ClearModified(){ConfigItem::ClearModified();} + void SettingsChanged(); + + // #100822# + DECL_LINK( DataChangedEventListener, VclWindowEvent* ); + + void ImplUpdateApplicationSettings(); +}; + +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString> ColorConfig_Impl::GetPropertyNames(const rtl::OUString& rScheme) +{ + uno::Sequence<OUString> aNames(2 * ColorConfigEntryCount); + OUString* pNames = aNames.getArray(); + struct ColorConfigEntryData_Impl + { + const sal_Char* cName; + sal_Int32 nLength; + rtl_TextEncoding eEncoding; + sal_Bool bCanBeVisible; + }; + static const ColorConfigEntryData_Impl cNames[] = + { + { RTL_CONSTASCII_USTRINGPARAM("/DocColor") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/DocBoundaries") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/AppBackground") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/ObjectBoundaries"),sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/TableBoundaries") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/FontColor") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/Links") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/LinksVisited") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/Anchor") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/Spell") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SmartTags") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterTextGrid") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterFieldShadings"),sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterIdxShadings") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterDirectCursor") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterScriptIndicator") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterSectionBoundaries") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/WriterPageBreaks") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/HTMLSGML") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/HTMLComment") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/HTMLKeyword") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/HTMLUnknown") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcGrid") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreak"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakManual"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcPageBreakAutomatic"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcDetective") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcDetectiveError") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcReference") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/CalcNotesBackground") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/DrawGrid") ,sal_True }, + { RTL_CONSTASCII_USTRINGPARAM("/DrawDrawing") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/DrawFill") ,sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICIdentifier"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICComment") , sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICNumber") , sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICString") , sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICOperator") , sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICKeyword") , sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/BASICError"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLIdentifier"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLNumber"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLString"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLOperator"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLKeyword"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLParameter"), sal_False }, + { RTL_CONSTASCII_USTRINGPARAM("/SQLComment"), sal_False } + }; + int nIndex = 0; + OUString sColor = C2U(cColor); + OUString sBase(C2U(cColorSchemes)); + sBase += utl::wrapConfigurationElementName(rScheme); + const int nCount = ColorConfigEntryCount; + for(sal_Int32 i = 0; i < 4 * nCount; i+= 4) + { + rtl::OUString sBaseName(sBase); + sal_Int32 nPos = i / 4; + sBaseName += OUString(cNames[nPos].cName, cNames[nPos].nLength, cNames[nPos].eEncoding); + pNames[nIndex] += sBaseName; + pNames[nIndex++] += sColor; + if(cNames[nPos].bCanBeVisible) + { + pNames[nIndex] += sBaseName; + pNames[nIndex++] += m_sIsVisible; + } + } + aNames.realloc(nIndex); + return aNames; +} +/* -----------------------------22.03.2002 14:37------------------------------ + + ---------------------------------------------------------------------------*/ +ColorConfig_Impl::ColorConfig_Impl(sal_Bool bEditMode) : + ConfigItem(C2U("Office.UI/ColorScheme")), + m_bEditMode(bEditMode), + m_sIsVisible(C2U("/IsVisible")) +{ + if(!m_bEditMode) + { + //try to register on the root node - if possible + uno::Sequence < ::rtl::OUString > aNames(1); + EnableNotification( aNames ); + } + Load(::rtl::OUString()); + + ImplUpdateApplicationSettings(); + + // #100822# + ::Application::AddEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) ); + +} +/* -----------------------------25.03.2002 12:28------------------------------ + + ---------------------------------------------------------------------------*/ +ColorConfig_Impl::~ColorConfig_Impl() +{ + // #100822# + ::Application::RemoveEventListener( LINK(this, ColorConfig_Impl, DataChangedEventListener) ); +} +/* -----------------------------22.03.2002 14:38------------------------------ + + ---------------------------------------------------------------------------*/ +void ColorConfig_Impl::Load(const rtl::OUString& rScheme) +{ + rtl::OUString sScheme(rScheme); + if(!sScheme.getLength()) + { + //detect current scheme name + uno::Sequence < ::rtl::OUString > aCurrent(1); + aCurrent.getArray()[0] = C2U("CurrentColorScheme"); + uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent ); + aCurrentVal.getConstArray()[0] >>= sScheme; + } + m_sLoadedScheme = sScheme; + // + uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(sScheme); + uno::Sequence< uno::Any > aColors = GetProperties( aColorNames ); + const uno::Any* pColors = aColors.getConstArray(); + const ::rtl::OUString* pColorNames = aColorNames.getConstArray(); + sal_Int32 nIndex = 0; + for(int i = 0; i < 2 * ColorConfigEntryCount && aColors.getLength() > nIndex; i+= 2) + { + if(pColors[nIndex].hasValue()) + pColors[nIndex] >>= m_aConfigValues[i / 2].nColor; + else + m_aConfigValues[i/2].nColor = COL_AUTO; + nIndex++; + if(nIndex >= aColors.getLength()) + break; + //test for visibility property + if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength())) + m_aConfigValues[i / 2].bIsVisible = Any2Bool(pColors[nIndex++]); + } +} +/* -----------------------------22.03.2002 14:38------------------------------ + + ---------------------------------------------------------------------------*/ +void ColorConfig_Impl::Notify( const uno::Sequence<OUString>& ) +{ + //loading via notification always uses the default setting + Load(::rtl::OUString()); + NotifyListeners(0); +} +/* -----------------------------22.03.2002 14:38------------------------------ + + ---------------------------------------------------------------------------*/ +void ColorConfig_Impl::Commit() +{ + uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(m_sLoadedScheme); + uno::Sequence < beans::PropertyValue > aPropValues(aColorNames.getLength()); + beans::PropertyValue* pPropValues = aPropValues.getArray(); + const ::rtl::OUString* pColorNames = aColorNames.getConstArray(); + sal_Int32 nIndex = 0; + const uno::Type& rBoolType = ::getBooleanCppuType(); + for(int i = 0; i < 2 * ColorConfigEntryCount && aColorNames.getLength() > nIndex; i+= 2) + { + pPropValues[nIndex].Name = pColorNames[nIndex]; + //save automatic colors as void value + if(COL_AUTO != sal::static_int_cast<ColorData>(m_aConfigValues[i/2].nColor)) + pPropValues[nIndex].Value <<= m_aConfigValues[i/2].nColor; + + nIndex++; + if(nIndex >= aColorNames.getLength()) + break; + //test for visibility property + if(pColorNames[nIndex].match(m_sIsVisible, pColorNames[nIndex].getLength() - m_sIsVisible.getLength())) + { + pPropValues[nIndex].Name = pColorNames[nIndex]; + pPropValues[nIndex].Value.setValue(&m_aConfigValues[i/2].bIsVisible, rBoolType); + nIndex++; + } + } + rtl::OUString sNode(C2U("ColorSchemes")); + SetSetProperties(sNode, aPropValues); + + CommitCurrentSchemeName(); +} +/* -----------------11.12.2002 10:42----------------- + * + * --------------------------------------------------*/ +void ColorConfig_Impl::CommitCurrentSchemeName() +{ + //save current scheme name + uno::Sequence < ::rtl::OUString > aCurrent(1); + aCurrent.getArray()[0] = C2U("CurrentColorScheme"); + uno::Sequence< uno::Any > aCurrentVal(1); + aCurrentVal.getArray()[0] <<= m_sLoadedScheme; + PutProperties(aCurrent, aCurrentVal); +} +/* -----------------------------25.03.2002 12:19------------------------------ + + ---------------------------------------------------------------------------*/ +void ColorConfig_Impl::SetColorConfigValue(ColorConfigEntry eValue, const ColorConfigValue& rValue ) +{ + if(rValue != m_aConfigValues[eValue]) + { + m_aConfigValues[eValue] = rValue; + SetModified(); + } +} +/* -----------------------------25.03.2002 15:22------------------------------ + + ---------------------------------------------------------------------------*/ +uno::Sequence< ::rtl::OUString> ColorConfig_Impl::GetSchemeNames() +{ + return GetNodeNames(C2U("ColorSchemes")); +} +/* -----------------------------09.04.2002 17:19------------------------------ + + ---------------------------------------------------------------------------*/ +sal_Bool ColorConfig_Impl::AddScheme(const rtl::OUString& rScheme) +{ + if(ConfigItem::AddNode(C2U("ColorSchemes"), rScheme)) + { + m_sLoadedScheme = rScheme; + Commit(); + return sal_True; + } + return sal_False; +} +/* -----------------------------09.04.2002 17:19------------------------------ + + ---------------------------------------------------------------------------*/ +sal_Bool ColorConfig_Impl::RemoveScheme(const rtl::OUString& rScheme) +{ + uno::Sequence< rtl::OUString > aElements(1); + aElements.getArray()[0] = rScheme; + return ClearNodeElements(C2U("ColorSchemes"), aElements); +} +/* -----------------------------2002/06/20 13:03------------------------------ + + ---------------------------------------------------------------------------*/ +void ColorConfig_Impl::SettingsChanged() +{ + vos::OGuard aVclGuard( Application::GetSolarMutex() ); + + ImplUpdateApplicationSettings(); + + NotifyListeners(0); +} +/* -----------------------------2002/08/16 12:07 ----------------------------- + #100822# + --------------------------------------------------------------------------- */ +IMPL_LINK( ColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent ) +{ + if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED ) + { + DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData()); + if ( (pData->GetType() == DATACHANGED_SETTINGS) && + (pData->GetFlags() & SETTINGS_STYLE) ) + { + SettingsChanged(); + return 1L; + } else + return 0L; + } else + return 0L; +} + +// --------------------------------------------------------------------------- + +/** updates the font color in the vcl window settings */ +void ColorConfig_Impl::ImplUpdateApplicationSettings() +{ + Application* pApp = GetpApp(); + if( pApp ) + { + AllSettings aSettings = pApp->GetSettings(); + StyleSettings aStyleSettings( aSettings.GetStyleSettings() ); + + ColorConfigValue aRet = GetColorConfigValue(svtools::FONTCOLOR); + if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor)) + aRet.nColor = ColorConfig::GetDefaultColor(svtools::FONTCOLOR).GetColor(); + + Color aFontColor(aRet.nColor); + + if( aStyleSettings.GetFontColor() != aFontColor ) + { + aStyleSettings.SetFontColor( aFontColor ); + + aSettings.SetStyleSettings( aStyleSettings ); + pApp->SetSettings( aSettings ); + } + } +} + +// --------------------------------------------------------------------------- + +ColorConfig::ColorConfig() +{ + ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + if ( !m_pImpl ) + { + m_pImpl = new ColorConfig_Impl; + ItemHolder2::holdConfigItem(E_COLORCFG); + } + ++nColorRefCount_Impl; + m_pImpl->AddListener(this); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +ColorConfig::~ColorConfig() +{ + ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + m_pImpl->RemoveListener(this); + if(!--nColorRefCount_Impl) + { + delete m_pImpl; + m_pImpl = 0; + } +} +/* -----------------------------11.04.2002 11:49------------------------------ + + ---------------------------------------------------------------------------*/ +Color ColorConfig::GetDefaultColor(ColorConfigEntry eEntry) +{ + static const sal_Int32 aAutoColors[] = + { + 0, // DOCCOLOR + 0xc0c0c0, // DOCBOUNDARIES + 0x808080, // APPBACKGROUND + 0xc0c0c0, // OBJECTBOUNDARIES + 0xc0c0c0, // TABLEBOUNDARIES + 0, // FONTCOLOR + 0xcc, // LINKS + 0x80, // LINKSVISITED + 0, // ANCHOR + 0xff0000, // SPELL + COL_LIGHTMAGENTA,// SMARTTAGS + 0xc0c0c0, // WRITERTEXTGRID + 0xc0c0c0, // WRITERFIELDSHADIN + 0xc0c0c0, // WRITERIDXSHADINGS + 0, // WRITERDIRECTCURSOR + COL_GREEN, //WRITERSCRIPTINDICATOR + 0xc0c0c0, //WRITERSECTIONBOUNDARIES + COL_BLUE, //WRITERPAGEBREAKS, + COL_LIGHTBLUE, // HTMLSGML + COL_LIGHTGREEN, // HTMLCOMMENT + COL_LIGHTRED, // HTMLKEYWORD + COL_GRAY, // HTMLUNKNOWN + COL_LIGHTGRAY, // CALCGRID + COL_BLUE, //CALCPAGEBREAK + 0x2300dc, //CALCPAGEBREAKMANUAL + COL_GRAY, //CALCPAGEBREAKAUTOMATIC + COL_LIGHTBLUE, // CALCDETECTIVE + COL_LIGHTRED, // CALCDETECTIVEERROR + COL_LIGHTRED, // CALCREFERENCE + 0xffffc0, // CALCNOTESBACKGROUND + 0xc0c0c0, // DRAWGRID + 0, // DRAWDRAWING + 0xb8ff, // DRAWFILL + COL_GREEN, // BASICIDENTIFIER, + COL_GRAY,// BASICCOMMENT , + COL_LIGHTRED,// BASICNUMBER , + COL_LIGHTRED,// BASICSTRING , + COL_BLUE, // BASICOPERATOR , + COL_BLUE, // BASICKEYWORD , + COL_RED, //BASICERROR + 0x009900, // SQLIDENTIFIER + 0x000000, // SQLNUMBER + 0xCE7B00, // SQLSTRING + 0x000000, // SQLOPERATOR + 0x0000E6, // SQLKEYWORD + 0x259D9D, // SQLPARAMTER + 0x969696,// SQLCOMMENT + }; + Color aRet; + switch(eEntry) + { + case DOCCOLOR : + aRet = Application::GetSettings().GetStyleSettings().GetWindowColor(); + break; + + case APPBACKGROUND : + aRet = Application::GetSettings().GetStyleSettings().GetWorkspaceColor(); + break; + + case SPELL : + case DRAWDRAWING : + case SMARTTAGS : + { + const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings(); + aRet = rStyleSettings.GetHighContrastMode() ? + rStyleSettings.GetDialogTextColor().GetColor() : aAutoColors[eEntry]; + } + break; + + case DRAWFILL : + aRet = /*rStyleSettings.GetHighContrastMode() ? + rStyleSettings.OutlineMode??? : */ aAutoColors[eEntry]; + break; + + case FONTCOLOR : + aRet = Application::GetSettings().GetStyleSettings().GetWindowTextColor(); + break; + + case LINKS : + aRet = Application::GetSettings().GetStyleSettings().GetLinkColor(); + break; + + case LINKSVISITED : + aRet = Application::GetSettings().GetStyleSettings().GetVisitedLinkColor(); + break; + + default: + aRet = aAutoColors[eEntry]; + } + return aRet; +} +/* -----------------------------11.04.2002 11:49------------------------------ + + ---------------------------------------------------------------------------*/ +ColorConfigValue ColorConfig::GetColorValue(ColorConfigEntry eEntry, sal_Bool bSmart)const +{ + ColorConfigValue aRet = m_pImpl->GetColorConfigValue(eEntry); + if(bSmart) + { + if(COL_AUTO == sal::static_int_cast<ColorData>(aRet.nColor)) + aRet.nColor = ColorConfig::GetDefaultColor(eEntry).GetColor(); + //#103495# don't allow grey between 40% and 60% as application background + const UINT8 nRed = COLORDATA_RED( aRet.nColor); + if(eEntry == APPBACKGROUND && + (nRed == COLORDATA_GREEN( aRet.nColor)) && + (nRed == COLORDATA_BLUE( aRet.nColor)) && + nRed > 102 && nRed < 153 ) + { + aRet.nColor = RGB_COLORDATA(153, 153, 153); + } + } + + return aRet; +} +/* -----------------------------25.03.2002 12:01------------------------------ + + ---------------------------------------------------------------------------*/ +EditableColorConfig::EditableColorConfig() : + m_pImpl(new ColorConfig_Impl), + m_bModified(sal_False) +{ + m_pImpl->BlockBroadcasts(TRUE); +} +/*-- 25.03.2002 12:03:08--------------------------------------------------- + + -----------------------------------------------------------------------*/ +EditableColorConfig::~EditableColorConfig() +{ + m_pImpl->BlockBroadcasts(FALSE); + if(m_bModified) + m_pImpl->SetModified(); + if(m_pImpl->IsModified()) + m_pImpl->Commit(); + delete m_pImpl; +} + +/*-- 25.03.2002 12:03:15--------------------------------------------------- + + -----------------------------------------------------------------------*/ +uno::Sequence< ::rtl::OUString > EditableColorConfig::GetSchemeNames() const +{ + return m_pImpl->GetSchemeNames(); +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void EditableColorConfig::DeleteScheme(const ::rtl::OUString& rScheme ) +{ + m_pImpl->RemoveScheme(rScheme); +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void EditableColorConfig::AddScheme(const ::rtl::OUString& rScheme ) +{ + m_pImpl->AddScheme(rScheme); +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool EditableColorConfig::LoadScheme(const ::rtl::OUString& rScheme ) +{ + if(m_bModified) + m_pImpl->SetModified(); + if(m_pImpl->IsModified()) + m_pImpl->Commit(); + m_bModified = sal_False; + m_pImpl->Load(rScheme); + //the name of the loaded scheme has to be committed separately + m_pImpl->CommitCurrentSchemeName(); + return sal_True; +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const ::rtl::OUString& EditableColorConfig::GetCurrentSchemeName()const +{ + return m_pImpl->GetLoadedScheme(); +} +/* -----------------11.12.2002 10:56----------------- + * changes the name of the current scheme but doesn't load it! + * --------------------------------------------------*/ +void EditableColorConfig::SetCurrentSchemeName(const ::rtl::OUString& rScheme) +{ + m_pImpl->SetCurrentSchemeName(rScheme); + m_pImpl->CommitCurrentSchemeName(); +} +/*-- 25.03.2002 12:03:17--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const ColorConfigValue& EditableColorConfig::GetColorValue( + ColorConfigEntry eEntry)const +{ + return m_pImpl->GetColorConfigValue(eEntry); +} +/*-- 25.03.2002 12:03:17--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void EditableColorConfig::SetColorValue( + ColorConfigEntry eEntry, const ColorConfigValue& rValue) +{ + m_pImpl->SetColorConfigValue(eEntry, rValue); + m_pImpl->ClearModified(); + m_bModified = sal_True; +} +/* -----------------------------10.04.2002 13:22------------------------------ + + ---------------------------------------------------------------------------*/ +void EditableColorConfig::SetModified() +{ + m_bModified = sal_True; +} +/* -----------------15.10.2002 14:51----------------- + * + * --------------------------------------------------*/ +void EditableColorConfig::Commit() +{ + if(m_bModified) + m_pImpl->SetModified(); + if(m_pImpl->IsModified()) + m_pImpl->Commit(); + m_bModified = sal_False; +} +// ----------------------------------------------------------------------------- +void EditableColorConfig::DisableBroadcast() +{ + m_pImpl->BlockBroadcasts(TRUE); +} +// ----------------------------------------------------------------------------- +void EditableColorConfig::EnableBroadcast() +{ + m_pImpl->BlockBroadcasts(FALSE); +} +// ----------------------------------------------------------------------------- + +}//namespace svtools diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx new file mode 100644 index 000000000000..993025b22884 --- /dev/null +++ b/svtools/source/config/extcolorcfg.cxx @@ -0,0 +1,827 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "extcolorcfg.hxx" +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <com/sun/star/lang/Locale.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <tools/color.hxx> +#include <tools/debug.hxx> +#include <unotools/configitem.hxx> +#include <unotools/configpathes.hxx> +#include <com/sun/star/uno/Sequence.h> +#include <svl/poolitem.hxx> //Any2Bool +#include <svl/smplhint.hxx> +#include <vos/mutex.hxx> + + /* #100822# ---- +#include <vcl/wrkwin.hxx> + ------------- */ +#include <vcl/svapp.hxx> +#include <vcl/event.hxx> +#include <rtl/instance.hxx> +#include <rtl/strbuf.hxx> +#include <comphelper/stl_types.hxx> + + +//----------------------------------------------------------------------------- +using namespace utl; +using namespace rtl; +using namespace com::sun::star; + +namespace svtools +{ + +#define C2U(cChar) OUString::createFromAscii(cChar) +sal_Int32 nExtendedColorRefCount_Impl = 0; +namespace +{ + struct ColorMutex_Impl + : public rtl::Static< ::osl::Mutex, ColorMutex_Impl > {}; +} + +ExtendedColorConfig_Impl* ExtendedColorConfig::m_pImpl = NULL; + +/* -----------------------------16.01.01 15:36-------------------------------- + ---------------------------------------------------------------------------*/ +class ExtendedColorConfig_Impl : public utl::ConfigItem, public SfxBroadcaster +{ + DECLARE_STL_USTRINGACCESS_MAP( ::rtl::OUString, TDisplayNames); + DECLARE_STL_USTRINGACCESS_MAP(ExtendedColorConfigValue,TConfigValues); + typedef ::std::vector<TConfigValues::iterator> TMapPos; + typedef ::std::pair< TConfigValues, TMapPos > TComponentMapping; + DECLARE_STL_USTRINGACCESS_MAP(TComponentMapping,TComponents); + TComponents m_aConfigValues; + TDisplayNames m_aComponentDisplayNames; + ::std::vector<TComponents::iterator> m_aConfigValuesPos; + + sal_Bool m_bEditMode; + rtl::OUString m_sLoadedScheme; + sal_Bool m_bIsBroadcastEnabled; + static sal_Bool m_bLockBroadcast; + static sal_Bool m_bBroadcastWhenUnlocked; + + uno::Sequence< ::rtl::OUString> GetPropertyNames(const rtl::OUString& rScheme); + void FillComponentColors(uno::Sequence < ::rtl::OUString >& _rComponents,const TDisplayNames& _rDisplayNames); +public: + ExtendedColorConfig_Impl(sal_Bool bEditMode = sal_False); + virtual ~ExtendedColorConfig_Impl(); + + void Load(const rtl::OUString& rScheme); + void CommitCurrentSchemeName(); + //changes the name of the current scheme but doesn't load it! + void SetCurrentSchemeName(const rtl::OUString& rSchemeName) {m_sLoadedScheme = rSchemeName;} + sal_Bool ExistsScheme(const ::rtl::OUString& _sSchemeName); + virtual void Commit(); + virtual void Notify( const uno::Sequence<rtl::OUString>& aPropertyNames); + + sal_Int32 GetComponentCount() const; + ::rtl::OUString GetComponentName(sal_uInt32 _nPos) const; + ::rtl::OUString GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const; + sal_Int32 GetComponentColorCount(const ::rtl::OUString& _sName) const; + ExtendedColorConfigValue GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const; + + ExtendedColorConfigValue GetColorConfigValue(const ::rtl::OUString& _sComponentName,const ::rtl::OUString& _sName) + { + TComponents::iterator aFind = m_aConfigValues.find(_sComponentName); + if ( aFind != m_aConfigValues.end() ) + { + TConfigValues::iterator aFind2 = aFind->second.first.find(_sName); + if ( aFind2 != aFind->second.first.end() ) + return aFind2->second; + } +#if OSL_DEBUG_LEVEL > 0 + ::rtl::OStringBuffer aMessage( "Could find the required config:\n" ); + aMessage.append( "component: " ); + aMessage.append( ::rtl::OUStringToOString( _sComponentName, RTL_TEXTENCODING_UTF8 ) ); + aMessage.append( "\nname: " ); + aMessage.append( ::rtl::OUStringToOString( _sName, RTL_TEXTENCODING_UTF8 ) ); + OSL_ENSURE( 0, aMessage.makeStringAndClear().getStr() ); +#endif + return ExtendedColorConfigValue(); + } + void SetColorConfigValue(const ::rtl::OUString& _sName, + const ExtendedColorConfigValue& rValue ); + + const rtl::OUString& GetLoadedScheme() const {return m_sLoadedScheme;} + + uno::Sequence< ::rtl::OUString> GetSchemeNames(); + + sal_Bool AddScheme(const rtl::OUString& rNode); + sal_Bool RemoveScheme(const rtl::OUString& rNode); + void SetModified(){ConfigItem::SetModified();} + void ClearModified(){ConfigItem::ClearModified();} + void SettingsChanged(); + + static void DisableBroadcast(); + static void EnableBroadcast(); + static sal_Bool IsEnableBroadcast(); + + static void LockBroadcast(); + static void UnlockBroadcast(); + + // #100822# + DECL_LINK( DataChangedEventListener, VclWindowEvent* ); +}; + +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Sequence< OUString> ExtendedColorConfig_Impl::GetPropertyNames(const rtl::OUString& rScheme) +{ + uno::Sequence< OUString> aNames(GetNodeNames(rScheme)); + ::rtl::OUString* pIter = aNames.getArray(); + ::rtl::OUString* pEnd = pIter + aNames.getLength(); + ::rtl::OUString sSep(RTL_CONSTASCII_USTRINGPARAM("/")); + for(;pIter != pEnd;++pIter) + { + *pIter = rScheme + sSep + *pIter; + } + return aNames; +} +// ----------------------------------------------------------------------------- +sal_Int32 ExtendedColorConfig_Impl::GetComponentCount() const +{ + return m_aConfigValues.size(); +} +// ----------------------------------------------------------------------------- +sal_Int32 ExtendedColorConfig_Impl::GetComponentColorCount(const ::rtl::OUString& _sName) const +{ + sal_Int32 nSize = 0; + TComponents::const_iterator aFind = m_aConfigValues.find(_sName); + if ( aFind != m_aConfigValues.end() ) + { + nSize = aFind->second.first.size(); + } + return nSize; +} +// ----------------------------------------------------------------------------- +ExtendedColorConfigValue ExtendedColorConfig_Impl::GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const +{ + TComponents::const_iterator aFind = m_aConfigValues.find(_sName); + if ( aFind != m_aConfigValues.end() ) + { + if ( _nPos < aFind->second.second.size() ) + { + return aFind->second.second[_nPos]->second; + } + } + return ExtendedColorConfigValue(); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ExtendedColorConfig_Impl::GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const +{ + ::rtl::OUString sRet; + TDisplayNames::const_iterator aFind = m_aComponentDisplayNames.find(_sComponentName); + if ( aFind != m_aComponentDisplayNames.end() ) + sRet = aFind->second; + return sRet; +} +// ----------------------------------------------------------------------------- +::rtl::OUString ExtendedColorConfig_Impl::GetComponentName(sal_uInt32 _nPos) const +{ + ::rtl::OUString sRet; + if ( _nPos < m_aConfigValuesPos.size() ) + sRet = m_aConfigValuesPos[_nPos]->first; + return sRet; +} +// ----------------------------------------------------------------------------- +/* -----------------------------22.03.2002 14:37------------------------------ + + ---------------------------------------------------------------------------*/ +sal_Bool ExtendedColorConfig_Impl::m_bLockBroadcast = sal_False; +sal_Bool ExtendedColorConfig_Impl::m_bBroadcastWhenUnlocked = sal_False; +ExtendedColorConfig_Impl::ExtendedColorConfig_Impl(sal_Bool bEditMode) : + ConfigItem(C2U("Office.ExtendedColorScheme")), + m_bEditMode(bEditMode), + m_bIsBroadcastEnabled(sal_True) +{ + if(!m_bEditMode) + { + //try to register on the root node - if possible + uno::Sequence < ::rtl::OUString > aNames(1); + EnableNotification( aNames ); + } + Load(::rtl::OUString()); + + // #100822# + ::Application::AddEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) ); + +} +/* -----------------------------25.03.2002 12:28------------------------------ + + ---------------------------------------------------------------------------*/ +ExtendedColorConfig_Impl::~ExtendedColorConfig_Impl() +{ + // #100822# + ::Application::RemoveEventListener( LINK(this, ExtendedColorConfig_Impl, DataChangedEventListener) ); +} +// ----------------------------------------------------------------------------- +void ExtendedColorConfig_Impl::DisableBroadcast() +{ + if ( ExtendedColorConfig::m_pImpl ) + ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = sal_False; +} +// ----------------------------------------------------------------------------- +void ExtendedColorConfig_Impl::EnableBroadcast() +{ + if ( ExtendedColorConfig::m_pImpl ) + ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled = sal_True; +} +// ----------------------------------------------------------------------------- +sal_Bool ExtendedColorConfig_Impl::IsEnableBroadcast() +{ + return ExtendedColorConfig::m_pImpl ? ExtendedColorConfig::m_pImpl->m_bIsBroadcastEnabled : sal_False; +} +/* -----------------------------22.03.2002 14:38------------------------------ + + ---------------------------------------------------------------------------*/ +void lcl_addString(uno::Sequence < ::rtl::OUString >& _rSeq,const ::rtl::OUString& _sAdd) +{ + ::rtl::OUString* pIter = _rSeq.getArray(); + ::rtl::OUString* pEnd = pIter + _rSeq.getLength(); + for(;pIter != pEnd;++pIter) + *pIter += _sAdd; +} +// ----------------------------------------------------------------------------- +void ExtendedColorConfig_Impl::Load(const rtl::OUString& rScheme) +{ + m_aComponentDisplayNames.clear(); + m_aConfigValuesPos.clear(); + m_aConfigValues.clear(); + + // fill display names + TDisplayNames aDisplayNameMap; + ::rtl::OUString sEntryNames(RTL_CONSTASCII_USTRINGPARAM("EntryNames")); + uno::Sequence < ::rtl::OUString > aComponentNames = GetPropertyNames(sEntryNames); + ::rtl::OUString sDisplayName(RTL_CONSTASCII_USTRINGPARAM("/DisplayName")); + ::rtl::OUString* pIter = aComponentNames.getArray(); + ::rtl::OUString* pEnd = pIter + aComponentNames.getLength(); + for(sal_Int32 i = 0;pIter != pEnd;++pIter,++i) + { + uno::Sequence < ::rtl::OUString > aComponentDisplayNames(1); + aComponentDisplayNames[0] = *pIter; + aComponentDisplayNames[0] += sDisplayName; + uno::Sequence< uno::Any > aComponentDisplayNamesValue = GetProperties( aComponentDisplayNames ); + ::rtl::OUString sComponentDisplayName; + if ( aComponentDisplayNamesValue.getLength() && (aComponentDisplayNamesValue[0] >>= sComponentDisplayName) ) + { + sal_Int32 nIndex = 0; + m_aComponentDisplayNames.insert(TDisplayNames::value_type(pIter->getToken(1,'/',nIndex),sComponentDisplayName)); + } + + *pIter += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/Entries")); + uno::Sequence < ::rtl::OUString > aDisplayNames = GetPropertyNames(*pIter); + lcl_addString(aDisplayNames,sDisplayName); + + uno::Sequence< uno::Any > aDisplayNamesValue = GetProperties( aDisplayNames ); + + const ::rtl::OUString* pDispIter = aDisplayNames.getConstArray(); + const ::rtl::OUString* pDispEnd = pDispIter + aDisplayNames.getLength(); + for(sal_Int32 j = 0;pDispIter != pDispEnd;++pDispIter,++j) + { + sal_Int32 nIndex = 0; + pDispIter->getToken(0,'/',nIndex); + ::rtl::OUString sName = pDispIter->copy(nIndex); + sName = sName.copy(0,sName.lastIndexOf(sDisplayName)); + ::rtl::OUString sCurrentDisplayName; + aDisplayNamesValue[j] >>= sCurrentDisplayName; + aDisplayNameMap.insert(TDisplayNames::value_type(sName,sCurrentDisplayName)); + } + } + + // load color settings + rtl::OUString sScheme(rScheme); + + if(!sScheme.getLength()) + { + //detect current scheme name + uno::Sequence < ::rtl::OUString > aCurrent(1); + aCurrent.getArray()[0] = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/CurrentColorScheme")); + uno::Sequence< uno::Any > aCurrentVal = GetProperties( aCurrent ); + aCurrentVal.getConstArray()[0] >>= sScheme; + } // if(!sScheme.getLength()) + + m_sLoadedScheme = sScheme; + ::rtl::OUString sBase(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/")); + sBase += sScheme; + + sal_Bool bFound = ExistsScheme(sScheme); + if ( bFound ) + { + aComponentNames = GetPropertyNames(sBase); + FillComponentColors(aComponentNames,aDisplayNameMap); + } // if ( bFound ) + + if ( !m_sLoadedScheme.getLength() ) + m_sLoadedScheme = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("default")); + + if ( !sScheme.equalsAscii("default") ) + { + ::rtl::OUString sDefault(RTL_CONSTASCII_USTRINGPARAM("default")); + if ( ExistsScheme(sDefault) ) + { + ::rtl::OUString sBaseDefault(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/default")); + aComponentNames = GetPropertyNames(sBaseDefault); + FillComponentColors(aComponentNames,aDisplayNameMap); + } + } // if ( !sScheme.equalsAscii("default") ) + if ( !bFound && sScheme.getLength() ) + { + AddScheme(sScheme); + CommitCurrentSchemeName(); + } +} +// ----------------------------------------------------------------------------- +void ExtendedColorConfig_Impl::FillComponentColors(uno::Sequence < ::rtl::OUString >& _rComponents,const TDisplayNames& _rDisplayNames) +{ + const ::rtl::OUString sColorEntries(RTL_CONSTASCII_USTRINGPARAM("/Entries")); + ::rtl::OUString* pIter = _rComponents.getArray(); + ::rtl::OUString* pEnd = pIter + _rComponents.getLength(); + for(;pIter != pEnd;++pIter) + { + ::rtl::OUString sComponentName = pIter->copy(pIter->lastIndexOf('/')+1); + if ( m_aConfigValues.find(sComponentName) == m_aConfigValues.end() ) + { + ::rtl::OUString sEntry = *pIter; + sEntry += sColorEntries; + + uno::Sequence < ::rtl::OUString > aColorNames = GetPropertyNames(sEntry); + uno::Sequence < ::rtl::OUString > aDefaultColorNames = aColorNames; + + const ::rtl::OUString sColor(RTL_CONSTASCII_USTRINGPARAM("/Color")); + const ::rtl::OUString sDefaultColor(RTL_CONSTASCII_USTRINGPARAM("/DefaultColor")); + lcl_addString(aColorNames,sColor); + lcl_addString(aDefaultColorNames,sDefaultColor); + uno::Sequence< uno::Any > aColors = GetProperties( aColorNames ); + const uno::Any* pColors = aColors.getConstArray(); + + uno::Sequence< uno::Any > aDefaultColors = GetProperties( aDefaultColorNames ); + bool bDefaultColorFound = aDefaultColors.getLength() != 0; + const uno::Any* pDefaultColors = aDefaultColors.getConstArray(); + + ::rtl::OUString* pColorIter = aColorNames.getArray(); + ::rtl::OUString* pColorEnd = pColorIter + aColorNames.getLength(); + + m_aConfigValuesPos.push_back(m_aConfigValues.insert(TComponents::value_type(sComponentName,TComponentMapping(TConfigValues(),TMapPos()))).first); + TConfigValues& aConfigValues = (*m_aConfigValuesPos.rbegin())->second.first; + TMapPos& aConfigValuesPos = (*m_aConfigValuesPos.rbegin())->second.second; + for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i) + { + if ( aConfigValues.find(*pColorIter) == aConfigValues.end() ) + { + sal_Int32 nIndex = 0; + pColorIter->getToken(2,'/',nIndex); + ::rtl::OUString sName(pColorIter->copy(nIndex)),sDisplayName; + ::rtl::OUString sTemp = sName.copy(0,sName.lastIndexOf(sColor)); + + TDisplayNames::const_iterator aFind = _rDisplayNames.find(sTemp); + nIndex = 0; + sName = sName.getToken(2,'/',nIndex); + OSL_ENSURE(aFind != _rDisplayNames.end(),"DisplayName is not in EntryNames config list!"); + if ( aFind != _rDisplayNames.end() ) + sDisplayName = aFind->second; + + OSL_ENSURE(pColors[i].hasValue(),"Color config entry has NIL as color value set!"); + OSL_ENSURE(pDefaultColors[i].hasValue(),"Color config entry has NIL as color value set!"); + sal_Int32 nColor = 0,nDefaultColor = 0; + pColors[i] >>= nColor; + if ( bDefaultColorFound ) + pDefaultColors[i] >>= nDefaultColor; + else + nDefaultColor = nColor; + ExtendedColorConfigValue aValue(sName,sDisplayName,nColor,nDefaultColor); + aConfigValuesPos.push_back(aConfigValues.insert(TConfigValues::value_type(sName,aValue)).first); + } + } // for(int i = 0; pColorIter != pColorEnd; ++pColorIter ,++i) + } + } +} +/* -----------------------------22.03.2002 14:38------------------------------ + + ---------------------------------------------------------------------------*/ +void ExtendedColorConfig_Impl::Notify( const uno::Sequence<OUString>& /*rPropertyNames*/) +{ + //loading via notification always uses the default setting + Load(::rtl::OUString()); + + vos::OGuard aVclGuard( Application::GetSolarMutex() ); + + if(m_bLockBroadcast) + { + m_bBroadcastWhenUnlocked = sal_True; + } + else + Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED)); +} +/* -----------------------------22.03.2002 14:38------------------------------ + + ---------------------------------------------------------------------------*/ +void ExtendedColorConfig_Impl::Commit() +{ + if ( !m_sLoadedScheme.getLength() ) + return; + const ::rtl::OUString sColorEntries(RTL_CONSTASCII_USTRINGPARAM("Entries")); + const ::rtl::OUString sColor(RTL_CONSTASCII_USTRINGPARAM("/Color")); + const ::rtl::OUString sDefaultColor(RTL_CONSTASCII_USTRINGPARAM("/DefaultColor")); + ::rtl::OUString sBase(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/")); + const ::rtl::OUString s_sSep(RTL_CONSTASCII_USTRINGPARAM("/")); + sBase += m_sLoadedScheme; + + TComponents::iterator aIter = m_aConfigValues.begin(); + TComponents::iterator aEnd = m_aConfigValues.end(); + for( ;aIter != aEnd;++aIter ) + { + ::rtl::OUString sEntry = aIter->first; + sEntry += sColorEntries; + + if ( ConfigItem::AddNode(sBase, aIter->first) ) + { + rtl::OUString sNode = sBase; + sNode += s_sSep; + sNode += aIter->first; + //ConfigItem::AddNode(sNode, sColorEntries); + sNode += s_sSep; + sNode += sColorEntries; + + uno::Sequence < beans::PropertyValue > aPropValues(aIter->second.first.size()); + beans::PropertyValue* pPropValues = aPropValues.getArray(); + TConfigValues::iterator aConIter = aIter->second.first.begin(); + TConfigValues::iterator aConEnd = aIter->second.first.end(); + for (; aConIter != aConEnd; ++aConIter,++pPropValues) + { + pPropValues->Name = sNode + s_sSep + aConIter->first; + ConfigItem::AddNode(sNode, aConIter->first); + pPropValues->Name += sColor; + pPropValues->Value <<= aConIter->second.getColor(); + // the default color will never be changed + } + ::rtl::OUString s(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes")); + SetSetProperties(s, aPropValues); + } + } + + CommitCurrentSchemeName(); +} +/* -----------------11.12.2002 10:42----------------- + * + * --------------------------------------------------*/ +void ExtendedColorConfig_Impl::CommitCurrentSchemeName() +{ + //save current scheme name + uno::Sequence < ::rtl::OUString > aCurrent(1); + aCurrent.getArray()[0] = C2U("ExtendedColorScheme/CurrentColorScheme"); + uno::Sequence< uno::Any > aCurrentVal(1); + aCurrentVal.getArray()[0] <<= m_sLoadedScheme; + PutProperties(aCurrent, aCurrentVal); +} +// ----------------------------------------------------------------------------- +sal_Bool ExtendedColorConfig_Impl::ExistsScheme(const ::rtl::OUString& _sSchemeName) +{ + ::rtl::OUString sBase(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes")); + + uno::Sequence < ::rtl::OUString > aComponentNames = GetPropertyNames(sBase); + sBase += ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")) + _sSchemeName; + const ::rtl::OUString* pCompIter = aComponentNames.getConstArray(); + const ::rtl::OUString* pCompEnd = pCompIter + aComponentNames.getLength(); + for(;pCompIter != pCompEnd && *pCompIter != sBase;++pCompIter) + ; + return pCompIter != pCompEnd; +} +// ----------------------------------------------------------------------------- +/* -----------------------------25.03.2002 12:19------------------------------ + + ---------------------------------------------------------------------------*/ +void ExtendedColorConfig_Impl::SetColorConfigValue(const ::rtl::OUString& _sName, const ExtendedColorConfigValue& rValue ) +{ + TComponents::iterator aFind = m_aConfigValues.find(_sName); + if ( aFind != m_aConfigValues.end() ) + { + TConfigValues::iterator aFind2 = aFind->second.first.find(rValue.getName()); + if ( aFind2 != aFind->second.first.end() ) + aFind2->second = rValue; + SetModified(); + } +} +/* -----------------------------25.03.2002 15:22------------------------------ + + ---------------------------------------------------------------------------*/ +uno::Sequence< ::rtl::OUString> ExtendedColorConfig_Impl::GetSchemeNames() +{ + return GetNodeNames(C2U("ExtendedColorScheme/ColorSchemes")); +} +/* -----------------------------09.04.2002 17:19------------------------------ + + ---------------------------------------------------------------------------*/ +sal_Bool ExtendedColorConfig_Impl::AddScheme(const rtl::OUString& rScheme) +{ + if(ConfigItem::AddNode(C2U("ExtendedColorScheme/ColorSchemes"), rScheme)) + { + m_sLoadedScheme = rScheme; + Commit(); + return sal_True; + } + return sal_False; +} +/* -----------------------------09.04.2002 17:19------------------------------ + + ---------------------------------------------------------------------------*/ +sal_Bool ExtendedColorConfig_Impl::RemoveScheme(const rtl::OUString& rScheme) +{ + uno::Sequence< rtl::OUString > aElements(1); + aElements.getArray()[0] = rScheme; + return ClearNodeElements(C2U("ExtendedColorScheme/ColorSchemes"), aElements); +} +/* -----------------------------2002/06/20 13:03------------------------------ + + ---------------------------------------------------------------------------*/ +void ExtendedColorConfig_Impl::SettingsChanged() +{ + vos::OGuard aVclGuard( Application::GetSolarMutex() ); + + Broadcast( SfxSimpleHint( SFX_HINT_COLORS_CHANGED ) ); +} +/* -----------------11.12.2002 09:21----------------- + * + * --------------------------------------------------*/ +void ExtendedColorConfig_Impl::LockBroadcast() +{ + m_bLockBroadcast = sal_True; +} +/* -----------------11.12.2002 09:21----------------- + * + * --------------------------------------------------*/ +void ExtendedColorConfig_Impl::UnlockBroadcast() +{ + if ( m_bBroadcastWhenUnlocked ) + { + m_bBroadcastWhenUnlocked = ExtendedColorConfig::m_pImpl != NULL; + if ( m_bBroadcastWhenUnlocked ) + { + if ( ExtendedColorConfig::m_pImpl->IsEnableBroadcast() ) + { + m_bBroadcastWhenUnlocked = sal_False; + ExtendedColorConfig::m_pImpl->Broadcast(SfxSimpleHint(SFX_HINT_COLORS_CHANGED)); + } + } + } + m_bLockBroadcast = sal_False; +} +/* -----------------------------2002/08/16 12:07 ----------------------------- + #100822# + --------------------------------------------------------------------------- */ +IMPL_LINK( ExtendedColorConfig_Impl, DataChangedEventListener, VclWindowEvent*, pEvent ) +{ + if ( pEvent->GetId() == VCLEVENT_APPLICATION_DATACHANGED ) + { + DataChangedEvent* pData = (DataChangedEvent*)(pEvent->GetData()); + if ( (pData->GetType() == DATACHANGED_SETTINGS) && + (pData->GetFlags() & SETTINGS_STYLE) ) + { + SettingsChanged(); + return 1L; + } else + return 0L; + } else + return 0L; +} + +// --------------------------------------------------------------------------- + +// --------------------------------------------------------------------------- + +ExtendedColorConfig::ExtendedColorConfig() +{ + ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + if ( !m_pImpl ) + m_pImpl = new ExtendedColorConfig_Impl; + ++nExtendedColorRefCount_Impl; + StartListening( *m_pImpl); +} +/* -----------------------------16.01.01 15:36-------------------------------- + + ---------------------------------------------------------------------------*/ +ExtendedColorConfig::~ExtendedColorConfig() +{ + ::osl::MutexGuard aGuard( ColorMutex_Impl::get() ); + EndListening( *m_pImpl); + if(!--nExtendedColorRefCount_Impl) + { + delete m_pImpl; + m_pImpl = 0; + } +} +/* -----------------------------11.04.2002 11:49------------------------------ + + ---------------------------------------------------------------------------*/ +ExtendedColorConfigValue ExtendedColorConfig::GetColorValue(const ::rtl::OUString& _sComponentName,const ::rtl::OUString& _sName)const +{ + return m_pImpl->GetColorConfigValue(_sComponentName,_sName); +} +// ----------------------------------------------------------------------------- +sal_Int32 ExtendedColorConfig::GetComponentCount() const +{ + return m_pImpl->GetComponentCount(); +} +// ----------------------------------------------------------------------------- +sal_Int32 ExtendedColorConfig::GetComponentColorCount(const ::rtl::OUString& _sName) const +{ + return m_pImpl->GetComponentColorCount(_sName); +} +// ----------------------------------------------------------------------------- +ExtendedColorConfigValue ExtendedColorConfig::GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const +{ + return m_pImpl->GetComponentColorConfigValue(_sName,_nPos); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const +{ + return m_pImpl->GetComponentName(_nPos); +} +// ----------------------------------------------------------------------------- +::rtl::OUString ExtendedColorConfig::GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const +{ + return m_pImpl->GetComponentDisplayName(_sComponentName); +} +// ----------------------------------------------------------------------------- +/* -----------------------------12.04.2002 09:25------------------------------ + + ---------------------------------------------------------------------------*/ +void ExtendedColorConfig::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) +{ + vos::OGuard aVclGuard( Application::GetSolarMutex() ); + + Broadcast( rHint ); +} +/* -----------------------------25.03.2002 12:01------------------------------ + + ---------------------------------------------------------------------------*/ +EditableExtendedColorConfig::EditableExtendedColorConfig() : + m_pImpl(new ExtendedColorConfig_Impl), + m_bModified(sal_False) +{ + m_pImpl->LockBroadcast(); +} +/*-- 25.03.2002 12:03:08--------------------------------------------------- + + -----------------------------------------------------------------------*/ +EditableExtendedColorConfig::~EditableExtendedColorConfig() +{ + m_pImpl->UnlockBroadcast(); + if(m_bModified) + m_pImpl->SetModified(); + if(m_pImpl->IsModified()) + m_pImpl->Commit(); + delete m_pImpl; +} + +/*-- 25.03.2002 12:03:15--------------------------------------------------- + + -----------------------------------------------------------------------*/ +uno::Sequence< ::rtl::OUString > EditableExtendedColorConfig::GetSchemeNames() const +{ + return m_pImpl->GetSchemeNames(); +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void EditableExtendedColorConfig::DeleteScheme(const ::rtl::OUString& rScheme ) +{ + m_pImpl->RemoveScheme(rScheme); +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void EditableExtendedColorConfig::AddScheme(const ::rtl::OUString& rScheme ) +{ + m_pImpl->AddScheme(rScheme); +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Bool EditableExtendedColorConfig::LoadScheme(const ::rtl::OUString& rScheme ) +{ + if(m_bModified) + m_pImpl->SetModified(); + if(m_pImpl->IsModified()) + m_pImpl->Commit(); + m_bModified = sal_False; + m_pImpl->Load(rScheme); + //the name of the loaded scheme has to be committed separately + m_pImpl->CommitCurrentSchemeName(); + return sal_True; +} +/*-- 25.03.2002 12:03:16--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const ::rtl::OUString& EditableExtendedColorConfig::GetCurrentSchemeName()const +{ + return m_pImpl->GetLoadedScheme(); +} +/* -----------------11.12.2002 10:56----------------- + * changes the name of the current scheme but doesn't load it! + * --------------------------------------------------*/ +void EditableExtendedColorConfig::SetCurrentSchemeName(const ::rtl::OUString& rScheme) +{ + m_pImpl->SetCurrentSchemeName(rScheme); + m_pImpl->CommitCurrentSchemeName(); +} +/*-- 25.03.2002 12:03:17--------------------------------------------------- + + -----------------------------------------------------------------------*/ +ExtendedColorConfigValue EditableExtendedColorConfig::GetColorValue(const ::rtl::OUString& _sComponentName, + const ::rtl::OUString& _sName)const +{ + return m_pImpl->GetColorConfigValue(_sComponentName,_sName); +} +/*-- 25.03.2002 12:03:17--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void EditableExtendedColorConfig::SetColorValue( + const ::rtl::OUString& _sName, const ExtendedColorConfigValue& rValue) +{ + m_pImpl->SetColorConfigValue(_sName, rValue); + m_pImpl->ClearModified(); + m_bModified = sal_True; +} +/* -----------------------------10.04.2002 13:22------------------------------ + + ---------------------------------------------------------------------------*/ +void EditableExtendedColorConfig::SetModified() +{ + m_bModified = sal_True; +} +/* -----------------15.10.2002 14:51----------------- + * + * --------------------------------------------------*/ +void EditableExtendedColorConfig::Commit() +{ + if(m_bModified) + m_pImpl->SetModified(); + if(m_pImpl->IsModified()) + m_pImpl->Commit(); + m_bModified = sal_False; +} +// ----------------------------------------------------------------------------- +void EditableExtendedColorConfig::DisableBroadcast() +{ + m_pImpl->DisableBroadcast(); +} +// ----------------------------------------------------------------------------- +void EditableExtendedColorConfig::EnableBroadcast() +{ + m_pImpl->EnableBroadcast(); +} +// ----------------------------------------------------------------------------- +sal_Int32 EditableExtendedColorConfig::GetComponentCount() const +{ + return m_pImpl->GetComponentCount(); +} +// ----------------------------------------------------------------------------- +sal_Int32 EditableExtendedColorConfig::GetComponentColorCount(const ::rtl::OUString& _sName) const +{ + return m_pImpl->GetComponentColorCount(_sName); +} +// ----------------------------------------------------------------------------- +ExtendedColorConfigValue EditableExtendedColorConfig::GetComponentColorConfigValue(const ::rtl::OUString& _sName,sal_uInt32 _nPos) const +{ + return m_pImpl->GetComponentColorConfigValue(_sName,_nPos); +} +// ----------------------------------------------------------------------------- +::rtl::OUString EditableExtendedColorConfig::GetComponentName(sal_uInt32 _nPos) const +{ + return m_pImpl->GetComponentName(_nPos); +} +// ----------------------------------------------------------------------------- +::rtl::OUString EditableExtendedColorConfig::GetComponentDisplayName(const ::rtl::OUString& _sComponentName) const +{ + return m_pImpl->GetComponentDisplayName(_sComponentName); +} +}//namespace svtools diff --git a/svtools/source/config/fontsubstconfig.cxx b/svtools/source/config/fontsubstconfig.cxx new file mode 100644 index 000000000000..7bcbc1e4be82 --- /dev/null +++ b/svtools/source/config/fontsubstconfig.cxx @@ -0,0 +1,229 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "fontsubstconfig.hxx" +#include <svl/svarray.hxx> +#include <com/sun/star/beans/PropertyValue.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> +#include <tools/debug.hxx> + +#include <vcl/outdev.hxx> +#include <rtl/logfile.hxx> + +using namespace utl; +using namespace rtl; +using namespace com::sun::star; +using namespace com::sun::star::uno; +using namespace com::sun::star::beans; + +#define C2U(cChar) OUString::createFromAscii(cChar) + +const sal_Char cReplacement[] = "Replacement"; +const sal_Char cFontPairs[] = "FontPairs"; + +const sal_Char cReplaceFont[] = "ReplaceFont"; +const sal_Char cSubstituteFont[]= "SubstituteFont"; +const sal_Char cOnScreenOnly[] = "OnScreenOnly"; +const sal_Char cAlways[] = "Always"; + +//----------------------------------------------------------------------------- +typedef SubstitutionStruct* SubstitutionStructPtr; +SV_DECL_PTRARR_DEL(SubstitutionStructArr, SubstitutionStructPtr, 2, 2) +SV_IMPL_PTRARR(SubstitutionStructArr, SubstitutionStructPtr); +//----------------------------------------------------------------------------- +struct SvtFontSubstConfig_Impl +{ + SubstitutionStructArr aSubstArr; +}; +/* -----------------------------18.01.01 12:04-------------------------------- + + ---------------------------------------------------------------------------*/ +SvtFontSubstConfig::SvtFontSubstConfig() : + ConfigItem(C2U("Office.Common/Font/Substitution")), + bIsEnabled(sal_False), + pImpl(new SvtFontSubstConfig_Impl) +{ + RTL_LOGFILE_CONTEXT(aLog, "svtools SvtFontSubstConfig::SvtFontSubstConfig()"); + + Sequence<OUString> aNames(1); + aNames.getArray()[0] = C2U(cReplacement); + Sequence<Any> aValues = GetProperties(aNames); + DBG_ASSERT(aValues.getConstArray()[0].hasValue(), "no value available"); + if(aValues.getConstArray()[0].hasValue()) + bIsEnabled = *(sal_Bool*)aValues.getConstArray()[0].getValue(); + + OUString sPropPrefix(C2U(cFontPairs)); + Sequence<OUString> aNodeNames = GetNodeNames(sPropPrefix, CONFIG_NAME_LOCAL_PATH); + const OUString* pNodeNames = aNodeNames.getConstArray(); + Sequence<OUString> aPropNames(aNodeNames.getLength() * 4); + OUString* pNames = aPropNames.getArray(); + sal_Int32 nName = 0; + sPropPrefix += C2U("/"); + sal_Int32 nNode; + for(nNode = 0; nNode < aNodeNames.getLength(); nNode++) + { + OUString sStart(sPropPrefix); + sStart += pNodeNames[nNode]; + sStart += C2U("/"); + pNames[nName] = sStart; pNames[nName++] += C2U(cReplaceFont); + pNames[nName] = sStart; pNames[nName++] += C2U(cSubstituteFont); + pNames[nName] = sStart; pNames[nName++] += C2U(cAlways); + pNames[nName] = sStart; pNames[nName++] += C2U(cOnScreenOnly); + } + Sequence<Any> aNodeValues = GetProperties(aPropNames); + const Any* pNodeValues = aNodeValues.getConstArray(); + nName = 0; + for(nNode = 0; nNode < aNodeNames.getLength(); nNode++) + { + SubstitutionStructPtr pInsert = new SubstitutionStruct; + pNodeValues[nName++] >>= pInsert->sFont; + pNodeValues[nName++] >>= pInsert->sReplaceBy; + pInsert->bReplaceAlways = *(sal_Bool*)pNodeValues[nName++].getValue(); + pInsert->bReplaceOnScreenOnly = *(sal_Bool*)pNodeValues[nName++].getValue(); + pImpl->aSubstArr.Insert(pInsert, pImpl->aSubstArr.Count()); + } +} +/* -----------------------------18.01.01 12:06-------------------------------- + + ---------------------------------------------------------------------------*/ +SvtFontSubstConfig::~SvtFontSubstConfig() +{ + delete pImpl; +} +/*-- 18.01.01 12:08:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtFontSubstConfig::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) +{ +} + +void SvtFontSubstConfig::Commit() +{ + Sequence<OUString> aNames(1); + aNames.getArray()[0] = C2U(cReplacement); + Sequence<Any> aValues(1); + aValues.getArray()[0].setValue(&bIsEnabled, ::getBooleanCppuType()); + PutProperties(aNames, aValues); + + OUString sNode(C2U(cFontPairs)); + if(!pImpl->aSubstArr.Count()) + ClearNodeSet(sNode); + else + { + Sequence<PropertyValue> aSetValues(4 * pImpl->aSubstArr.Count()); + PropertyValue* pSetValues = aSetValues.getArray(); + sal_Int32 nSetValue = 0; + + const OUString sReplaceFont(C2U(cReplaceFont)); + const OUString sSubstituteFont(C2U(cSubstituteFont)); + const OUString sAlways(C2U(cAlways)); + const OUString sOnScreenOnly(C2U(cOnScreenOnly)); + + const uno::Type& rBoolType = ::getBooleanCppuType(); + for(sal_uInt16 i = 0; i < pImpl->aSubstArr.Count(); i++) + { + OUString sPrefix(sNode); + sPrefix += C2U("/_"); + sPrefix += OUString::valueOf((sal_Int32)i); + sPrefix += C2U("/"); + + SubstitutionStructPtr pSubst = pImpl->aSubstArr[i]; + pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sReplaceFont; + pSetValues[nSetValue++].Value <<= pSubst->sFont; + pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sSubstituteFont; + pSetValues[nSetValue++].Value <<= pSubst->sReplaceBy; + pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sAlways; + pSetValues[nSetValue++].Value.setValue(&pSubst->bReplaceAlways, rBoolType); + pSetValues[nSetValue].Name = sPrefix; pSetValues[nSetValue].Name += sOnScreenOnly; + pSetValues[nSetValue++].Value.setValue(&pSubst->bReplaceOnScreenOnly, rBoolType); + } + ReplaceSetProperties(sNode, aSetValues); + } +} +/*-- 18.01.01 12:08:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +sal_Int32 SvtFontSubstConfig::SubstitutionCount() const +{ + return pImpl->aSubstArr.Count(); +} +/*-- 18.01.01 12:08:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtFontSubstConfig::ClearSubstitutions() +{ + pImpl->aSubstArr.DeleteAndDestroy(0, pImpl->aSubstArr.Count()); +} +/*-- 18.01.01 12:08:00--------------------------------------------------- + + -----------------------------------------------------------------------*/ +const SubstitutionStruct* SvtFontSubstConfig::GetSubstitution(sal_Int32 nPos) +{ + DBG_ASSERT(nPos >= 0 && nPos < pImpl->aSubstArr.Count(), "illegal array index"); + if(nPos >= 0 && nPos < pImpl->aSubstArr.Count()) + return pImpl->aSubstArr[(sal_uInt16)nPos]; + return 0; +} +/*-- 18.01.01 12:08:01--------------------------------------------------- + + -----------------------------------------------------------------------*/ +void SvtFontSubstConfig::AddSubstitution(const SubstitutionStruct& rToAdd) +{ + SubstitutionStructPtr pInsert = new SubstitutionStruct(rToAdd); + pImpl->aSubstArr.Insert(pInsert, pImpl->aSubstArr.Count()); +} + +void SvtFontSubstConfig::Apply() +{ + OutputDevice::BeginFontSubstitution(); + + // Alte Substitution entfernen + sal_uInt16 nOldCount = OutputDevice::GetFontSubstituteCount(); + + while (nOldCount) + OutputDevice::RemoveFontSubstitute(--nOldCount); + + // Neue Substitution einlesen + sal_Int32 nCount = IsEnabled() ? SubstitutionCount() : 0; + + for (sal_Int32 i = 0; i < nCount; i++) + { + sal_uInt16 nFlags = 0; + const SubstitutionStruct* pSubs = GetSubstitution(i); + if(pSubs->bReplaceAlways) + nFlags |= FONT_SUBSTITUTE_ALWAYS; + if(pSubs->bReplaceOnScreenOnly) + nFlags |= FONT_SUBSTITUTE_SCREENONLY; + OutputDevice::AddFontSubstitute( String(pSubs->sFont), String(pSubs->sReplaceBy), nFlags ); + } + + OutputDevice::EndFontSubstitution(); +} diff --git a/svtools/source/config/helpopt.cxx b/svtools/source/config/helpopt.cxx new file mode 100644 index 000000000000..091bf50c4787 --- /dev/null +++ b/svtools/source/config/helpopt.cxx @@ -0,0 +1,764 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include <svtools/helpopt.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 <vcl/help.hxx> +#include <osl/mutex.hxx> +#include <comphelper/stl_types.hxx> + +#include <rtl/logfile.hxx> +#include "itemholder2.hxx" + +using namespace utl; +using namespace rtl; +using namespace com::sun::star::uno; +using namespace com::sun::star; + +static SvtHelpOptions_Impl* pOptions = NULL; +static sal_Int32 nRefCount = 0; + +#define EXTENDEDHELP 0 +#define HELPTIPS 1 +#define AGENT_ENABLED 2 +#define AGENT_TIMEOUT 3 +#define AGENT_RETRYLIMIT 4 +#define LOCALE 5 +#define SYSTEM 6 +#define STYLESHEET 7 + +class SvtHelpOptions_Impl : public utl::ConfigItem +{ + IdList* pList; + sal_Int32 nHelpAgentTimeoutPeriod; + sal_Int32 nHelpAgentRetryLimit; + sal_Bool bExtendedHelp; + sal_Bool bHelpTips; + sal_Bool bHelpAgentEnabled; + sal_Bool bWelcomeScreen; + String aLocale; + String aSystem; + String sHelpStyleSheet; + + DECLARE_STL_USTRINGACCESS_MAP( sal_Int32, MapString2Int ); + MapString2Int aURLIgnoreCounters; + ::osl::Mutex aIgnoreCounterSafety; + + Sequence< OUString > GetPropertyNames(); + +public: + SvtHelpOptions_Impl(); + + virtual void Notify( const com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames ); + void Load( const ::com::sun::star::uno::Sequence< ::rtl::OUString>& aPropertyNames); + virtual void Commit(); + + void SetExtendedHelp( sal_Bool b ) { bExtendedHelp= b; SetModified(); } + sal_Bool IsExtendedHelp() const { return bExtendedHelp; } + void SetHelpTips( sal_Bool b ) { bHelpTips = b; SetModified(); } + sal_Bool IsHelpTips() const { return bHelpTips; } + + void SetHelpAgentEnabled( sal_Bool b ) { bHelpAgentEnabled = b; SetModified(); } + sal_Bool IsHelpAgentEnabled() const { return bHelpAgentEnabled; } + void SetHelpAgentTimeoutPeriod( sal_Int32 _nSeconds ) { nHelpAgentTimeoutPeriod = _nSeconds; SetModified(); } + sal_Int32 GetHelpAgentTimeoutPeriod( ) const { return nHelpAgentTimeoutPeriod; } + void SetHelpAgentRetryLimit( sal_Int32 _nTrials ) { nHelpAgentRetryLimit = _nTrials; SetModified(); } + sal_Int32 GetHelpAgentRetryLimit( ) const { return nHelpAgentRetryLimit; } + + sal_Int32 getAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ); + void decAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ); + void resetAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ); + void resetAgentIgnoreURLCounter(); + + void SetWelcomeScreen( sal_Bool b ) { bWelcomeScreen = b; SetModified(); } + sal_Bool IsWelcomeScreen() const { return bWelcomeScreen; } + IdList* GetPIStarterList() { return pList; } + void AddToPIStarterList( sal_Int32 nId ); + void RemoveFromPIStarterList( sal_Int32 nId ); + String GetLocale() const { return aLocale; } + String GetSystem() const { return aSystem; } + + const String& GetHelpStyleSheet()const{return sHelpStyleSheet;} + void SetHelpStyleSheet(const String& rStyleSheet){sHelpStyleSheet = rStyleSheet; SetModified();} + + static ::osl::Mutex & getInitMutex(); + +protected: + void implLoadURLCounters(); + void implSaveURLCounters(); + // to be called with aIgnoreCounterSafety locked + void implGetURLCounters( Sequence< ::rtl::OUString >& _rNodeNames, Sequence< Any >& _rURLs, Sequence< Any >& _rCounter ); +}; + +Sequence< OUString > SvtHelpOptions_Impl::GetPropertyNames() +{ + static const char* aPropNames[] = + { + "ExtendedTip", + "Tip", + "HelpAgent/Enabled", + "HelpAgent/Timeout", + "HelpAgent/RetryLimit", + "Locale", + "System", + "HelpStyleSheet", +// "HowTo/Show" + }; + + 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; +} + +::osl::Mutex & SvtHelpOptions_Impl::getInitMutex() +{ + static ::osl::Mutex *pMutex = 0; + + if( ! pMutex ) + { + ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); + if( ! pMutex ) + { + static ::osl::Mutex mutex; + pMutex = &mutex; + } + } + return *pMutex; +} + + +// ----------------------------------------------------------------------- + +SvtHelpOptions_Impl::SvtHelpOptions_Impl() + : ConfigItem( OUString::createFromAscii("Office.Common/Help") ) + , pList( 0 ) + , bExtendedHelp( sal_False ) + , bHelpTips( sal_True ) + , bHelpAgentEnabled( sal_False ) + , bWelcomeScreen( sal_False ) +{ + Sequence< OUString > aNames = GetPropertyNames(); + Load( aNames ); + EnableNotification( aNames ); + implLoadURLCounters(); +} + +// ----------------------------------------------------------------------- +static int lcl_MapPropertyName( const ::rtl::OUString rCompare, + const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames) +{ + for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp) + { + if( aInternalPropertyNames[nProp] == rCompare ) + return nProp; + } + return -1; +} + +void SvtHelpOptions_Impl::Load(const uno::Sequence< ::rtl::OUString>& rPropertyNames) +{ + const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames()); + Sequence< Any > aValues = GetProperties( rPropertyNames ); + const Any* pValues = aValues.getConstArray(); + DBG_ASSERT( aValues.getLength() == rPropertyNames.getLength(), "GetProperties failed" ); + if ( aValues.getLength() == rPropertyNames.getLength() ) + { + for ( int nProp = 0; nProp < rPropertyNames.getLength(); nProp++ ) + { + DBG_ASSERT( pValues[nProp].hasValue(), "property value missing" ); + if ( pValues[nProp].hasValue() ) + { + sal_Bool bTmp = sal_Bool(); + ::rtl::OUString aTmpStr; + sal_Int32 nTmpInt = 0; + if ( pValues[nProp] >>= bTmp ) + { + switch ( lcl_MapPropertyName(rPropertyNames[nProp], aInternalPropertyNames) ) + { + case EXTENDEDHELP : + bExtendedHelp = bTmp; + break; + case HELPTIPS : + bHelpTips = bTmp; + break; + case AGENT_ENABLED : + bHelpAgentEnabled = bTmp; + break; + default: + DBG_ERRORFILE( "Wrong Member!" ); + break; + } + } + else if ( pValues[nProp] >>= aTmpStr ) + { + switch ( nProp ) + { + case LOCALE: + aLocale = aTmpStr; + break; + + case SYSTEM: + aSystem = aTmpStr; + break; + case STYLESHEET : + sHelpStyleSheet = aTmpStr; + break; + default: + DBG_ERRORFILE( "Wrong Member!" ); + break; + } + } + else if ( pValues[nProp] >>= nTmpInt ) + { + switch ( nProp ) + { + case AGENT_TIMEOUT: + nHelpAgentTimeoutPeriod = nTmpInt; + break; + + case AGENT_RETRYLIMIT: + nHelpAgentRetryLimit = nTmpInt; + break; + + default: + DBG_ERRORFILE( "Wrong Member!" ); + break; + } + } + else + { + DBG_ERRORFILE( "Wrong Type!" ); + } + } + } + if ( IsHelpTips() != Help::IsQuickHelpEnabled() ) + IsHelpTips() ? Help::EnableQuickHelp() : Help::DisableQuickHelp(); + if ( IsExtendedHelp() != Help::IsBalloonHelpEnabled() ) + IsExtendedHelp() ? Help::EnableBalloonHelp() : Help::DisableBalloonHelp(); + } +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::implGetURLCounters( Sequence< ::rtl::OUString >& _rNodeNames, Sequence< Any >& _rURLs, Sequence< Any >& _rCounters ) +{ + // the ignore counters for the help agent URLs + const ::rtl::OUString sIgnoreListNodePath = ::rtl::OUString::createFromAscii("HelpAgent/IgnoreList"); + const ::rtl::OUString sPathSeparator = ::rtl::OUString::createFromAscii("/"); + const ::rtl::OUString sURLLocalPath = ::rtl::OUString::createFromAscii("/Name"); + const ::rtl::OUString sCounterLocalPath = ::rtl::OUString::createFromAscii("/Counter"); + + // get the names of all the nodes containing ignore counters + // collect the node names we have to ask + // first get the node names of all children of HelpAgent/IgnoreList + _rNodeNames = GetNodeNames(sIgnoreListNodePath); + const ::rtl::OUString* pIgnoredURLsNodes = _rNodeNames.getConstArray(); + const ::rtl::OUString* pIgnoredURLsNodesEnd = pIgnoredURLsNodes + _rNodeNames.getLength(); + + // then assemble the two lists (of node paths) for the URLs and the counters + Sequence< ::rtl::OUString > aIgnoredURLs(_rNodeNames.getLength()); + Sequence< ::rtl::OUString > aIgnoredURLsCounter(_rNodeNames.getLength()); + ::rtl::OUString* pIgnoredURLs = aIgnoredURLs.getArray(); + ::rtl::OUString* pIgnoredURLsCounter = aIgnoredURLsCounter.getArray(); + for (;pIgnoredURLsNodes != pIgnoredURLsNodesEnd; ++pIgnoredURLsNodes, ++pIgnoredURLs, ++pIgnoredURLsCounter) + { + ::rtl::OUString sLocalURLAccess = sIgnoreListNodePath; + sLocalURLAccess += sPathSeparator; + sLocalURLAccess += *pIgnoredURLsNodes; + + // the path to the URL of this specific entry + *pIgnoredURLs = sLocalURLAccess; + *pIgnoredURLs += sURLLocalPath; + + // the path of the counter for that URL + *pIgnoredURLsCounter = sLocalURLAccess; + *pIgnoredURLsCounter += sCounterLocalPath; + } + + // now collect the values + _rURLs = GetProperties(aIgnoredURLs); + _rCounters = GetProperties(aIgnoredURLsCounter); + + sal_Int32 nURLs = _rURLs.getLength(); + sal_Int32 nCounters = _rCounters.getLength(); + DBG_ASSERT(nURLs == nCounters, "SvtHelpOptions_Impl::implGetURLCounters: inconsistence while retrieving the visited URLs!"); + + // normalize in case something went wrong + sal_Int32 nKnownURLs = nURLs < nCounters ? nURLs : nCounters; + if (nURLs < nCounters) + { + _rCounters.realloc(nKnownURLs); + _rNodeNames.realloc(nKnownURLs); + } + else if (nURLs > nCounters) + { + _rURLs.realloc(nKnownURLs); + _rNodeNames.realloc(nKnownURLs); + } +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::implSaveURLCounters() +{ + ::osl::MutexGuard aGuard(aIgnoreCounterSafety); + + const ::rtl::OUString sIgnoreListNodePath = ::rtl::OUString::createFromAscii("HelpAgent/IgnoreList"); + const ::rtl::OUString sPathSeparator = ::rtl::OUString::createFromAscii("/"); + const ::rtl::OUString sURLLocalPath = ::rtl::OUString::createFromAscii("/Name"); + const ::rtl::OUString sCounterLocalPath = ::rtl::OUString::createFromAscii("/Counter"); + + // get the current URL/counter pairs (as they're persistent at the moment) + Sequence< ::rtl::OUString > aNodeNames; + Sequence< Any > aURLs; + Sequence< Any > aCounters; + + implGetURLCounters(aNodeNames, aURLs, aCounters); + sal_Int32 nKnownURLs = aURLs.getLength(); + + const ::rtl::OUString* pNodeNames = aNodeNames.getConstArray(); + const Any* pURLs = aURLs.getConstArray(); + const Any* pCounters = aCounters.getConstArray(); + + // check which of them must be deleted/modified + Sequence< ::rtl::OUString > aDeleteFromConfig(nKnownURLs); // names of nodes to be deleted + ::rtl::OUString* pDeleteFromConfig = aDeleteFromConfig.getArray(); + ::std::set< ::rtl::OUString > aAlreadyPresent; // URLs currently persistent + + // for modifying already existent nodes + Sequence< ::rtl::OUString > aNewCounterNodePaths(nKnownURLs); + Sequence< Any > aNewCounterValues(nKnownURLs); + ::rtl::OUString* pNewCounterNodePaths = aNewCounterNodePaths.getArray(); + Any* pNewCounterValues = aNewCounterValues.getArray(); + + // temporaries needed inside the loop + ::rtl::OUString sCurrentURL, sCurrentURLNodeName; + + for (sal_Int32 i=0; i<nKnownURLs; ++i, ++pNodeNames, ++pURLs, ++pCounters) + { + if (!((*pURLs) >>= sCurrentURL)) + continue; + + ConstMapString2IntIterator aThisURLNewCounter = aURLIgnoreCounters.find(sCurrentURL); + if (aURLIgnoreCounters.end() == aThisURLNewCounter) + { // we do not know anything about this URL anymore. + // -> have to removed it from the configuration later on + *pDeleteFromConfig = *pNodeNames; + ++pDeleteFromConfig; + } + else + { // we know this URL + sCurrentURLNodeName = sIgnoreListNodePath; + sCurrentURLNodeName += sPathSeparator; + sCurrentURLNodeName += *pNodeNames; + + // -> remember this (so we don't need to add a new node for this URL later on) + aAlreadyPresent.insert(sCurrentURL); + + sal_Int32 nThisURLPersistentCounter = 0; + (*pCounters) >>= nThisURLPersistentCounter; + + if (aThisURLNewCounter->second != nThisURLPersistentCounter) + { // the counter changed + // -> remember the path and the new counter for the adjustment below + *pNewCounterNodePaths = sCurrentURLNodeName; + *pNewCounterNodePaths += sCounterLocalPath; + ++pNewCounterNodePaths; + + (*pNewCounterValues) <<= aThisURLNewCounter->second; + ++pNewCounterValues; + } + } + } + + // delete the nodes which are flagged so ... + aDeleteFromConfig.realloc(pDeleteFromConfig - aDeleteFromConfig.getArray()); + if (0 != aDeleteFromConfig.getLength()) + { + ClearNodeElements(sIgnoreListNodePath, aDeleteFromConfig); + } + + // modify the nodes which need to be + aNewCounterNodePaths.realloc(pNewCounterNodePaths - aNewCounterNodePaths.getArray()); + aNewCounterValues.realloc(pNewCounterValues - aNewCounterValues.getArray()); + if (0 != aNewCounterNodePaths.getLength()) + { + PutProperties(aNewCounterNodePaths, aNewCounterValues); + } + + // and for the new ones ... + ::rtl::OUString sNewNodeName; + Sequence< ::rtl::OUString > aNewCounterDataNodeNames(2); + Sequence< Any > aNewCounterDataValues(2); + const ::rtl::OUString sNodeNameBase = ::rtl::OUString::createFromAscii("URL"); + for ( ConstMapString2IntIterator aCollectNew = aURLIgnoreCounters.begin(); + aCollectNew != aURLIgnoreCounters.end(); + ++aCollectNew + ) + { + if (aAlreadyPresent.end() == aAlreadyPresent.find(aCollectNew->first)) + { // this URL is not persistent, yet + // -> add a new node + sNewNodeName = sNodeNameBase; + if (!getUniqueSetElementName(sIgnoreListNodePath, sNewNodeName)) + { + DBG_ERRORFILE( "SvtHelpOptions_Impl::implSaveURLCounters: could not get a free name!" ); + continue; + } + AddNode(sIgnoreListNodePath, sNewNodeName); + + // and set the URL/counter pair + aNewCounterDataNodeNames[0] = sIgnoreListNodePath; + aNewCounterDataNodeNames[0] += sPathSeparator; + aNewCounterDataNodeNames[0] += sNewNodeName; + aNewCounterDataNodeNames[0] += sURLLocalPath; + aNewCounterDataValues[0] <<= aCollectNew->first; + + aNewCounterDataNodeNames[1] = sIgnoreListNodePath; + aNewCounterDataNodeNames[1] += sPathSeparator; + aNewCounterDataNodeNames[1] += sNewNodeName; + aNewCounterDataNodeNames[1] += sCounterLocalPath; + aNewCounterDataValues[1] <<= aCollectNew->second; + + PutProperties(aNewCounterDataNodeNames, aNewCounterDataValues); + } + } +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::implLoadURLCounters() +{ + ::osl::MutexGuard aGuard(aIgnoreCounterSafety); + + Sequence< ::rtl::OUString > aNodeNames; + Sequence< Any > aURLs; + Sequence< Any > aCounters; + + implGetURLCounters(aNodeNames, aURLs, aCounters); + sal_Int32 nKnownURLs = aURLs.getLength(); + + const Any* pURLs = aURLs.getConstArray(); + const Any* pCounters = aCounters.getConstArray(); + + ::rtl::OUString sCurrentURL; + sal_Int32 nCurrentCounter; + for (sal_Int32 i=0; i<nKnownURLs; ++i, ++pURLs, ++pCounters) + { + (*pURLs) >>= sCurrentURL; + nCurrentCounter = 0; + (*pCounters) >>= nCurrentCounter; + aURLIgnoreCounters[sCurrentURL] = nCurrentCounter; + } +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::Commit() +{ + Sequence< OUString > aNames = GetPropertyNames(); + Sequence< Any > aValues( aNames.getLength() ); + Any* pValues = aValues.getArray(); + for ( int nProp = 0; nProp < aNames.getLength(); nProp++ ) + { + switch ( nProp ) + { + case EXTENDEDHELP : + pValues[nProp] <<= bExtendedHelp; + break; + + case HELPTIPS : + pValues[nProp] <<= bHelpTips; + break; + + case AGENT_ENABLED : + pValues[nProp] <<= bHelpAgentEnabled; + break; + + case AGENT_TIMEOUT: + pValues[nProp] <<= nHelpAgentTimeoutPeriod; + break; + + case AGENT_RETRYLIMIT: + pValues[nProp] <<= nHelpAgentRetryLimit; + break; + + case LOCALE: + pValues[nProp] <<= ::rtl::OUString(aLocale); + break; + + case SYSTEM: + pValues[nProp] <<= ::rtl::OUString(aSystem); + break; + case STYLESHEET : + pValues[nProp] <<= ::rtl::OUString(sHelpStyleSheet); + break; + + } + } + + PutProperties( aNames, aValues ); + + implSaveURLCounters(); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::Notify( const Sequence<rtl::OUString>& aPropertyNames ) +{ + Load( aPropertyNames ); +} + +SvtHelpOptions::SvtHelpOptions() +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() ); + ++nRefCount; + if ( !pOptions ) + { + RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtHelpOptions_Impl::ctor()"); + pOptions = new SvtHelpOptions_Impl; + + ItemHolder2::holdConfigItem(E_HELPOPTIONS); + } + pImp = pOptions; +} + +// ----------------------------------------------------------------------- + +sal_Int32 SvtHelpOptions_Impl::getAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ) +{ + ::osl::MutexGuard aGuard(aIgnoreCounterSafety); + ConstMapString2IntIterator aMapPos = aURLIgnoreCounters.find(_rURL); + if (aURLIgnoreCounters.end() == aMapPos) + return GetHelpAgentRetryLimit(); + return aMapPos->second; +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::decAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ) +{ + ::osl::MutexGuard aGuard(aIgnoreCounterSafety); + MapString2IntIterator aMapPos = aURLIgnoreCounters.find(_rURL); + if (aURLIgnoreCounters.end() == aMapPos) + { // nothing known about this URL 'til now + sal_Int32 nLimit = GetHelpAgentRetryLimit(); + sal_Int32 nIgnoreAgain = nLimit > 0 ? nLimit - 1 : 0; + aURLIgnoreCounters[_rURL] = nIgnoreAgain; + } + else + { + sal_Int32& rCounter = aMapPos->second; + if (rCounter) + --rCounter; + } + SetModified(); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::resetAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ) +{ + ::osl::MutexGuard aGuard(aIgnoreCounterSafety); + MapString2IntIterator aMapPos = aURLIgnoreCounters.find(_rURL); + if (aURLIgnoreCounters.end() != aMapPos) + { + aURLIgnoreCounters.erase(aMapPos); + SetModified(); + } +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions_Impl::resetAgentIgnoreURLCounter() +{ + ::osl::MutexGuard aGuard(aIgnoreCounterSafety); + aURLIgnoreCounters.clear(); + SetModified(); +} + +// ----------------------------------------------------------------------- + +SvtHelpOptions::~SvtHelpOptions() +{ + // Global access, must be guarded (multithreading) + ::osl::MutexGuard aGuard( SvtHelpOptions_Impl::getInitMutex() ); + if ( !--nRefCount ) + { + if ( pOptions->IsModified() ) + pOptions->Commit(); + DELETEZ( pOptions ); + } +} + +void SvtHelpOptions::SetExtendedHelp( sal_Bool b ) +{ + pImp->SetExtendedHelp( b ); +} + +sal_Bool SvtHelpOptions::IsExtendedHelp() const +{ + return pImp->IsExtendedHelp(); +} + +void SvtHelpOptions::SetHelpTips( sal_Bool b ) +{ + pImp->SetHelpTips( b ); +} + +sal_Bool SvtHelpOptions::IsHelpTips() const +{ + return pImp->IsHelpTips(); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::SetHelpAgentRetryLimit( sal_Int32 _nTrials ) +{ + pImp->SetHelpAgentRetryLimit( _nTrials ); +} + +// ----------------------------------------------------------------------- + +sal_Int32 SvtHelpOptions::GetHelpAgentRetryLimit( ) const +{ + return pImp->GetHelpAgentRetryLimit( ); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::SetHelpAgentTimeoutPeriod( sal_Int32 _nSeconds ) +{ + pImp->SetHelpAgentTimeoutPeriod( _nSeconds ); +} + +// ----------------------------------------------------------------------- + +sal_Int32 SvtHelpOptions::GetHelpAgentTimeoutPeriod( ) const +{ + return pImp->GetHelpAgentTimeoutPeriod( ); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::SetHelpAgentAutoStartMode( sal_Bool b ) +{ + pImp->SetHelpAgentEnabled( b ); +} + +// ----------------------------------------------------------------------- + +sal_Bool SvtHelpOptions::IsHelpAgentAutoStartMode() const +{ + return pImp->IsHelpAgentEnabled(); +} + +// ----------------------------------------------------------------------- + +sal_Int32 SvtHelpOptions::getAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ) +{ + return pImp->getAgentIgnoreURLCounter( _rURL ); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::decAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ) +{ + pImp->decAgentIgnoreURLCounter( _rURL ); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::resetAgentIgnoreURLCounter( const ::rtl::OUString& _rURL ) +{ + pImp->resetAgentIgnoreURLCounter( _rURL ); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::resetAgentIgnoreURLCounter() +{ + pImp->resetAgentIgnoreURLCounter(); +} + +// ----------------------------------------------------------------------- + +void SvtHelpOptions::SetWelcomeScreen( sal_Bool b ) +{ + pImp->SetWelcomeScreen( b ); +} + +sal_Bool SvtHelpOptions::IsWelcomeScreen() const +{ + return pImp->IsWelcomeScreen(); +} + +IdList* SvtHelpOptions::GetPIStarterList() +{ + return pImp->GetPIStarterList(); +} + +void SvtHelpOptions::AddToPIStarterList( sal_Int32 ) +{ +} + +void SvtHelpOptions::RemoveFromPIStarterList( sal_Int32 ) +{ +} + +String SvtHelpOptions::GetLocale() const +{ + return pImp->GetLocale(); +} + +String SvtHelpOptions::GetSystem() const +{ + return pImp->GetSystem(); +} + +const String& SvtHelpOptions::GetHelpStyleSheet()const +{ + return pImp->GetHelpStyleSheet(); +} + +void SvtHelpOptions::SetHelpStyleSheet(const String& rStyleSheet) +{ + pImp->SetHelpStyleSheet(rStyleSheet); +} + diff --git a/svtools/source/config/htmlcfg.cxx b/svtools/source/config/htmlcfg.cxx new file mode 100644 index 000000000000..b8a9660ee8dc --- /dev/null +++ b/svtools/source/config/htmlcfg.cxx @@ -0,0 +1,523 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include <svtools/htmlcfg.hxx> +#include <svtools/parhtml.hxx> +#include <unotools/syslocale.hxx> +#include <tools/debug.hxx> +#include <tools/list.hxx> +#include <tools/link.hxx> + +// ----------------------------------------------------------------------- +#define HTMLCFG_UNKNOWN_TAGS 0x01 +//#define HTMLCFG_STYLE_SHEETS 0x02 +//#define HTMLCFG_NETSCAPE3 0x04 +#define HTMLCFG_STAR_BASIC 0x08 +#define HTMLCFG_LOCAL_GRF 0x10 +#define HTMLCFG_PRINT_LAYOUT_EXTENSION 0x20 +#define HTMLCFG_IGNORE_FONT_FAMILY 0x40 +#define HTMLCFG_IS_BASIC_WARNING 0x80 +#define HTMLCFG_NUMBERS_ENGLISH_US 0x100 + +using namespace utl; +using namespace rtl; +using namespace com::sun::star::uno; + +static SvxHtmlOptions* pOptions = 0; + +DECLARE_LIST( LinkList, Link * ) + +#define C2U(cChar) OUString::createFromAscii(cChar) +/* -----------------------------23.11.00 11:39-------------------------------- + + ---------------------------------------------------------------------------*/ +struct HtmlOptions_Impl +{ + LinkList aList; + sal_Int32 nFlags; + sal_Int32 nExportMode; + sal_Int32 aFontSizeArr[HTML_FONT_COUNT]; + sal_Int32 eEncoding; + sal_Bool bIsEncodingDefault; + + HtmlOptions_Impl() : + nFlags(HTMLCFG_LOCAL_GRF|HTMLCFG_IS_BASIC_WARNING), + nExportMode(HTML_CFG_NS40), + eEncoding( gsl_getSystemTextEncoding() ), + bIsEncodingDefault(sal_True) + { + aFontSizeArr[0] = HTMLFONTSZ1_DFLT; + aFontSizeArr[1] = HTMLFONTSZ2_DFLT; + aFontSizeArr[2] = HTMLFONTSZ3_DFLT; + aFontSizeArr[3] = HTMLFONTSZ4_DFLT; + aFontSizeArr[4] = HTMLFONTSZ5_DFLT; + aFontSizeArr[5] = HTMLFONTSZ6_DFLT; + aFontSizeArr[6] = HTMLFONTSZ7_DFLT; + } +}; + +/* -----------------------------23.11.00 11:39-------------------------------- + + ---------------------------------------------------------------------------*/ +const Sequence<OUString>& SvxHtmlOptions::GetPropertyNames() +{ + static Sequence<OUString> aNames; + if(!aNames.getLength()) + { + static const char* aPropNames[] = + { + "Import/UnknownTag", // 0 + "Import/FontSetting", // 1 + "Import/FontSize/Size_1", // 2 + "Import/FontSize/Size_2", // 3 + "Import/FontSize/Size_3", // 4 + "Import/FontSize/Size_4", // 5 + "Import/FontSize/Size_5", // 6 + "Import/FontSize/Size_6", // 7 + "Import/FontSize/Size_7", // 8 + "Export/Browser", // 9 + "Export/Basic", // 0 + "Export/PrintLayout", // 11 + "Export/LocalGraphic", // 12 + "Export/Warning", // 13 + "Export/Encoding", // 14 + "Import/NumbersEnglishUS" // 15 + }; + const int nCount = sizeof(aPropNames) / sizeof(aPropNames[0]); + aNames.realloc(nCount); + OUString* pNames = aNames.getArray(); + for(int i = 0; i < nCount; i++) + pNames[i] = C2U(aPropNames[i]); + } + return aNames; +} +// ----------------------------------------------------------------------- +SvxHtmlOptions::SvxHtmlOptions() : + ConfigItem(C2U("Office.Common/Filter/HTML")) +{ + pImp = new HtmlOptions_Impl; + Load( GetPropertyNames() ); +} + +// ----------------------------------------------------------------------- +SvxHtmlOptions::~SvxHtmlOptions() +{ + delete pImp; +} + +void SvxHtmlOptions::Load( const Sequence< OUString >& aNames ) +{ + Sequence<Any> aValues = GetProperties(aNames); + const Any* pValues = aValues.getConstArray(); + DBG_ASSERT(aValues.getLength() == aNames.getLength(), "GetProperties failed"); + if(aValues.getLength() == aNames.getLength()) + { + pImp->nFlags = 0; + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + if(pValues[nProp].hasValue()) + { + switch(nProp) + { + case 0: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_UNKNOWN_TAGS; + break;//"Import/UnknownTag", + case 1: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_IGNORE_FONT_FAMILY; + break;//"Import/FontSetting", + case 2: pValues[nProp] >>= pImp->aFontSizeArr[0]; break;//"Import/FontSize/Size_1", + case 3: pValues[nProp] >>= pImp->aFontSizeArr[1]; break;//"Import/FontSize/Size_2", + case 4: pValues[nProp] >>= pImp->aFontSizeArr[2]; break;//"Import/FontSize/Size_3", + case 5: pValues[nProp] >>= pImp->aFontSizeArr[3]; break;//"Import/FontSize/Size_4", + case 6: pValues[nProp] >>= pImp->aFontSizeArr[4]; break;//"Import/FontSize/Size_5", + case 7: pValues[nProp] >>= pImp->aFontSizeArr[5]; break;//"Import/FontSize/Size_6", + case 8: pValues[nProp] >>= pImp->aFontSizeArr[6]; break;//"Import/FontSize/Size_7", + case 9://"Export/Browser", + { + sal_Int32 nExpMode = 0; +// pValues[nProp] >>= pImp->nExportMode; + pValues[nProp] >>= nExpMode; + switch( nExpMode ) + { + case 0: nExpMode = HTML_CFG_HTML32; break; + case 1: nExpMode = HTML_CFG_MSIE_40; break; +// case 2: nExpMode = HTML_CFG_NS30; break; depricated + case 3: nExpMode = HTML_CFG_WRITER; break; + case 4: nExpMode = HTML_CFG_NS40; break; + case 5: nExpMode = HTML_CFG_MSIE_40_OLD;break; + default: nExpMode = HTML_CFG_NS40; break; + } + + pImp->nExportMode = nExpMode; + } + break; + case 10: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_STAR_BASIC; + break;//"Export/Basic", + case 11: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_PRINT_LAYOUT_EXTENSION; + break;//"Export/PrintLayout", + case 12: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_LOCAL_GRF; + break;//"Export/LocalGraphic", + case 13: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_IS_BASIC_WARNING; + break;//"Export/Warning" + + case 14: pValues[nProp] >>= pImp->eEncoding; + pImp->bIsEncodingDefault = sal_False; + break;//"Export/Encoding" + + case 15: + if(*(sal_Bool*)pValues[nProp].getValue()) + pImp->nFlags |= HTMLCFG_NUMBERS_ENGLISH_US; + break;//"Import/NumbersEnglishUS" + } + } + } + } +} + +// ----------------------------------------------------------------------- +void SvxHtmlOptions::Commit() +{ + const Sequence<OUString>& aNames = GetPropertyNames(); + +// const OUString* pNames = aNames.getConstArray(); + Sequence<Any> aValues(aNames.getLength()); + Any* pValues = aValues.getArray(); + +// const Type& rType = ::getBooleanCppuType(); + for(int nProp = 0; nProp < aNames.getLength(); nProp++) + { + sal_Bool bSet = sal_False; + switch(nProp) + { + case 0: bSet = 0 != (pImp->nFlags & HTMLCFG_UNKNOWN_TAGS);break;//"Import/UnknownTag", + case 1: bSet = 0 != (pImp->nFlags & HTMLCFG_IGNORE_FONT_FAMILY);break;//"Import/FontSetting", + case 2: pValues[nProp] <<= pImp->aFontSizeArr[0];break;//"Import/FontSize/Size_1", + case 3: pValues[nProp] <<= pImp->aFontSizeArr[1];break;//"Import/FontSize/Size_2", + case 4: pValues[nProp] <<= pImp->aFontSizeArr[2];break;//"Import/FontSize/Size_3", + case 5: pValues[nProp] <<= pImp->aFontSizeArr[3];break;//"Import/FontSize/Size_4", + case 6: pValues[nProp] <<= pImp->aFontSizeArr[4];break;//"Import/FontSize/Size_5", + case 7: pValues[nProp] <<= pImp->aFontSizeArr[5];break;//"Import/FontSize/Size_6", + case 8: pValues[nProp] <<= pImp->aFontSizeArr[6];break;//"Import/FontSize/Size_7", + case 9: //"Export/Browser", + { + sal_Int32 nExpMode = pImp->nExportMode; + + switch( nExpMode ) + { + case HTML_CFG_HTML32: nExpMode = 0; break; + case HTML_CFG_MSIE_40: nExpMode = 1; break; +// case HTML_CFG_NS30: nExpMode = 2; break; depricated + case HTML_CFG_WRITER: nExpMode = 3; break; + case HTML_CFG_NS40: nExpMode = 4; break; + case HTML_CFG_MSIE_40_OLD: nExpMode = 5; break; + default: nExpMode = 4; break; // NS40 + } + + pValues[nProp] <<= nExpMode; + break; + } + case 10: bSet = 0 != (pImp->nFlags & HTMLCFG_STAR_BASIC);break;//"Export/Basic", + case 11: bSet = 0 != (pImp->nFlags & HTMLCFG_PRINT_LAYOUT_EXTENSION);break;//"Export/PrintLayout", + case 12: bSet = 0 != (pImp->nFlags & HTMLCFG_LOCAL_GRF);break;//"Export/LocalGraphic", + case 13: bSet = 0 != (pImp->nFlags & HTMLCFG_IS_BASIC_WARNING);break;//"Export/Warning" + case 14: + if(!pImp->bIsEncodingDefault) + pValues[nProp] <<= pImp->eEncoding; + break;//"Export/Encoding", + case 15: bSet = 0 != (pImp->nFlags & HTMLCFG_NUMBERS_ENGLISH_US);break;//"Import/NumbersEnglishUS" + } + if(nProp < 2 || ( nProp > 9 && nProp < 14 ) || nProp == 15) + pValues[nProp].setValue(&bSet, ::getCppuBooleanType()); + } + PutProperties(aNames, aValues); +} + +void SvxHtmlOptions::AddListenerLink( const Link& rLink ) +{ + pImp->aList.Insert( new Link( rLink ) ); +} + +void SvxHtmlOptions::RemoveListenerLink( const Link& rLink ) +{ + for ( USHORT n=0; n<pImp->aList.Count(); n++ ) + { + if ( (*pImp->aList.GetObject(n) ) == rLink ) + { + delete pImp->aList.Remove(n); + break; + } + } +} + +void SvxHtmlOptions::CallListeners() +{ + for ( USHORT n = 0; n < pImp->aList.Count(); ++n ) + pImp->aList.GetObject(n)->Call( this ); +} + + +void SvxHtmlOptions::Notify( const com::sun::star::uno::Sequence< rtl::OUString >& ) +{ + Load( GetPropertyNames() ); + CallListeners(); +} + +// ----------------------------------------------------------------------- +USHORT SvxHtmlOptions::GetFontSize(USHORT nPos) const +{ + if(nPos < HTML_FONT_COUNT) + return (USHORT)pImp->aFontSizeArr[nPos]; + return 0; +} +// ----------------------------------------------------------------------- +void SvxHtmlOptions::SetFontSize(USHORT nPos, USHORT nSize) +{ + if(nPos < HTML_FONT_COUNT) + { + pImp->aFontSizeArr[nPos] = nSize; + SetModified(); + } +} + +// ----------------------------------------------------------------------- + +// ----------------------------------------------------------------------- + + +BOOL SvxHtmlOptions::IsImportUnknown() const +{ + return 0 != (pImp->nFlags & HTMLCFG_UNKNOWN_TAGS) ; +} + +// ----------------------------------------------------------------------- + + +void SvxHtmlOptions::SetImportUnknown(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_UNKNOWN_TAGS; + else + pImp->nFlags &= ~HTMLCFG_UNKNOWN_TAGS; + SetModified(); +} + +// ----------------------------------------------------------------------- + + +USHORT SvxHtmlOptions::GetExportMode() const +{ + return (USHORT)pImp->nExportMode; +} + +// ----------------------------------------------------------------------- + + +void SvxHtmlOptions::SetExportMode(USHORT nSet) +{ + if(nSet <= HTML_CFG_MAX ) + { + pImp->nExportMode = nSet; + SetModified(); + CallListeners(); + } +} + +// ----------------------------------------------------------------------- + + +BOOL SvxHtmlOptions::IsStarBasic() const +{ + return 0 != (pImp->nFlags & HTMLCFG_STAR_BASIC) ; +} + +// ----------------------------------------------------------------------- + + +void SvxHtmlOptions::SetStarBasic(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_STAR_BASIC; + else + pImp->nFlags &= ~HTMLCFG_STAR_BASIC; + SetModified(); +} + +/*-----------------14.02.97 08.34------------------- + +--------------------------------------------------*/ + +BOOL SvxHtmlOptions::IsSaveGraphicsLocal() const +{ + return 0 != (pImp->nFlags & HTMLCFG_LOCAL_GRF) ; +} +/*-----------------14.02.97 08.34------------------- + +--------------------------------------------------*/ +void SvxHtmlOptions::SetSaveGraphicsLocal(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_LOCAL_GRF; + else + pImp->nFlags &= ~HTMLCFG_LOCAL_GRF; + SetModified(); +} + +/*-----------------10/21/97 08:34am----------------- + +--------------------------------------------------*/ + +BOOL SvxHtmlOptions::IsPrintLayoutExtension() const +{ + BOOL bRet = 0 != (pImp->nFlags & HTMLCFG_PRINT_LAYOUT_EXTENSION); + switch( pImp->nExportMode ) + { + case HTML_CFG_MSIE_40: + case HTML_CFG_NS40 : + case HTML_CFG_WRITER : + break; + default: + bRet = FALSE; + } + return bRet; +} +/*-----------------10/21/97 08:34am----------------- + +--------------------------------------------------*/ +void SvxHtmlOptions::SetPrintLayoutExtension(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_PRINT_LAYOUT_EXTENSION; + else + pImp->nFlags &= ~HTMLCFG_PRINT_LAYOUT_EXTENSION; + SetModified(); +} + +/*-----------------10.07.98 10.02------------------- + +--------------------------------------------------*/ + +BOOL SvxHtmlOptions::IsIgnoreFontFamily() const +{ + return 0 != (pImp->nFlags & HTMLCFG_IGNORE_FONT_FAMILY) ; +} +/*-----------------10.07.98 10.02------------------- + +--------------------------------------------------*/ +void SvxHtmlOptions::SetIgnoreFontFamily(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_IGNORE_FONT_FAMILY; + else + pImp->nFlags &= ~HTMLCFG_IGNORE_FONT_FAMILY; + SetModified(); +} +/* -----------------05.02.99 09:03------------------- + * + * --------------------------------------------------*/ +BOOL SvxHtmlOptions::IsStarBasicWarning() const +{ + return 0 != (pImp->nFlags & HTMLCFG_IS_BASIC_WARNING) ; +} +/* -----------------05.02.99 09:03------------------- + * + * --------------------------------------------------*/ +void SvxHtmlOptions::SetStarBasicWarning(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_IS_BASIC_WARNING; + else + pImp->nFlags &= ~HTMLCFG_IS_BASIC_WARNING; + SetModified(); +} + +/*-----------------19.02.2001 18:40----------------- + * + * --------------------------------------------------*/ +rtl_TextEncoding SvxHtmlOptions::GetTextEncoding() const +{ + rtl_TextEncoding eRet; + if(pImp->bIsEncodingDefault) + eRet = SvtSysLocale::GetBestMimeEncoding(); + else + eRet = (rtl_TextEncoding)pImp->eEncoding; + return eRet; +} + +/*-----------------19.02.2001 18:40----------------- + * + * --------------------------------------------------*/ +void SvxHtmlOptions::SetTextEncoding( rtl_TextEncoding eEnc ) +{ + pImp->eEncoding = eEnc; + pImp->bIsEncodingDefault = sal_False; + SetModified(); +} +/* -----------------------------15.08.2001 12:01------------------------------ + + ---------------------------------------------------------------------------*/ +sal_Bool SvxHtmlOptions::IsDefaultTextEncoding() const +{ + return pImp->bIsEncodingDefault; +} + +SvxHtmlOptions* SvxHtmlOptions::Get() +{ + if ( !pOptions ) + pOptions = new SvxHtmlOptions; + return pOptions; +} + + +/* ---------------------- 2006-06-07T21:02+0200 ---------------------- */ +BOOL SvxHtmlOptions::IsNumbersEnglishUS() const +{ + return 0 != (pImp->nFlags & HTMLCFG_NUMBERS_ENGLISH_US) ; +} + + +/* ---------------------- 2006-06-07T21:02+0200 ---------------------- */ +void SvxHtmlOptions::SetNumbersEnglishUS(BOOL bSet) +{ + if(bSet) + pImp->nFlags |= HTMLCFG_NUMBERS_ENGLISH_US; + else + pImp->nFlags &= ~HTMLCFG_NUMBERS_ENGLISH_US; + SetModified(); +} diff --git a/svtools/source/config/itemholder2.cxx b/svtools/source/config/itemholder2.cxx new file mode 100644 index 000000000000..8e971a1629bf --- /dev/null +++ b/svtools/source/config/itemholder2.cxx @@ -0,0 +1,209 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#include "itemholder2.hxx" + +//----------------------------------------------- +// includes +#include <comphelper/processfactory.hxx> +#include <com/sun/star/lang/XComponent.hpp> + +#include <svtools/accessibilityoptions.hxx> +#include <apearcfg.hxx> +#include <svtools/menuoptions.hxx> +#include <svtools/colorcfg.hxx> +#include <fontsubstconfig.hxx> +#include <svtools/helpopt.hxx> +#include <svtools/printoptions.hxx> +#include <unotools/options.hxx> +#include <svtools/miscopt.hxx> + + +#include <tools/debug.hxx> + +//----------------------------------------------- +// namespaces + +namespace css = ::com::sun::star; + +//----------------------------------------------- +// declarations + +//----------------------------------------------- +ItemHolder2::ItemHolder2() + : ItemHolderMutexBase() +{ + try + { + css::uno::Reference< css::lang::XMultiServiceFactory > xSMGR = ::comphelper::getProcessServiceFactory(); + css::uno::Reference< css::lang::XComponent > xCfg( + xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")), + css::uno::UNO_QUERY); + if (xCfg.is()) + xCfg->addEventListener(static_cast< css::lang::XEventListener* >(this)); + } +// #i37892 got errorhandling from ConfigManager::GetConfigurationProvider() + catch(css::uno::RuntimeException& rREx) + { + throw rREx; + } +#ifdef DBG_UTIL + catch(css::uno::Exception& rEx) + { + static sal_Bool bMessage = sal_True; + if(bMessage) + { + bMessage = sal_False; + ::rtl::OString sMsg("CreateInstance with arguments exception: "); + sMsg += ::rtl::OString(rEx.Message.getStr(), + rEx.Message.getLength(), + RTL_TEXTENCODING_ASCII_US); + DBG_ERROR(sMsg.getStr()); + } + } +#else + catch(css::uno::Exception&){} +#endif +} + +//----------------------------------------------- +ItemHolder2::~ItemHolder2() +{ + impl_releaseAllItems(); +} + +//----------------------------------------------- +void ItemHolder2::holdConfigItem(EItem eItem) +{ + static ItemHolder2* pHolder = new ItemHolder2(); + pHolder->impl_addItem(eItem); +} + +//----------------------------------------------- +void SAL_CALL ItemHolder2::disposing(const css::lang::EventObject&) + throw(css::uno::RuntimeException) +{ + impl_releaseAllItems(); +} + +//----------------------------------------------- +void ItemHolder2::impl_addItem(EItem eItem) +{ + ::osl::ResettableMutexGuard aLock(m_aLock); + + TItems::const_iterator pIt; + for ( pIt = m_lItems.begin(); + pIt != m_lItems.end() ; + ++pIt ) + { + const TItemInfo& rInfo = *pIt; + if (rInfo.eItem == eItem) + return; + } + + TItemInfo aNewItem; + aNewItem.eItem = eItem; + impl_newItem(aNewItem); + if (aNewItem.pItem) + m_lItems.push_back(aNewItem); +} + +//----------------------------------------------- +void ItemHolder2::impl_releaseAllItems() +{ + ::osl::ResettableMutexGuard aLock(m_aLock); + + TItems::iterator pIt; + for ( pIt = m_lItems.begin(); + pIt != m_lItems.end() ; + ++pIt ) + { + TItemInfo& rInfo = *pIt; + impl_deleteItem(rInfo); + } + m_lItems.clear(); +} + +//----------------------------------------------- +void ItemHolder2::impl_newItem(TItemInfo& rItem) +{ + switch(rItem.eItem) + { + case E_ACCESSIBILITYOPTIONS : + rItem.pItem = new SvtAccessibilityOptions(); + break; + + case E_APEARCFG : +// no ref count rItem.pItem = new SvtTabAppearanceCfg(); + break; + + case E_COLORCFG : + rItem.pItem = new ::svtools::ColorConfig(); + break; + + case E_FONTSUBSTCONFIG : +// no ref count rItem.pItem = new SvtFontSubstConfig(); + break; + + case E_HELPOPTIONS : + rItem.pItem = new SvtHelpOptions(); + break; + + case E_MENUOPTIONS : + rItem.pItem = new SvtMenuOptions(); + break; + + case E_PRINTOPTIONS : + rItem.pItem = new SvtPrinterOptions(); + break; + + case E_PRINTFILEOPTIONS : + rItem.pItem = new SvtPrintFileOptions(); + break; + + case E_MISCOPTIONS : + rItem.pItem = new SvtMiscOptions(); + break; + + default: + OSL_ASSERT(false); + break; + } +} + +//----------------------------------------------- +void ItemHolder2::impl_deleteItem(TItemInfo& rItem) +{ + if (rItem.pItem) + { + delete rItem.pItem; + rItem.pItem = 0; + } +} diff --git a/svtools/source/config/itemholder2.hxx b/svtools/source/config/itemholder2.hxx new file mode 100644 index 000000000000..9314021b5750 --- /dev/null +++ b/svtools/source/config/itemholder2.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * 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_SVTOOLS_ITEMHOLDER2_HXX_ +#define INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_ + +//----------------------------------------------- +// includes + +#include <unotools/itemholderbase.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/lang/XEventListener.hpp> + +//----------------------------------------------- +// namespaces + +#ifdef css +#error "Cant use css as namespace alias." +#else +#define css ::com::sun::star +#endif + +//----------------------------------------------- +// definitions + +class ItemHolder2 : private ItemHolderMutexBase + , public ::cppu::WeakImplHelper1< css::lang::XEventListener > +{ + //........................................... + // member + private: + + TItems m_lItems; + + //........................................... + // c++ interface + public: + + ItemHolder2(); + virtual ~ItemHolder2(); + static void holdConfigItem(EItem eItem); + + //........................................... + // uno interface + public: + + virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent) + throw(css::uno::RuntimeException); + + //........................................... + // helper + private: + + void impl_addItem(EItem eItem); + void impl_releaseAllItems(); + void impl_newItem(TItemInfo& rItem); + void impl_deleteItem(TItemInfo& rItem); +}; + +//----------------------------------------------- +// namespaces + +#undef css + +#endif // INCLUDED_SVTOOLS_ITEMHOLDER2_HXX_ diff --git a/svtools/source/config/makefile.mk b/svtools/source/config/makefile.mk new file mode 100644 index 000000000000..d3ba43de68ef --- /dev/null +++ b/svtools/source/config/makefile.mk @@ -0,0 +1,58 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* +PRJ=..$/.. + +PRJNAME=svtools +TARGET=config + +ENABLE_EXCEPTIONS := TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/svt.pmk + +# --- Files -------------------------------------------------------- + +SLOFILES= \ + $(SLO)$/accessibilityoptions.obj \ + $(SLO)$/apearcfg.obj \ + $(SLO)$/colorcfg.obj \ + $(SLO)$/extcolorcfg.obj \ + $(SLO)$/fontsubstconfig.obj \ + $(SLO)$/helpopt.obj \ + $(SLO)$/htmlcfg.obj \ + $(SLO)$/itemholder2.obj \ + $(SLO)$/menuoptions.obj \ + $(SLO)$/miscopt.obj \ + $(SLO)$/optionsdrawinglayer.obj \ + $(SLO)$/printoptions.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/svtools/source/config/menuoptions.cxx b/svtools/source/config/menuoptions.cxx new file mode 100644 index 000000000000..1551361f252f --- /dev/null +++ b/svtools/source/config/menuoptions.cxx @@ -0,0 +1,565 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" +#ifndef GCC +#endif + +//_________________________________________________________________________________________________________________ +// includes +//_________________________________________________________________________________________________________________ + +#include <svtools/menuoptions.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 <vcl/svapp.hxx> + +#include <rtl/logfile.hxx> +#include "itemholder2.hxx" + +//_________________________________________________________________________________________________________________ +// namespaces +//_________________________________________________________________________________________________________________ + +using namespace ::utl ; +using namespace ::rtl ; +using namespace ::osl ; +using namespace ::com::sun::star::uno ; + +//_________________________________________________________________________________________________________________ +// const +//_________________________________________________________________________________________________________________ + +#define ROOTNODE_MENU OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/View/Menu" )) +#define DEFAULT_DONTHIDEDISABLEDENTRIES sal_False +#define DEFAULT_FOLLOWMOUSE sal_True +#define DEFAULT_MENUICONS 2 + +#define PROPERTYNAME_DONTHIDEDISABLEDENTRIES OUString(RTL_CONSTASCII_USTRINGPARAM("DontHideDisabledEntry" )) +#define PROPERTYNAME_FOLLOWMOUSE OUString(RTL_CONSTASCII_USTRINGPARAM("FollowMouse" )) +#define PROPERTYNAME_SHOWICONSINMENUES OUString(RTL_CONSTASCII_USTRINGPARAM("ShowIconsInMenues" )) +#define PROPERTYNAME_SYSTEMICONSINMENUES OUString(RTL_CONSTASCII_USTRINGPARAM("IsSystemIconsInMenus" )) + +#define PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES 0 +#define PROPERTYHANDLE_FOLLOWMOUSE 1 +#define PROPERTYHANDLE_SHOWICONSINMENUES 2 +#define PROPERTYHANDLE_SYSTEMICONSINMENUES 3 + +#define PROPERTYCOUNT 4 + +#include <tools/link.hxx> +#include <tools/list.hxx> +DECLARE_LIST( LinkList, Link * ) + +//_________________________________________________________________________________________________________________ +// private declarations! +//_________________________________________________________________________________________________________________ + +class SvtMenuOptions_Impl : public ConfigItem +{ + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + LinkList aList; + sal_Bool m_bDontHideDisabledEntries ; /// cache "DontHideDisabledEntries" of Menu section + sal_Bool m_bFollowMouse ; /// cache "FollowMouse" of Menu section + sal_Int16 m_nMenuIcons ; /// cache "MenuIcons" of Menu section + + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + + SvtMenuOptions_Impl(); + ~SvtMenuOptions_Impl(); + + void AddListenerLink( const Link& rLink ); + void RemoveListenerLink( const Link& rLink ); + + //--------------------------------------------------------------------------------------------------------- + // overloaded methods of baseclass + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short called for notify of configmanager + @descr These method is called from the ConfigManager before application ends or from the + PropertyChangeListener if the sub tree broadcasts changes. You must update your + internal values. + + @seealso baseclass ConfigItem + + @param "seqPropertyNames" is the list of properties which should be updated. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void Notify( const Sequence< OUString >& seqPropertyNames ); + + /*-****************************************************************************************************//** + @short write changes to configuration + @descr These method writes the changed values into the sub tree + and should always called in our destructor to guarantee consistency of config data. + + @seealso baseclass ConfigItem + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void Commit(); + + //--------------------------------------------------------------------------------------------------------- + // public interface + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short access method to get internal values + @descr These method give us a chance to regulate acces to ouer internal values. + It's not used in the moment - but it's possible for the feature! + + @seealso - + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + sal_Bool IsEntryHidingEnabled() const + { return m_bDontHideDisabledEntries; } + + sal_Bool IsFollowMouseEnabled() const + { return m_bFollowMouse; } + + sal_Int16 GetMenuIconsState() const + { return m_nMenuIcons; } + + void SetEntryHidingState ( sal_Bool bState ) + { + m_bDontHideDisabledEntries = bState; + SetModified(); + for ( USHORT n=0; n<aList.Count(); n++ ) + aList.GetObject(n)->Call( this ); + Commit(); + } + + void SetFollowMouseState ( sal_Bool bState ) + { + m_bFollowMouse = bState; + SetModified(); + for ( USHORT n=0; n<aList.Count(); n++ ) + aList.GetObject(n)->Call( this ); + Commit(); + } + + void SetMenuIconsState ( sal_Int16 bState ) + { + m_nMenuIcons = bState; + SetModified(); + for ( USHORT n=0; n<aList.Count(); n++ ) + aList.GetObject(n)->Call( this ); + Commit(); + } + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + /*-****************************************************************************************************//** + @short return list of fix key names of ouer configuration management which represent oue module tree + @descr These methods return a static const list of key names. We need it to get needed values from our + configuration management. + + @seealso - + + @param - + @return A list of needed configuration keys is returned. + + @onerror - + *//*-*****************************************************************************************************/ + + static Sequence< OUString > impl_GetPropertyNames(); +}; + +//_________________________________________________________________________________________________________________ +// definitions +//_________________________________________________________________________________________________________________ + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +SvtMenuOptions_Impl::SvtMenuOptions_Impl() + // Init baseclasses first + : ConfigItem ( ROOTNODE_MENU ) + // Init member then. + , m_bDontHideDisabledEntries ( DEFAULT_DONTHIDEDISABLEDENTRIES ) + , m_bFollowMouse ( DEFAULT_FOLLOWMOUSE ) + , m_nMenuIcons ( DEFAULT_MENUICONS ) +{ + // Use our static list of configuration keys to get his values. + Sequence< OUString > seqNames = impl_GetPropertyNames(); + Sequence< Any > seqValues = GetProperties( seqNames ) ; + + // Safe impossible cases. + // We need values from ALL configuration keys. + // Follow assignment use order of values in relation to our list of key names! + DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nI miss some values of configuration keys!\n" ); + + sal_Bool bMenuIcons = true; + sal_Bool bSystemMenuIcons = true; + + // Copy values from list in right order to ouer internal member. + sal_Int32 nPropertyCount = seqValues.getLength() ; + sal_Int32 nProperty = 0 ; + for( nProperty=0; nProperty<nPropertyCount; ++nProperty ) + { + // Safe impossible cases. + // Check any for valid value. + DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nInvalid property value for property detected!\n" ); + switch( nProperty ) + { + case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" ); + seqValues[nProperty] >>= m_bDontHideDisabledEntries; + } + break; + + case PROPERTYHANDLE_FOLLOWMOUSE : { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" ); + seqValues[nProperty] >>= m_bFollowMouse; + } + break; + case PROPERTYHANDLE_SHOWICONSINMENUES : { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" ); + seqValues[nProperty] >>= bMenuIcons; + } + break; + case PROPERTYHANDLE_SYSTEMICONSINMENUES : { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" ); + seqValues[nProperty] >>= bSystemMenuIcons; + } + break; + } + } + + m_nMenuIcons = bSystemMenuIcons ? 2 : bMenuIcons; + + EnableNotification( seqNames ); +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +SvtMenuOptions_Impl::~SvtMenuOptions_Impl() +{ + // Flush data to configuration! + // User has no chance to do that. + if( IsModified() == sal_True ) + { + Commit(); + } + + for ( USHORT n=0; n<aList.Count(); ) + delete aList.Remove(n); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMenuOptions_Impl::Notify( const Sequence< OUString >& seqPropertyNames ) +{ + // Use given list of updated properties to get his values from configuration directly! + Sequence< Any > seqValues = GetProperties( seqPropertyNames ); + // Safe impossible cases. + // We need values from ALL notified configuration keys. + DBG_ASSERT( !(seqPropertyNames.getLength()!=seqValues.getLength()), "SvtMenuOptions_Impl::Notify()\nI miss some values of configuration keys!\n" ); + + sal_Bool bMenuIcons = true; + sal_Bool bSystemMenuIcons = true; + sal_Bool bMenuSettingsChanged = false; + + // Step over list of property names and get right value from coreesponding value list to set it on internal members! + sal_Int32 nCount = seqPropertyNames.getLength(); + for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) + { + if( seqPropertyNames[nProperty] == PROPERTYNAME_DONTHIDEDISABLEDENTRIES ) + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\DontHideDisabledEntry\"?" ); + seqValues[nProperty] >>= m_bDontHideDisabledEntries; + } + else if( seqPropertyNames[nProperty] == PROPERTYNAME_FOLLOWMOUSE ) + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::Notify()\nWho has changed the value type of \"Office.Common\\View\\Menu\\FollowMouse\"?" ); + seqValues[nProperty] >>= m_bFollowMouse; + } + else if( seqPropertyNames[nProperty] == PROPERTYNAME_SHOWICONSINMENUES ) + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\ShowIconsInMenues\"?" ); + bMenuSettingsChanged = seqValues[nProperty] >>= bMenuIcons; + } + else if( seqPropertyNames[nProperty] == PROPERTYNAME_SYSTEMICONSINMENUES ) + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtMenuOptions_Impl::SvtMenuOptions_Impl()\nWho has changed the value type of \"Office.Common\\View\\Menu\\IsSystemIconsInMenus\"?" ); + bMenuSettingsChanged = seqValues[nProperty] >>= bSystemMenuIcons; + } + + #if OSL_DEBUG_LEVEL > 1 + else DBG_ASSERT( sal_False, "SvtMenuOptions_Impl::Notify()\nUnkown property detected ... I can't handle these!\n" ); + #endif + } + + if ( bMenuSettingsChanged ) + m_nMenuIcons = bSystemMenuIcons ? 2 : bMenuIcons; + + for ( USHORT n=0; n<aList.Count(); n++ ) + aList.GetObject(n)->Call( this ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMenuOptions_Impl::Commit() +{ + // Get names of supported properties, create a list for values and copy current values to it. + Sequence< OUString > seqNames = impl_GetPropertyNames(); + sal_Int32 nCount = seqNames.getLength(); + Sequence< Any > seqValues ( nCount ); + for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) + { + switch( nProperty ) + { + case PROPERTYHANDLE_DONTHIDEDISABLEDENTRIES : { + seqValues[nProperty] <<= m_bDontHideDisabledEntries; + } + break; + + case PROPERTYHANDLE_FOLLOWMOUSE : { + seqValues[nProperty] <<= m_bFollowMouse; + } + break; + //Output cache of current setting as possibly modified by System Theme for older version + case PROPERTYHANDLE_SHOWICONSINMENUES : { + sal_Bool bValue = (sal_Bool)(Application::GetSettings().GetStyleSettings().GetUseImagesInMenus()); + seqValues[nProperty] <<= bValue; + } + break; + case PROPERTYHANDLE_SYSTEMICONSINMENUES : { + sal_Bool bValue = (m_nMenuIcons == 2 ? sal_True : sal_False) ; + seqValues[nProperty] <<= bValue; + } + break; + } + } + // Set properties in configuration. + PutProperties( seqNames, seqValues ); +} + +//***************************************************************************************************************** +// private method +//***************************************************************************************************************** +Sequence< OUString > SvtMenuOptions_Impl::impl_GetPropertyNames() +{ + // Build static list of configuration key names. + static const OUString pProperties[] = + { + PROPERTYNAME_DONTHIDEDISABLEDENTRIES , + PROPERTYNAME_FOLLOWMOUSE , + PROPERTYNAME_SHOWICONSINMENUES , + PROPERTYNAME_SYSTEMICONSINMENUES + }; + // Initialize return sequence with these list ... + static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); + // ... and return it. + return seqPropertyNames; +} + +void SvtMenuOptions_Impl::AddListenerLink( const Link& rLink ) +{ + aList.Insert( new Link( rLink ) ); +} + +void SvtMenuOptions_Impl::RemoveListenerLink( const Link& rLink ) +{ + for ( USHORT n=0; n<aList.Count(); n++ ) + { + if ( (*aList.GetObject(n) ) == rLink ) + { + delete aList.Remove(n); + break; + } + } +} + +//***************************************************************************************************************** +// initialize static member +// DON'T DO IT IN YOUR HEADER! +// see definition for further informations +//***************************************************************************************************************** +SvtMenuOptions_Impl* SvtMenuOptions::m_pDataContainer = NULL ; +sal_Int32 SvtMenuOptions::m_nRefCount = 0 ; + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +SvtMenuOptions::SvtMenuOptions() +{ + // Global access, must be guarded (multithreading!). + MutexGuard aGuard( GetOwnStaticMutex() ); + // Increase ouer refcount ... + ++m_nRefCount; + // ... and initialize ouer data container only if it not already! + if( m_pDataContainer == NULL ) + { + RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMenuOptions_Impl::ctor()"); + m_pDataContainer = new SvtMenuOptions_Impl(); + + ItemHolder2::holdConfigItem(E_MENUOPTIONS); + } +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +SvtMenuOptions::~SvtMenuOptions() +{ + // Global access, must be guarded (multithreading!) + MutexGuard aGuard( GetOwnStaticMutex() ); + // Decrease ouer refcount. + --m_nRefCount; + // If last instance was deleted ... + // we must destroy ouer static data container! + if( m_nRefCount <= 0 ) + { + delete m_pDataContainer; + m_pDataContainer = NULL; + } +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Bool SvtMenuOptions::IsEntryHidingEnabled() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsEntryHidingEnabled(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Bool SvtMenuOptions::IsFollowMouseEnabled() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsFollowMouseEnabled(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMenuOptions::SetEntryHidingState( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetEntryHidingState( bState ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMenuOptions::SetFollowMouseState( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetFollowMouseState( bState ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Int16 SvtMenuOptions::GetMenuIconsState() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMenuIconsState(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMenuOptions::SetMenuIconsState( sal_Int16 bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMenuIconsState( bState ); +} + +//***************************************************************************************************************** +// private method +//***************************************************************************************************************** +Mutex& SvtMenuOptions::GetOwnStaticMutex() +{ + // Initialize static mutex only for one time! + static Mutex* pMutex = NULL; + // If these method first called (Mutex not already exist!) ... + if( pMutex == NULL ) + { + // ... we must create a new one. Protect follow code with the global mutex - + // It must be - we create a static variable! + MutexGuard aGuard( Mutex::getGlobalMutex() ); + // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! + if( pMutex == NULL ) + { + // Create the new mutex and set it for return on static variable. + static Mutex aMutex; + pMutex = &aMutex; + } + } + // Return new created or already existing mutex object. + return *pMutex; +} + +void SvtMenuOptions::AddListenerLink( const Link& rLink ) +{ + m_pDataContainer->AddListenerLink( rLink ); +} + +void SvtMenuOptions::RemoveListenerLink( const Link& rLink ) +{ + m_pDataContainer->RemoveListenerLink( rLink ); +} diff --git a/svtools/source/config/miscopt.cxx b/svtools/source/config/miscopt.cxx new file mode 100644 index 000000000000..7b04b56104e0 --- /dev/null +++ b/svtools/source/config/miscopt.cxx @@ -0,0 +1,831 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" +//_________________________________________________________________________________________________________________ +// includes +//_________________________________________________________________________________________________________________ + +#include <svtools/miscopt.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 <tools/link.hxx> +#include <tools/list.hxx> +#include <tools/wldcrd.hxx> +#include <tools/urlobj.hxx> + +#include <rtl/logfile.hxx> +#include "itemholder2.hxx" + +#include <imgdef.hxx> +#include <vcl/svapp.hxx> + +//_________________________________________________________________________________________________________________ +// namespaces +//_________________________________________________________________________________________________________________ + +using namespace ::utl ; +using namespace ::rtl ; +using namespace ::osl ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star; + +//_________________________________________________________________________________________________________________ +// const +//_________________________________________________________________________________________________________________ + +#define ASCII_STR(s) OUString( RTL_CONSTASCII_USTRINGPARAM(s) ) +#define ROOTNODE_MISC ASCII_STR("Office.Common/Misc") +#define DEFAULT_PLUGINSENABLED sal_True; + +#define PROPERTYNAME_PLUGINSENABLED ASCII_STR("PluginsEnabled") +#define PROPERTYHANDLE_PLUGINSENABLED 0 +#define PROPERTYNAME_SYMBOLSET ASCII_STR("SymbolSet") +#define PROPERTYHANDLE_SYMBOLSET 1 +#define PROPERTYNAME_TOOLBOXSTYLE ASCII_STR("ToolboxStyle") +#define PROPERTYHANDLE_TOOLBOXSTYLE 2 +#define PROPERTYNAME_USESYSTEMFILEDIALOG ASCII_STR("UseSystemFileDialog") +#define PROPERTYHANDLE_USESYSTEMFILEDIALOG 3 +#define PROPERTYNAME_SYMBOLSTYLE ASCII_STR("SymbolStyle") +#define PROPERTYHANDLE_SYMBOLSTYLE 4 +#define PROPERTYNAME_USESYSTEMPRINTDIALOG ASCII_STR("UseSystemPrintDialog") +#define PROPERTYHANDLE_USESYSTEMPRINTDIALOG 5 + +#define PROPERTYCOUNT 6 + +#define VCL_TOOLBOX_STYLE_FLAT ((USHORT)0x0004) // from <vcl/toolbox.hxx> + +DECLARE_LIST( LinkList, Link * ) + +//_________________________________________________________________________________________________________________ +// private declarations! +//_________________________________________________________________________________________________________________ + +class SvtMiscOptions_Impl : public ConfigItem +{ + //------------------------------------------------------------------------------------------------------------- + // private member + //------------------------------------------------------------------------------------------------------------- + + private: + LinkList aList; + sal_Bool m_bUseSystemFileDialog; + sal_Bool m_bIsUseSystemFileDialogRO; + sal_Bool m_bPluginsEnabled; + sal_Bool m_bIsPluginsEnabledRO; + sal_Int16 m_nSymbolsSize; + sal_Bool m_bIsSymbolsSizeRO; + sal_Bool m_bIsSymbolsStyleRO; + sal_Int16 m_nToolboxStyle; + sal_Bool m_bIsToolboxStyleRO; + sal_Bool m_bUseSystemPrintDialog; + sal_Bool m_bIsUseSystemPrintDialogRO; + + //------------------------------------------------------------------------------------------------------------- + // public methods + //------------------------------------------------------------------------------------------------------------- + + public: + + //--------------------------------------------------------------------------------------------------------- + // constructor / destructor + //--------------------------------------------------------------------------------------------------------- + + SvtMiscOptions_Impl(); + ~SvtMiscOptions_Impl(); + + //--------------------------------------------------------------------------------------------------------- + // overloaded methods of baseclass + //--------------------------------------------------------------------------------------------------------- + + /*-****************************************************************************************************//** + @short called for notify of configmanager + @descr These method is called from the ConfigManager before application ends or from the + PropertyChangeListener if the sub tree broadcasts changes. You must update your + internal values. + + @seealso baseclass ConfigItem + + @param "seqPropertyNames" is the list of properties which should be updated. + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void Notify( const Sequence< OUString >& seqPropertyNames ); + + /** loads required data from the configuration. It's called in the constructor to + read all entries and form ::Notify to re-read changed settings + + */ + void Load( const Sequence< OUString >& rPropertyNames ); + + /*-****************************************************************************************************//** + @short write changes to configuration + @descr These method writes the changed values into the sub tree + and should always called in our destructor to guarantee consistency of config data. + + @seealso baseclass ConfigItem + + @param - + @return - + + @onerror - + *//*-*****************************************************************************************************/ + + virtual void Commit(); + + //--------------------------------------------------------------------------------------------------------- + // public interface + //--------------------------------------------------------------------------------------------------------- + + inline sal_Bool UseSystemFileDialog() const + { return m_bUseSystemFileDialog; } + + inline void SetUseSystemFileDialog( sal_Bool bSet ) + { m_bUseSystemFileDialog = bSet; SetModified(); } + + inline sal_Bool IsUseSystemFileDialogReadOnly() const + { return m_bIsUseSystemFileDialogRO; } + + inline sal_Bool IsPluginsEnabled() const + { return m_bPluginsEnabled; } + + void SetPluginsEnabled( sal_Bool bEnable ); + + inline sal_Bool IsPluginsEnabledReadOnly() const + { return m_bIsPluginsEnabledRO; } + + inline sal_Int16 GetSymbolsSize() + { return m_nSymbolsSize; } + + void SetSymbolsSize( sal_Int16 nSet ); + + inline sal_Bool IsGetSymbolsSizeReadOnly() + { return m_bIsSymbolsSizeRO; } + + sal_Int16 GetSymbolsStyle() const; + ::rtl::OUString GetSymbolsStyleName() const; + sal_Int16 GetCurrentSymbolsStyle() const; + + inline void SetSymbolsStyle( sal_Int16 nSet ) + { ImplSetSymbolsStyle( true, nSet, ::rtl::OUString() ); } + + inline void SetSymbolsStyleName( ::rtl::OUString &rName ) + { ImplSetSymbolsStyle( false, 0, rName ); } + + inline sal_Bool IsGetSymbolsStyleReadOnly() + { return m_bIsSymbolsStyleRO; } + + // translate to VCL settings ( "0" = 3D, "1" = FLAT ) + inline sal_Int16 GetToolboxStyle() + { return m_nToolboxStyle ? VCL_TOOLBOX_STYLE_FLAT : 0; } + + // translate from VCL settings + void SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified ); + + inline sal_Bool IsGetToolboxStyleReadOnly() + { return m_bIsToolboxStyleRO; } + + inline sal_Bool UseSystemPrintDialog() const + { return m_bUseSystemPrintDialog; } + + inline void SetUseSystemPrintDialog( sal_Bool bSet ) + { m_bUseSystemPrintDialog = bSet; SetModified(); } + + inline sal_Bool IsUseSystemPrintDialogReadOnly() const + { return m_bIsUseSystemPrintDialogRO; } + + void AddListenerLink( const Link& rLink ); + void RemoveListenerLink( const Link& rLink ); + void CallListeners(); + + //------------------------------------------------------------------------------------------------------------- + // private methods + //------------------------------------------------------------------------------------------------------------- + + private: + + /*-****************************************************************************************************//** + @short return list of key names of ouer configuration management which represent oue module tree + @descr These methods return a static const list of key names. We need it to get needed values from our + configuration management. + + @seealso - + + @param - + @return A list of needed configuration keys is returned. + + @onerror - + *//*-*****************************************************************************************************/ + + static Sequence< OUString > GetPropertyNames(); + + protected: + void ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName ); +}; + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +SvtMiscOptions_Impl::SvtMiscOptions_Impl() + // Init baseclasses first + : ConfigItem( ROOTNODE_MISC ) + + , m_bUseSystemFileDialog( sal_False ) + , m_bIsUseSystemFileDialogRO( sal_False ) + , m_bPluginsEnabled( sal_False ) + , m_bIsPluginsEnabledRO( sal_False ) + , m_nSymbolsSize( 0 ) + , m_bIsSymbolsSizeRO( sal_False ) + , m_bIsSymbolsStyleRO( sal_False ) + , m_nToolboxStyle( 1 ) + , m_bIsToolboxStyleRO( sal_False ) + , m_bUseSystemPrintDialog( sal_False ) + , m_bIsUseSystemPrintDialogRO( sal_False ) + +{ + // Use our static list of configuration keys to get his values. + Sequence< OUString > seqNames = GetPropertyNames ( ); + Load( seqNames ); + Sequence< Any > seqValues = GetProperties ( seqNames ); + Sequence< sal_Bool > seqRO = GetReadOnlyStates ( seqNames ); + + // Safe impossible cases. + // We need values from ALL configuration keys. + // Follow assignment use order of values in relation to our list of key names! + DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtMiscOptions_Impl::SvtMiscOptions_Impl()\nI miss some values of configuration keys!\n" ); + + // Copy values from list in right order to ouer internal member. + sal_Int32 nPropertyCount = seqValues.getLength(); + for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) + { + // Safe impossible cases. + // Check any for valid value. + DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" ); + switch( nProperty ) + { + case PROPERTYHANDLE_PLUGINSENABLED : + { + if( !(seqValues[nProperty] >>= m_bPluginsEnabled) ) + { + DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" ); + } + m_bIsPluginsEnabledRO = seqRO[nProperty]; + break; + } + + case PROPERTYHANDLE_SYMBOLSET : + { + if( !(seqValues[nProperty] >>= m_nSymbolsSize) ) + { + DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" ); + } + m_bIsSymbolsSizeRO = seqRO[nProperty]; + break; + } + + case PROPERTYHANDLE_TOOLBOXSTYLE : + { + if( !(seqValues[nProperty] >>= m_nToolboxStyle) ) + { + DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" ); + } + m_bIsToolboxStyleRO = seqRO[nProperty]; + break; + } + + case PROPERTYHANDLE_USESYSTEMFILEDIALOG : + { + if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) ) + { + DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" ); + } + m_bIsUseSystemFileDialogRO = seqRO[nProperty]; + break; + } + + case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : + { + if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) ) + { + DBG_ERROR("Wrong type of \"Misc\\UseSystemPrintDialog\"!" ); + } + m_bIsUseSystemPrintDialogRO = seqRO[nProperty]; + break; + } + + case PROPERTYHANDLE_SYMBOLSTYLE : + { + ::rtl::OUString aSymbolsStyle; + if( seqValues[nProperty] >>= aSymbolsStyle ) + SetSymbolsStyleName( aSymbolsStyle ); + else + { + DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" ); + } + m_bIsSymbolsStyleRO = seqRO[nProperty]; + break; + } + } + } + + // Enable notification mechanism of ouer baseclass. + // We need it to get information about changes outside these class on ouer used configuration keys! + EnableNotification( seqNames ); +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +SvtMiscOptions_Impl::~SvtMiscOptions_Impl() +{ + // We must save our current values .. if user forget it! + if( IsModified() == sal_True ) + { + Commit(); + } + + for ( USHORT n=0; n<aList.Count(); ) + delete aList.Remove(n); +} + +/*-- 25.02.2005 13:22:04--------------------------------------------------- + + -----------------------------------------------------------------------*/ +static int lcl_MapPropertyName( const ::rtl::OUString rCompare, + const uno::Sequence< ::rtl::OUString>& aInternalPropertyNames) +{ + for(int nProp = 0; nProp < aInternalPropertyNames.getLength(); ++nProp) + { + if( aInternalPropertyNames[nProp] == rCompare ) + return nProp; + } + return -1; +} + +void SvtMiscOptions_Impl::Load( const Sequence< OUString >& rPropertyNames ) +{ + const uno::Sequence< ::rtl::OUString> aInternalPropertyNames( GetPropertyNames()); + Sequence< Any > seqValues = GetProperties( rPropertyNames ); + + // Safe impossible cases. + // We need values from ALL configuration keys. + // Follow assignment use order of values in relation to our list of key names! + DBG_ASSERT( !(rPropertyNames.getLength()!=seqValues.getLength()), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nI miss some values of configuration keys!\n" ); + + // Copy values from list in right order to ouer internal member. + sal_Int32 nPropertyCount = seqValues.getLength(); + for( sal_Int32 nProperty=0; nProperty<nPropertyCount; ++nProperty ) + { + // Safe impossible cases. + // Check any for valid value. + DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtSecurityOptions_Impl::SvtSecurityOptions_Impl()\nInvalid property value detected!\n" ); + switch( lcl_MapPropertyName(rPropertyNames[nProperty], aInternalPropertyNames) ) + { + case PROPERTYHANDLE_PLUGINSENABLED : { + if( !(seqValues[nProperty] >>= m_bPluginsEnabled) ) + { + DBG_ERROR("Wrong type of \"Misc\\PluginsEnabled\"!" ); + } + } + break; + case PROPERTYHANDLE_SYMBOLSET : { + if( !(seqValues[nProperty] >>= m_nSymbolsSize) ) + { + DBG_ERROR("Wrong type of \"Misc\\SymbolSet\"!" ); + } + } + break; + case PROPERTYHANDLE_TOOLBOXSTYLE : { + if( !(seqValues[nProperty] >>= m_nToolboxStyle) ) + { + DBG_ERROR("Wrong type of \"Misc\\ToolboxStyle\"!" ); + } + } + break; + case PROPERTYHANDLE_USESYSTEMFILEDIALOG : { + if( !(seqValues[nProperty] >>= m_bUseSystemFileDialog) ) + { + DBG_ERROR("Wrong type of \"Misc\\UseSystemFileDialog\"!" ); + } + } + break; + case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : { + if( !(seqValues[nProperty] >>= m_bUseSystemPrintDialog) ) + { + DBG_ERROR("Wrong type of \"Misc\\UseSystemPrintDialog\"!" ); + } + } + break; + case PROPERTYHANDLE_SYMBOLSTYLE : { + ::rtl::OUString aSymbolsStyle; + if( seqValues[nProperty] >>= aSymbolsStyle ) + SetSymbolsStyleName( aSymbolsStyle ); + else + { + DBG_ERROR("Wrong type of \"Misc\\SymbolStyle\"!" ); + } + } + break; + } + } +} + +void SvtMiscOptions_Impl::AddListenerLink( const Link& rLink ) +{ + aList.Insert( new Link( rLink ) ); +} + +void SvtMiscOptions_Impl::RemoveListenerLink( const Link& rLink ) +{ + for ( USHORT n=0; n<aList.Count(); n++ ) + { + if ( (*aList.GetObject(n) ) == rLink ) + { + delete aList.Remove(n); + break; + } + } +} + +void SvtMiscOptions_Impl::CallListeners() +{ + for ( USHORT n = 0; n < aList.Count(); ++n ) + aList.GetObject(n)->Call( this ); +} + +void SvtMiscOptions_Impl::SetToolboxStyle( sal_Int16 nStyle, bool _bSetModified ) +{ + m_nToolboxStyle = nStyle ? 1 : 0; + if ( _bSetModified ) + SetModified(); + CallListeners(); +} + +void SvtMiscOptions_Impl::SetSymbolsSize( sal_Int16 nSet ) +{ + m_nSymbolsSize = nSet; + SetModified(); + CallListeners(); +} + +sal_Int16 SvtMiscOptions_Impl::GetSymbolsStyle() const +{ + return (sal_Int16)Application::GetSettings().GetStyleSettings().GetSymbolsStyle(); +} + +::rtl::OUString SvtMiscOptions_Impl::GetSymbolsStyleName() const +{ + return Application::GetSettings().GetStyleSettings().GetSymbolsStyleName(); +} + +sal_Int16 SvtMiscOptions_Impl::GetCurrentSymbolsStyle() const +{ + return (sal_Int16)Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyle(); +} + +void SvtMiscOptions_Impl::ImplSetSymbolsStyle( bool bValue, sal_Int16 nSet, const ::rtl::OUString &rName ) +{ + if ( ( bValue && ( nSet != GetSymbolsStyle() ) ) || + ( !bValue && ( rName != GetSymbolsStyleName() ) ) ) + { + AllSettings aAllSettings = Application::GetSettings(); + StyleSettings aStyleSettings = aAllSettings.GetStyleSettings(); + + if ( bValue ) + aStyleSettings.SetSymbolsStyle( nSet ); + else + aStyleSettings.SetSymbolsStyleName( rName ); + + aAllSettings.SetStyleSettings(aStyleSettings); + Application::MergeSystemSettings( aAllSettings ); + Application::SetSettings(aAllSettings); + + SetModified(); + CallListeners(); + } +} + +void SvtMiscOptions_Impl::SetPluginsEnabled( sal_Bool bEnable ) +{ + m_bPluginsEnabled = bEnable; + SetModified(); + CallListeners(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMiscOptions_Impl::Notify( const Sequence< OUString >& rPropertyNames ) +{ + Load( rPropertyNames ); + CallListeners(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtMiscOptions_Impl::Commit() +{ + // Get names of supported properties, create a list for values and copy current values to it. + Sequence< OUString > seqNames = GetPropertyNames (); + sal_Int32 nCount = seqNames.getLength(); + Sequence< Any > seqValues ( nCount ); + for( sal_Int32 nProperty=0; nProperty<nCount; ++nProperty ) + { + switch( nProperty ) + { + case PROPERTYHANDLE_PLUGINSENABLED : + { + if ( !m_bIsPluginsEnabledRO ) + seqValues[nProperty] <<= m_bPluginsEnabled; + break; + } + + case PROPERTYHANDLE_SYMBOLSET : + { + if ( !m_bIsSymbolsSizeRO ) + seqValues[nProperty] <<= m_nSymbolsSize; + break; + } + + case PROPERTYHANDLE_TOOLBOXSTYLE : + { + if ( !m_bIsToolboxStyleRO ) + seqValues[nProperty] <<= m_nToolboxStyle; + break; + } + + case PROPERTYHANDLE_USESYSTEMFILEDIALOG : + { + if ( !m_bIsUseSystemFileDialogRO ) + seqValues[nProperty] <<= m_bUseSystemFileDialog; + break; + } + + case PROPERTYHANDLE_SYMBOLSTYLE : + { + if ( !m_bIsSymbolsStyleRO ) + seqValues[nProperty] <<= GetSymbolsStyleName(); + break; + } + + case PROPERTYHANDLE_USESYSTEMPRINTDIALOG : + { + if ( !m_bIsUseSystemPrintDialogRO ) + seqValues[nProperty] <<= m_bUseSystemPrintDialog; + break; + } + } + } + // Set properties in configuration. + PutProperties( seqNames, seqValues ); +} + +//***************************************************************************************************************** +// private method +//***************************************************************************************************************** +Sequence< OUString > SvtMiscOptions_Impl::GetPropertyNames() +{ + // Build static list of configuration key names. + static const OUString pProperties[] = + { + PROPERTYNAME_PLUGINSENABLED, + PROPERTYNAME_SYMBOLSET, + PROPERTYNAME_TOOLBOXSTYLE, + PROPERTYNAME_USESYSTEMFILEDIALOG, + PROPERTYNAME_SYMBOLSTYLE, + PROPERTYNAME_USESYSTEMPRINTDIALOG + }; + + // Initialize return sequence with these list ... + static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); + // ... and return it. + return seqPropertyNames; +} + +//***************************************************************************************************************** +// initialize static member +// DON'T DO IT IN YOUR HEADER! +// see definition for further informations +//***************************************************************************************************************** +SvtMiscOptions_Impl* SvtMiscOptions::m_pDataContainer = NULL ; +sal_Int32 SvtMiscOptions::m_nRefCount = 0 ; + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +SvtMiscOptions::SvtMiscOptions() +{ + // Global access, must be guarded (multithreading!). + MutexGuard aGuard( GetInitMutex() ); + // Increase ouer refcount ... + ++m_nRefCount; + // ... and initialize ouer data container only if it not already exist! + if( m_pDataContainer == NULL ) + { + RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtMiscOptions_Impl::ctor()"); + m_pDataContainer = new SvtMiscOptions_Impl; + ItemHolder2::holdConfigItem(E_MISCOPTIONS); + } +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +SvtMiscOptions::~SvtMiscOptions() +{ + // Global access, must be guarded (multithreading!) + MutexGuard aGuard( GetInitMutex() ); + // Decrease ouer refcount. + --m_nRefCount; + // If last instance was deleted ... + // we must destroy ouer static data container! + if( m_nRefCount <= 0 ) + { + delete m_pDataContainer; + m_pDataContainer = NULL; + } +} + +sal_Bool SvtMiscOptions::UseSystemFileDialog() const +{ + return m_pDataContainer->UseSystemFileDialog(); +} + +void SvtMiscOptions::SetUseSystemFileDialog( sal_Bool bEnable ) +{ + m_pDataContainer->SetUseSystemFileDialog( bEnable ); +} + +sal_Bool SvtMiscOptions::IsUseSystemFileDialogReadOnly() const +{ + return m_pDataContainer->IsUseSystemFileDialogReadOnly(); +} + +sal_Bool SvtMiscOptions::IsPluginsEnabled() const +{ + return m_pDataContainer->IsPluginsEnabled(); +} + +void SvtMiscOptions::SetPluginsEnabled( sal_Bool bEnable ) +{ + m_pDataContainer->SetPluginsEnabled( bEnable ); +} + +sal_Bool SvtMiscOptions::IsPluginsEnabledReadOnly() const +{ + return m_pDataContainer->IsPluginsEnabledReadOnly(); +} + +sal_Int16 SvtMiscOptions::GetSymbolsSize() const +{ + return m_pDataContainer->GetSymbolsSize(); +} + +void SvtMiscOptions::SetSymbolsSize( sal_Int16 nSet ) +{ + m_pDataContainer->SetSymbolsSize( nSet ); +} + +sal_Int16 SvtMiscOptions::GetCurrentSymbolsSize() const +{ + sal_Int16 eOptSymbolsSize = m_pDataContainer->GetSymbolsSize(); + + if ( eOptSymbolsSize == SFX_SYMBOLS_SIZE_AUTO ) + { + // Use system settings, we have to retrieve the toolbar icon size from the + // Application class + ULONG nStyleIconSize = Application::GetSettings().GetStyleSettings().GetToolbarIconSize(); + if ( nStyleIconSize == STYLE_TOOLBAR_ICONSIZE_LARGE ) + eOptSymbolsSize = SFX_SYMBOLS_SIZE_LARGE; + else + eOptSymbolsSize = SFX_SYMBOLS_SIZE_SMALL; + } + + return eOptSymbolsSize; +} + +bool SvtMiscOptions::AreCurrentSymbolsLarge() const +{ + return ( GetCurrentSymbolsSize() == SFX_SYMBOLS_SIZE_LARGE ); +} + +sal_Bool SvtMiscOptions::IsGetSymbolsSizeReadOnly() const +{ + return m_pDataContainer->IsGetSymbolsSizeReadOnly(); +} + +sal_Int16 SvtMiscOptions::GetSymbolsStyle() const +{ + return m_pDataContainer->GetSymbolsStyle(); +} + +sal_Int16 SvtMiscOptions::GetCurrentSymbolsStyle() const +{ + return m_pDataContainer->GetCurrentSymbolsStyle(); +} + +OUString SvtMiscOptions::GetCurrentSymbolsStyleName() const +{ + return Application::GetSettings().GetStyleSettings().GetCurrentSymbolsStyleName(); +} + +void SvtMiscOptions::SetSymbolsStyle( sal_Int16 nSet ) +{ + m_pDataContainer->SetSymbolsStyle( nSet ); +} + +sal_Bool SvtMiscOptions::IsGetSymbolsStyleReadOnly() const +{ + return m_pDataContainer->IsGetSymbolsStyleReadOnly(); +} + +sal_Int16 SvtMiscOptions::GetToolboxStyle() const +{ + return m_pDataContainer->GetToolboxStyle(); +} + +void SvtMiscOptions::SetToolboxStyle( sal_Int16 nStyle ) +{ + m_pDataContainer->SetToolboxStyle( nStyle, true ); +} + +sal_Bool SvtMiscOptions::IsGetToolboxStyleReadOnly() const +{ + return m_pDataContainer->IsGetToolboxStyleReadOnly(); +} + +sal_Bool SvtMiscOptions::UseSystemPrintDialog() const +{ + return m_pDataContainer->UseSystemPrintDialog(); +} + +void SvtMiscOptions::SetUseSystemPrintDialog( sal_Bool bEnable ) +{ + m_pDataContainer->SetUseSystemPrintDialog( bEnable ); +} + +//***************************************************************************************************************** +// private method +//***************************************************************************************************************** +Mutex & SvtMiscOptions::GetInitMutex() +{ + // Initialize static mutex only for one time! + static Mutex* pMutex = NULL; + // If these method first called (Mutex not already exist!) ... + if( pMutex == NULL ) + { + // ... we must create a new one. Protect follow code with the global mutex - + // It must be - we create a static variable! + MutexGuard aGuard( Mutex::getGlobalMutex() ); + // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! + if( pMutex == NULL ) + { + // Create the new mutex and set it for return on static variable. + static Mutex aMutex; + pMutex = &aMutex; + } + } + // Return new created or already existing mutex object. + return *pMutex; +} + +void SvtMiscOptions::AddListenerLink( const Link& rLink ) +{ + m_pDataContainer->AddListenerLink( rLink ); +} + +void SvtMiscOptions::RemoveListenerLink( const Link& rLink ) +{ + m_pDataContainer->RemoveListenerLink( rLink ); +} diff --git a/svtools/source/config/optionsdrawinglayer.cxx b/svtools/source/config/optionsdrawinglayer.cxx new file mode 100644 index 000000000000..57cf1cd8ad5b --- /dev/null +++ b/svtools/source/config/optionsdrawinglayer.cxx @@ -0,0 +1,1713 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +#ifdef _MSC_VER +#pragma hdrstop +#endif + +//_________________________________________________________________________________________________________________ +// includes +//_________________________________________________________________________________________________________________ + +#include <svtools/optionsdrawinglayer.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 <vcl/svapp.hxx> +#include <vcl/outdev.hxx> + +//_________________________________________________________________________________________________________________ +// namespaces +//_________________________________________________________________________________________________________________ + +using namespace ::utl ; +using namespace ::rtl ; +using namespace ::osl ; +using namespace ::com::sun::star::uno ; + +//_________________________________________________________________________________________________________________ +// const +//_________________________________________________________________________________________________________________ + +#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Drawinglayer" )) +#define DEFAULT_OVERLAYBUFFER sal_True +#define DEFAULT_PAINTBUFFER sal_True +#define DEFAULT_STRIPE_COLOR_A 0 +#define DEFAULT_STRIPE_COLOR_B 16581375 +#define DEFAULT_STRIPE_LENGTH 4 + +// #i73602# +// #i74769#, #i75172# : Change default for Calc and Writer to True +#define DEFAULT_OVERLAYBUFFER_CALC sal_True +#define DEFAULT_OVERLAYBUFFER_WRITER sal_True +#define DEFAULT_OVERLAYBUFFER_DRAWIMPRESS sal_True + +// #i74769#, #i75172# +#define DEFAULT_PAINTBUFFER_CALC sal_True +#define DEFAULT_PAINTBUFFER_WRITER sal_True +#define DEFAULT_PAINTBUFFER_DRAWIMPRESS sal_True + +// #i4219# +#define DEFAULT_MAXIMUMPAPERWIDTH 300 +#define DEFAULT_MAXIMUMPAPERHEIGHT 300 +#define DEFAULT_MAXIMUMPAPERLEFTMARGIN 9999 +#define DEFAULT_MAXIMUMPAPERRIGHTMARGIN 9999 +#define DEFAULT_MAXIMUMPAPERTOPMARGIN 9999 +#define DEFAULT_MAXIMUMPAPERBOTTOMMARGIN 9999 + +// primitives +#define DEFAULT_ANTIALIASING sal_True +#define DEFAULT_SNAPHORVERLINESTODISCRETE sal_True +#define DEFAULT_SOLIDDRAGCREATE sal_True +#define DEFAULT_RENDERDECORATEDTEXTDIRECT sal_True +#define DEFAULT_RENDERSIMPLETEXTDIRECT sal_True +#define DEFAULT_QUADRATIC3DRENDERLIMIT 1000000 +#define DEFAULT_QUADRATICFORMCONTROLRENDERLIMIT 45000 + +// #i97672# selection settings +#define DEFAULT_TRANSPARENTSELECTION sal_True +#define DEFAULT_TRANSPARENTSELECTIONPERCENT 75 +#define DEFAULT_SELECTIONMAXIMUMLUMINANCEPERCENT 70 + +#define PROPERTYNAME_OVERLAYBUFFER OUString(RTL_CONSTASCII_USTRINGPARAM("OverlayBuffer" )) +#define PROPERTYNAME_PAINTBUFFER OUString(RTL_CONSTASCII_USTRINGPARAM("PaintBuffer" )) +#define PROPERTYNAME_STRIPE_COLOR_A OUString(RTL_CONSTASCII_USTRINGPARAM("StripeColorA" )) +#define PROPERTYNAME_STRIPE_COLOR_B OUString(RTL_CONSTASCII_USTRINGPARAM("StripeColorB" )) +#define PROPERTYNAME_STRIPE_LENGTH OUString(RTL_CONSTASCII_USTRINGPARAM("StripeLength" )) + +// #i73602# +#define PROPERTYNAME_OVERLAYBUFFER_CALC OUString(RTL_CONSTASCII_USTRINGPARAM("OverlayBuffer_Calc")) +#define PROPERTYNAME_OVERLAYBUFFER_WRITER OUString(RTL_CONSTASCII_USTRINGPARAM("OverlayBuffer_Writer")) +#define PROPERTYNAME_OVERLAYBUFFER_DRAWIMPRESS OUString(RTL_CONSTASCII_USTRINGPARAM("OverlayBuffer_DrawImpress")) + +// #i74769#, #i75172# +#define PROPERTYNAME_PAINTBUFFER_CALC OUString(RTL_CONSTASCII_USTRINGPARAM("PaintBuffer_Calc")) +#define PROPERTYNAME_PAINTBUFFER_WRITER OUString(RTL_CONSTASCII_USTRINGPARAM("PaintBuffer_Writer")) +#define PROPERTYNAME_PAINTBUFFER_DRAWIMPRESS OUString(RTL_CONSTASCII_USTRINGPARAM("PaintBuffer_DrawImpress")) + +// #i4219# +#define PROPERTYNAME_MAXIMUMPAPERWIDTH OUString(RTL_CONSTASCII_USTRINGPARAM("MaximumPaperWidth")) +#define PROPERTYNAME_MAXIMUMPAPERHEIGHT OUString(RTL_CONSTASCII_USTRINGPARAM("MaximumPaperHeight")) +#define PROPERTYNAME_MAXIMUMPAPERLEFTMARGIN OUString(RTL_CONSTASCII_USTRINGPARAM("MaximumPaperLeftMargin")) +#define PROPERTYNAME_MAXIMUMPAPERRIGHTMARGIN OUString(RTL_CONSTASCII_USTRINGPARAM("MaximumPaperRightMargin")) +#define PROPERTYNAME_MAXIMUMPAPERTOPMARGIN OUString(RTL_CONSTASCII_USTRINGPARAM("MaximumPaperTopMargin")) +#define PROPERTYNAME_MAXIMUMPAPERBOTTOMMARGIN OUString(RTL_CONSTASCII_USTRINGPARAM("MaximumPaperBottomMargin")) + +// primitives +#define PROPERTYNAME_ANTIALIASING OUString(RTL_CONSTASCII_USTRINGPARAM("AntiAliasing")) +#define PROPERTYNAME_SNAPHORVERLINESTODISCRETE OUString(RTL_CONSTASCII_USTRINGPARAM("SnapHorVerLinesToDiscrete")) +#define PROPERTYNAME_SOLIDDRAGCREATE OUString(RTL_CONSTASCII_USTRINGPARAM("SolidDragCreate")) +#define PROPERTYNAME_RENDERDECORATEDTEXTDIRECT OUString(RTL_CONSTASCII_USTRINGPARAM("RenderDecoratedTextDirect")) +#define PROPERTYNAME_RENDERSIMPLETEXTDIRECT OUString(RTL_CONSTASCII_USTRINGPARAM("RenderSimpleTextDirect")) +#define PROPERTYNAME_QUADRATIC3DRENDERLIMIT OUString(RTL_CONSTASCII_USTRINGPARAM("Quadratic3DRenderLimit")) +#define PROPERTYNAME_QUADRATICFORMCONTROLRENDERLIMIT OUString(RTL_CONSTASCII_USTRINGPARAM("QuadraticFormControlRenderLimit")) + +// #i97672# selection settings +#define PROPERTYNAME_TRANSPARENTSELECTION OUString(RTL_CONSTASCII_USTRINGPARAM("TransparentSelection")) +#define PROPERTYNAME_TRANSPARENTSELECTIONPERCENT OUString(RTL_CONSTASCII_USTRINGPARAM("TransparentSelectionPercent")) +#define PROPERTYNAME_SELECTIONMAXIMUMLUMINANCEPERCENT OUString(RTL_CONSTASCII_USTRINGPARAM("SelectionMaximumLuminancePercent")) + +#define PROPERTYHANDLE_OVERLAYBUFFER 0 +#define PROPERTYHANDLE_PAINTBUFFER 1 +#define PROPERTYHANDLE_STRIPE_COLOR_A 2 +#define PROPERTYHANDLE_STRIPE_COLOR_B 3 +#define PROPERTYHANDLE_STRIPE_LENGTH 4 + +// #i73602# +#define PROPERTYHANDLE_OVERLAYBUFFER_CALC 5 +#define PROPERTYHANDLE_OVERLAYBUFFER_WRITER 6 +#define PROPERTYHANDLE_OVERLAYBUFFER_DRAWIMPRESS 7 + +// #i74769#, #i75172# +#define PROPERTYHANDLE_PAINTBUFFER_CALC 8 +#define PROPERTYHANDLE_PAINTBUFFER_WRITER 9 +#define PROPERTYHANDLE_PAINTBUFFER_DRAWIMPRESS 10 + +// #i4219# +#define PROPERTYHANDLE_MAXIMUMPAPERWIDTH 11 +#define PROPERTYHANDLE_MAXIMUMPAPERHEIGHT 12 +#define PROPERTYHANDLE_MAXIMUMPAPERLEFTMARGIN 13 +#define PROPERTYHANDLE_MAXIMUMPAPERRIGHTMARGIN 14 +#define PROPERTYHANDLE_MAXIMUMPAPERTOPMARGIN 15 +#define PROPERTYHANDLE_MAXIMUMPAPERBOTTOMMARGIN 16 + +// primitives +#define PROPERTYHANDLE_ANTIALIASING 17 +#define PROPERTYHANDLE_SNAPHORVERLINESTODISCRETE 18 +#define PROPERTYHANDLE_SOLIDDRAGCREATE 19 +#define PROPERTYHANDLE_RENDERDECORATEDTEXTDIRECT 20 +#define PROPERTYHANDLE_RENDERSIMPLETEXTDIRECT 21 +#define PROPERTYHANDLE_QUADRATIC3DRENDERLIMIT 22 +#define PROPERTYHANDLE_QUADRATICFORMCONTROLRENDERLIMIT 23 + +// #i97672# selection settings +#define PROPERTYHANDLE_TRANSPARENTSELECTION 24 +#define PROPERTYHANDLE_TRANSPARENTSELECTIONPERCENT 25 +#define PROPERTYHANDLE_SELECTIONMAXIMUMLUMINANCEPERCENT 26 + +#define PROPERTYCOUNT 27 + +class SvtOptionsDrawinglayer_Impl : public ConfigItem +{ +public: + +//--------------------------------------------------------------------------------------------------------- +// constructor / destructor +//--------------------------------------------------------------------------------------------------------- + + SvtOptionsDrawinglayer_Impl(); + ~SvtOptionsDrawinglayer_Impl(); + +//--------------------------------------------------------------------------------------------------------- +// overloaded methods of baseclass +//--------------------------------------------------------------------------------------------------------- + + virtual void Commit(); + virtual void Notify( const com::sun::star::uno::Sequence<rtl::OUString>& aPropertyNames); + +//--------------------------------------------------------------------------------------------------------- +// public interface +//--------------------------------------------------------------------------------------------------------- + + sal_Bool IsOverlayBuffer() const; + sal_Bool IsPaintBuffer() const; + Color GetStripeColorA() const; + Color GetStripeColorB() const; + sal_uInt16 GetStripeLength() const; + + // #i73602# + sal_Bool IsOverlayBuffer_Calc() const; + sal_Bool IsOverlayBuffer_Writer() const; + sal_Bool IsOverlayBuffer_DrawImpress() const; + + // #i74769#, #i75172# + sal_Bool IsPaintBuffer_Calc() const; + sal_Bool IsPaintBuffer_Writer() const; + sal_Bool IsPaintBuffer_DrawImpress() const; + + void SetOverlayBuffer( sal_Bool bState ); + void SetPaintBuffer( sal_Bool bState ); + void SetStripeColorA( Color aColor ); + void SetStripeColorB( Color aColor ); + void SetStripeLength( sal_uInt16 nLength ); + + // #i73602# + void SetOverlayBuffer_Calc( sal_Bool bState ); + void SetOverlayBuffer_Writer( sal_Bool bState ); + void SetOverlayBuffer_DrawImpress( sal_Bool bState ); + + // #i74769#, #i75172# + void SetPaintBuffer_Calc( sal_Bool bState ); + void SetPaintBuffer_Writer( sal_Bool bState ); + void SetPaintBuffer_DrawImpress( sal_Bool bState ); + + // #i4219# + sal_uInt32 GetMaximumPaperWidth() const; + sal_uInt32 GetMaximumPaperHeight() const; + sal_uInt32 GetMaximumPaperLeftMargin() const; + sal_uInt32 GetMaximumPaperRightMargin() const; + sal_uInt32 GetMaximumPaperTopMargin() const; + sal_uInt32 GetMaximumPaperBottomMargin() const; + + void SetMaximumPaperWidth(sal_uInt32 nNew); + void SetMaximumPaperHeight(sal_uInt32 nNew); + void SetMaximumPaperLeftMargin(sal_uInt32 nNew); + void SetMaximumPaperRightMargin(sal_uInt32 nNew); + void SetMaximumPaperTopMargin(sal_uInt32 nNew); + void SetMaximumPaperBottomMargin(sal_uInt32 nNew); + + // helper + sal_Bool IsAAPossibleOnThisSystem() const; + + // primitives + sal_Bool IsAntiAliasing() const; + sal_Bool IsSnapHorVerLinesToDiscrete() const; + sal_Bool IsSolidDragCreate() const; + sal_Bool IsRenderDecoratedTextDirect() const; + sal_Bool IsRenderSimpleTextDirect() const; + sal_uInt32 GetQuadratic3DRenderLimit() const; + sal_uInt32 GetQuadraticFormControlRenderLimit() const; + + void SetAntiAliasing( sal_Bool bState ); + void SetSnapHorVerLinesToDiscrete( sal_Bool bState ); + void SetSolidDragCreate( sal_Bool bState ); + void SetRenderDecoratedTextDirect( sal_Bool bState ); + void SetRenderSimpleTextDirect( sal_Bool bState ); + void SetQuadratic3DRenderLimit(sal_uInt32 nNew); + void SetQuadraticFormControlRenderLimit(sal_uInt32 nNew); + + // #i97672# selection settings + sal_Bool IsTransparentSelection() const; + sal_uInt16 GetTransparentSelectionPercent() const; + sal_uInt16 GetSelectionMaximumLuminancePercent() const; + + void SetTransparentSelection( sal_Bool bState ); + void SetTransparentSelectionPercent( sal_uInt16 nPercent ); + void SetSelectionMaximumLuminancePercent( sal_uInt16 nPercent ); + +//------------------------------------------------------------------------------------------------------------- +// private methods +//------------------------------------------------------------------------------------------------------------- + +private: + + static Sequence< OUString > impl_GetPropertyNames(); + +//------------------------------------------------------------------------------------------------------------- +// private member +//------------------------------------------------------------------------------------------------------------- + +private: + + sal_Bool m_bOverlayBuffer; + sal_Bool m_bPaintBuffer; + Color m_bStripeColorA; + Color m_bStripeColorB; + sal_uInt16 m_nStripeLength; + + // #i73602# + sal_Bool m_bOverlayBuffer_Calc; + sal_Bool m_bOverlayBuffer_Writer; + sal_Bool m_bOverlayBuffer_DrawImpress; + + // #i74769#, #i75172# + sal_Bool m_bPaintBuffer_Calc; + sal_Bool m_bPaintBuffer_Writer; + sal_Bool m_bPaintBuffer_DrawImpress; + + // #i4219# + sal_uInt32 m_nMaximumPaperWidth; + sal_uInt32 m_nMaximumPaperHeight; + sal_uInt32 m_nMaximumPaperLeftMargin; + sal_uInt32 m_nMaximumPaperRightMargin; + sal_uInt32 m_nMaximumPaperTopMargin; + sal_uInt32 m_nMaximumPaperBottomMargin; + + // primitives + sal_Bool m_bAntiAliasing; + sal_Bool m_bSnapHorVerLinesToDiscrete; + sal_Bool m_bSolidDragCreate; + sal_Bool m_bRenderDecoratedTextDirect; + sal_Bool m_bRenderSimpleTextDirect; + sal_uInt32 m_nQuadratic3DRenderLimit; + sal_uInt32 m_nQuadraticFormControlRenderLimit; + + // #i97672# selection settings + sal_uInt16 m_nTransparentSelectionPercent; + sal_uInt16 m_nSelectionMaximumLuminancePercent; + sal_Bool m_bTransparentSelection; + + // local values + bool m_bAllowAA : 1; + bool m_bAllowAAChecked : 1; +}; + +//_________________________________________________________________________________________________________________ +// definitions +//_________________________________________________________________________________________________________________ + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl() : + ConfigItem( ROOTNODE_START ), + m_bOverlayBuffer( DEFAULT_OVERLAYBUFFER ), + m_bPaintBuffer( DEFAULT_PAINTBUFFER ), + m_bStripeColorA(Color(DEFAULT_STRIPE_COLOR_A)), + m_bStripeColorB(Color(DEFAULT_STRIPE_COLOR_B)), + m_nStripeLength(DEFAULT_STRIPE_LENGTH), + + // #i73602# + m_bOverlayBuffer_Calc( DEFAULT_OVERLAYBUFFER_CALC ), + m_bOverlayBuffer_Writer( DEFAULT_OVERLAYBUFFER_WRITER ), + m_bOverlayBuffer_DrawImpress( DEFAULT_OVERLAYBUFFER_DRAWIMPRESS ), + + // #i74769#, #i75172# + m_bPaintBuffer_Calc( DEFAULT_PAINTBUFFER_CALC ), + m_bPaintBuffer_Writer( DEFAULT_PAINTBUFFER_WRITER ), + m_bPaintBuffer_DrawImpress( DEFAULT_PAINTBUFFER_DRAWIMPRESS ), + + // #i4219# + m_nMaximumPaperWidth(DEFAULT_MAXIMUMPAPERWIDTH), + m_nMaximumPaperHeight(DEFAULT_MAXIMUMPAPERHEIGHT), + m_nMaximumPaperLeftMargin(DEFAULT_MAXIMUMPAPERLEFTMARGIN), + m_nMaximumPaperRightMargin(DEFAULT_MAXIMUMPAPERRIGHTMARGIN), + m_nMaximumPaperTopMargin(DEFAULT_MAXIMUMPAPERTOPMARGIN), + m_nMaximumPaperBottomMargin(DEFAULT_MAXIMUMPAPERBOTTOMMARGIN), + + // primitives + m_bAntiAliasing(DEFAULT_ANTIALIASING), + m_bSnapHorVerLinesToDiscrete(DEFAULT_SNAPHORVERLINESTODISCRETE), + m_bSolidDragCreate(DEFAULT_SOLIDDRAGCREATE), + m_bRenderDecoratedTextDirect(DEFAULT_RENDERDECORATEDTEXTDIRECT), + m_bRenderSimpleTextDirect(DEFAULT_RENDERSIMPLETEXTDIRECT), + m_nQuadratic3DRenderLimit(DEFAULT_QUADRATIC3DRENDERLIMIT), + m_nQuadraticFormControlRenderLimit(DEFAULT_QUADRATICFORMCONTROLRENDERLIMIT), + + // #i97672# selection settings + m_nTransparentSelectionPercent(DEFAULT_TRANSPARENTSELECTIONPERCENT), + m_nSelectionMaximumLuminancePercent(DEFAULT_SELECTIONMAXIMUMLUMINANCEPERCENT), + m_bTransparentSelection(DEFAULT_TRANSPARENTSELECTION), + + // local values + m_bAllowAA(true), + m_bAllowAAChecked(false) +{ + Sequence< OUString > seqNames( impl_GetPropertyNames() ); + Sequence< Any > seqValues = GetProperties( seqNames ) ; + + DBG_ASSERT( !(seqNames.getLength()!=seqValues.getLength()), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nI miss some values of configuration keys!\n" ); + + // Copy values from list in right order to ouer internal member. + sal_Int32 nPropertyCount = seqValues.getLength(); + sal_Int32 nProperty = 0; + + for( nProperty=0; nProperty<nPropertyCount; ++nProperty ) + { + DBG_ASSERT( !(seqValues[nProperty].hasValue()==sal_False), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nInvalid property value for property detected!\n" ); + + switch( nProperty ) + { + case PROPERTYHANDLE_OVERLAYBUFFER: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer\"?" ); + seqValues[nProperty] >>= m_bOverlayBuffer; + } + break; + + case PROPERTYHANDLE_PAINTBUFFER: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer\"?" ); + seqValues[nProperty] >>= m_bPaintBuffer; + } + break; + + case PROPERTYHANDLE_STRIPE_COLOR_A: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\StripeColorA\"?" ); + sal_Int32 nValue = 0; + seqValues[nProperty] >>= nValue; + m_bStripeColorA = nValue; + } + break; + + case PROPERTYHANDLE_STRIPE_COLOR_B: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\StripeColorB\"?" ); + sal_Int32 nValue = 0; + seqValues[nProperty] >>= nValue; + m_bStripeColorB = nValue; + } + break; + + case PROPERTYHANDLE_STRIPE_LENGTH: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\StripeLength\"?" ); + seqValues[nProperty] >>= m_nStripeLength; + } + break; + + // #i73602# + case PROPERTYHANDLE_OVERLAYBUFFER_CALC: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer_Calc\"?" ); + seqValues[nProperty] >>= m_bOverlayBuffer_Calc; + } + break; + + case PROPERTYHANDLE_OVERLAYBUFFER_WRITER: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer_Writer\"?" ); + seqValues[nProperty] >>= m_bOverlayBuffer_Writer; + } + break; + + case PROPERTYHANDLE_OVERLAYBUFFER_DRAWIMPRESS: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\OverlayBuffer_DrawImpress\"?" ); + seqValues[nProperty] >>= m_bOverlayBuffer_DrawImpress; + } + break; + + // #i74769#, #i75172# + case PROPERTYHANDLE_PAINTBUFFER_CALC: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer_Calc\"?" ); + seqValues[nProperty] >>= m_bPaintBuffer_Calc; + } + break; + + case PROPERTYHANDLE_PAINTBUFFER_WRITER: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer_Writer\"?" ); + seqValues[nProperty] >>= m_bPaintBuffer_Writer; + } + break; + + case PROPERTYHANDLE_PAINTBUFFER_DRAWIMPRESS: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\PaintBuffer_DrawImpress\"?" ); + seqValues[nProperty] >>= m_bPaintBuffer_DrawImpress; + } + break; + + // #i4219# + case PROPERTYHANDLE_MAXIMUMPAPERWIDTH: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperWidth\"?" ); + seqValues[nProperty] >>= m_nMaximumPaperWidth; + } + break; + + case PROPERTYHANDLE_MAXIMUMPAPERHEIGHT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperHeight\"?" ); + seqValues[nProperty] >>= m_nMaximumPaperHeight; + } + break; + + case PROPERTYHANDLE_MAXIMUMPAPERLEFTMARGIN: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperLeftMargin\"?" ); + seqValues[nProperty] >>= m_nMaximumPaperLeftMargin; + } + break; + + case PROPERTYHANDLE_MAXIMUMPAPERRIGHTMARGIN: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperRightMargin\"?" ); + seqValues[nProperty] >>= m_nMaximumPaperRightMargin; + } + break; + + case PROPERTYHANDLE_MAXIMUMPAPERTOPMARGIN: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperTopMargin\"?" ); + seqValues[nProperty] >>= m_nMaximumPaperTopMargin; + } + break; + + case PROPERTYHANDLE_MAXIMUMPAPERBOTTOMMARGIN: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\MaximumPaperBottomMargin\"?" ); + seqValues[nProperty] >>= m_nMaximumPaperBottomMargin; + } + break; + + // primitives + case PROPERTYHANDLE_ANTIALIASING: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\AntiAliasing\"?" ); + seqValues[nProperty] >>= m_bAntiAliasing; + } + break; + + // primitives + case PROPERTYHANDLE_SNAPHORVERLINESTODISCRETE: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\SnapHorVerLinesToDiscrete\"?" ); + seqValues[nProperty] >>= m_bSnapHorVerLinesToDiscrete; + } + break; + + case PROPERTYHANDLE_SOLIDDRAGCREATE: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\SolidDragCreate\"?" ); + seqValues[nProperty] >>= m_bSolidDragCreate; + } + break; + + case PROPERTYHANDLE_RENDERDECORATEDTEXTDIRECT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\RenderDecoratedTextDirect\"?" ); + seqValues[nProperty] >>= m_bRenderDecoratedTextDirect; + } + break; + + case PROPERTYHANDLE_RENDERSIMPLETEXTDIRECT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\RenderSimpleTextDirect\"?" ); + seqValues[nProperty] >>= m_bRenderSimpleTextDirect; + } + break; + + case PROPERTYHANDLE_QUADRATIC3DRENDERLIMIT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\Quadratic3DRenderLimit\"?" ); + seqValues[nProperty] >>= m_nQuadratic3DRenderLimit; + } + break; + + case PROPERTYHANDLE_QUADRATICFORMCONTROLRENDERLIMIT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_LONG), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\QuadraticFormControlRenderLimit\"?" ); + seqValues[nProperty] >>= m_nQuadraticFormControlRenderLimit; + } + break; + + // #i97672# selection settings + case PROPERTYHANDLE_TRANSPARENTSELECTION: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_BOOLEAN), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\TransparentSelection\"?" ); + seqValues[nProperty] >>= m_bTransparentSelection; + } + break; + + case PROPERTYHANDLE_TRANSPARENTSELECTIONPERCENT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\TransparentSelectionPercent\"?" ); + seqValues[nProperty] >>= m_nTransparentSelectionPercent; + } + + case PROPERTYHANDLE_SELECTIONMAXIMUMLUMINANCEPERCENT: + { + DBG_ASSERT(!(seqValues[nProperty].getValueTypeClass()!=TypeClass_SHORT), "SvtOptionsDrawinglayer_Impl::SvtOptionsDrawinglayer_Impl()\nWho has changed the value type of \"Office.Common\\Drawinglayer\\SelectionMaximumLuminancePercent\"?" ); + seqValues[nProperty] >>= m_nSelectionMaximumLuminancePercent; + } + break; + } + } +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +SvtOptionsDrawinglayer_Impl::~SvtOptionsDrawinglayer_Impl() +{ + if( IsModified() ) + Commit(); +} + +//***************************************************************************************************************** +// Commit +//***************************************************************************************************************** +void SvtOptionsDrawinglayer_Impl::Commit() +{ + Sequence< OUString > aSeqNames( impl_GetPropertyNames() ); + Sequence< Any > aSeqValues( aSeqNames.getLength() ); + + for( sal_Int32 nProperty = 0, nCount = aSeqNames.getLength(); nProperty < nCount; ++nProperty ) + { + switch( nProperty ) + { + case PROPERTYHANDLE_OVERLAYBUFFER: + aSeqValues[nProperty] <<= m_bOverlayBuffer; + break; + + case PROPERTYHANDLE_PAINTBUFFER: + aSeqValues[nProperty] <<= m_bPaintBuffer; + break; + + case PROPERTYHANDLE_STRIPE_COLOR_A: + aSeqValues[nProperty] <<= m_bStripeColorA.GetColor(); + break; + + case PROPERTYHANDLE_STRIPE_COLOR_B: + aSeqValues[nProperty] <<= m_bStripeColorB.GetColor(); + break; + + case PROPERTYHANDLE_STRIPE_LENGTH: + aSeqValues[nProperty] <<= m_nStripeLength; + break; + + // #i73602# + case PROPERTYHANDLE_OVERLAYBUFFER_CALC: + aSeqValues[nProperty] <<= m_bOverlayBuffer_Calc; + break; + + case PROPERTYHANDLE_OVERLAYBUFFER_WRITER: + aSeqValues[nProperty] <<= m_bOverlayBuffer_Writer; + break; + + case PROPERTYHANDLE_OVERLAYBUFFER_DRAWIMPRESS: + aSeqValues[nProperty] <<= m_bOverlayBuffer_DrawImpress; + break; + + // #i74769#, #i75172# + case PROPERTYHANDLE_PAINTBUFFER_CALC: + aSeqValues[nProperty] <<= m_bPaintBuffer_Calc; + break; + + case PROPERTYHANDLE_PAINTBUFFER_WRITER: + aSeqValues[nProperty] <<= m_bPaintBuffer_Writer; + break; + + case PROPERTYHANDLE_PAINTBUFFER_DRAWIMPRESS: + aSeqValues[nProperty] <<= m_bPaintBuffer_DrawImpress; + break; + + // #i4219# + case PROPERTYHANDLE_MAXIMUMPAPERWIDTH: + aSeqValues[nProperty] <<= m_nMaximumPaperWidth; + break; + + case PROPERTYHANDLE_MAXIMUMPAPERHEIGHT: + aSeqValues[nProperty] <<= m_nMaximumPaperHeight; + break; + + case PROPERTYHANDLE_MAXIMUMPAPERLEFTMARGIN: + aSeqValues[nProperty] <<= m_nMaximumPaperLeftMargin; + break; + + case PROPERTYHANDLE_MAXIMUMPAPERRIGHTMARGIN: + aSeqValues[nProperty] <<= m_nMaximumPaperRightMargin; + break; + + case PROPERTYHANDLE_MAXIMUMPAPERTOPMARGIN: + aSeqValues[nProperty] <<= m_nMaximumPaperTopMargin; + break; + + case PROPERTYHANDLE_MAXIMUMPAPERBOTTOMMARGIN: + aSeqValues[nProperty] <<= m_nMaximumPaperBottomMargin; + break; + + // primitives + case PROPERTYHANDLE_ANTIALIASING: + aSeqValues[nProperty] <<= m_bAntiAliasing; + break; + + case PROPERTYHANDLE_SNAPHORVERLINESTODISCRETE: + aSeqValues[nProperty] <<= m_bSnapHorVerLinesToDiscrete; + break; + + case PROPERTYHANDLE_SOLIDDRAGCREATE: + aSeqValues[nProperty] <<= m_bSolidDragCreate; + break; + + case PROPERTYHANDLE_RENDERDECORATEDTEXTDIRECT: + aSeqValues[nProperty] <<= m_bRenderDecoratedTextDirect; + break; + + case PROPERTYHANDLE_RENDERSIMPLETEXTDIRECT: + aSeqValues[nProperty] <<= m_bRenderSimpleTextDirect; + break; + + case PROPERTYHANDLE_QUADRATIC3DRENDERLIMIT: + aSeqValues[nProperty] <<= m_nQuadratic3DRenderLimit; + break; + + case PROPERTYHANDLE_QUADRATICFORMCONTROLRENDERLIMIT: + aSeqValues[nProperty] <<= m_nQuadraticFormControlRenderLimit; + break; + + // #i97672# selection settings + case PROPERTYHANDLE_TRANSPARENTSELECTION: + aSeqValues[nProperty] <<= m_bTransparentSelection; + break; + + case PROPERTYHANDLE_TRANSPARENTSELECTIONPERCENT: + aSeqValues[nProperty] <<= m_nTransparentSelectionPercent; + break; + + case PROPERTYHANDLE_SELECTIONMAXIMUMLUMINANCEPERCENT: + aSeqValues[nProperty] <<= m_nSelectionMaximumLuminancePercent; + break; + } + } + + PutProperties( aSeqNames, aSeqValues ); +} + +void SvtOptionsDrawinglayer_Impl::Notify( const com::sun::star::uno::Sequence<rtl::OUString>& ) +{ +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Bool SvtOptionsDrawinglayer_Impl::IsOverlayBuffer() const +{ + return m_bOverlayBuffer; +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Bool SvtOptionsDrawinglayer_Impl::IsPaintBuffer() const +{ + return m_bPaintBuffer; +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +Color SvtOptionsDrawinglayer_Impl::GetStripeColorA() const +{ + return m_bStripeColorA; +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +Color SvtOptionsDrawinglayer_Impl::GetStripeColorB() const +{ + return m_bStripeColorB; +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_uInt16 SvtOptionsDrawinglayer_Impl::GetStripeLength() const +{ + return m_nStripeLength; +} + +// #i73602# +sal_Bool SvtOptionsDrawinglayer_Impl::IsOverlayBuffer_Calc() const +{ + return m_bOverlayBuffer_Calc; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsOverlayBuffer_Writer() const +{ + return m_bOverlayBuffer_Writer; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsOverlayBuffer_DrawImpress() const +{ + return m_bOverlayBuffer_DrawImpress; +} + +// #i74769#, #i75172# +sal_Bool SvtOptionsDrawinglayer_Impl::IsPaintBuffer_Calc() const +{ + return m_bPaintBuffer_Calc; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsPaintBuffer_Writer() const +{ + return m_bPaintBuffer_Writer; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsPaintBuffer_DrawImpress() const +{ + return m_bPaintBuffer_DrawImpress; +} + +// #i4219# +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetMaximumPaperWidth() const +{ + return m_nMaximumPaperWidth; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetMaximumPaperHeight() const +{ + return m_nMaximumPaperHeight; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetMaximumPaperLeftMargin() const +{ + return m_nMaximumPaperLeftMargin; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetMaximumPaperRightMargin() const +{ + return m_nMaximumPaperRightMargin; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetMaximumPaperTopMargin() const +{ + return m_nMaximumPaperTopMargin; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetMaximumPaperBottomMargin() const +{ + return m_nMaximumPaperBottomMargin; +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer_Impl::SetOverlayBuffer( sal_Bool bState ) +{ + if(m_bOverlayBuffer != bState) + { + m_bOverlayBuffer = bState; + SetModified(); + } +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer_Impl::SetPaintBuffer( sal_Bool bState ) +{ + if(m_bPaintBuffer != bState) + { + m_bPaintBuffer = bState; + SetModified(); + } +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer_Impl::SetStripeColorA( Color aColor ) +{ + if(m_bStripeColorA != aColor) + { + m_bStripeColorA = aColor; + SetModified(); + } +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer_Impl::SetStripeColorB( Color aColor ) +{ + if(m_bStripeColorB != aColor) + { + m_bStripeColorB = aColor; + SetModified(); + } +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer_Impl::SetStripeLength( sal_uInt16 nLength ) +{ + if(m_nStripeLength != nLength) + { + m_nStripeLength = nLength; + SetModified(); + } +} + +// #i73602# +void SvtOptionsDrawinglayer_Impl::SetOverlayBuffer_Calc( sal_Bool bState ) +{ + if(m_bOverlayBuffer_Calc != bState) + { + m_bOverlayBuffer_Calc = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetOverlayBuffer_Writer( sal_Bool bState ) +{ + if(m_bOverlayBuffer_Writer != bState) + { + m_bOverlayBuffer_Writer = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetOverlayBuffer_DrawImpress( sal_Bool bState ) +{ + if(m_bOverlayBuffer_DrawImpress != bState) + { + m_bOverlayBuffer_DrawImpress = bState; + SetModified(); + } +} + +// #i74769#, #i75172# +void SvtOptionsDrawinglayer_Impl::SetPaintBuffer_Calc( sal_Bool bState ) +{ + if(m_bPaintBuffer_Calc != bState) + { + m_bPaintBuffer_Calc = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetPaintBuffer_Writer( sal_Bool bState ) +{ + if(m_bPaintBuffer_Writer != bState) + { + m_bPaintBuffer_Writer = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetPaintBuffer_DrawImpress( sal_Bool bState ) +{ + if(m_bPaintBuffer_DrawImpress != bState) + { + m_bPaintBuffer_DrawImpress = bState; + SetModified(); + } +} + +// #i4219# +void SvtOptionsDrawinglayer_Impl::SetMaximumPaperWidth( sal_uInt32 nNew ) +{ + if(m_nMaximumPaperWidth != nNew) + { + m_nMaximumPaperWidth = nNew; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetMaximumPaperHeight( sal_uInt32 nNew ) +{ + if(m_nMaximumPaperHeight != nNew) + { + m_nMaximumPaperHeight = nNew; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetMaximumPaperLeftMargin( sal_uInt32 nNew ) +{ + if(m_nMaximumPaperLeftMargin != nNew) + { + m_nMaximumPaperLeftMargin = nNew; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetMaximumPaperRightMargin( sal_uInt32 nNew ) +{ + if(m_nMaximumPaperRightMargin != nNew) + { + m_nMaximumPaperRightMargin = nNew; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetMaximumPaperTopMargin( sal_uInt32 nNew ) +{ + if(m_nMaximumPaperTopMargin != nNew) + { + m_nMaximumPaperTopMargin = nNew; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetMaximumPaperBottomMargin( sal_uInt32 nNew ) +{ + if(m_nMaximumPaperBottomMargin != nNew) + { + m_nMaximumPaperBottomMargin = nNew; + SetModified(); + } +} + +// helper +sal_Bool SvtOptionsDrawinglayer_Impl::IsAAPossibleOnThisSystem() const +{ + if(!m_bAllowAAChecked) + { + SvtOptionsDrawinglayer_Impl* pThat = const_cast< SvtOptionsDrawinglayer_Impl* >(this); + pThat->m_bAllowAAChecked = true; + +#ifdef WIN32 + // WIN32 uses GDIPlus with VCL forthe first incarnation; this will be enhanced + // in the future to use canvases and the canvas renderer, thus a AA-abled + // canvas needs to be checked here in the future. + // Currently, just allow AA for WIN32 +#endif + + // check XRenderExtension + if(m_bAllowAA && !Application::GetDefaultDevice()->supportsOperation( OutDevSupport_TransparentRect )) + { + pThat->m_bAllowAA = false; + } + } + + return m_bAllowAA; +} + +// primitives +sal_Bool SvtOptionsDrawinglayer_Impl::IsAntiAliasing() const +{ + return m_bAntiAliasing; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsSnapHorVerLinesToDiscrete() const +{ + return m_bSnapHorVerLinesToDiscrete; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsSolidDragCreate() const +{ + return m_bSolidDragCreate; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsRenderDecoratedTextDirect() const +{ + return m_bRenderDecoratedTextDirect; +} + +sal_Bool SvtOptionsDrawinglayer_Impl::IsRenderSimpleTextDirect() const +{ + return m_bRenderSimpleTextDirect; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetQuadratic3DRenderLimit() const +{ + return m_nQuadratic3DRenderLimit; +} + +sal_uInt32 SvtOptionsDrawinglayer_Impl::GetQuadraticFormControlRenderLimit() const +{ + return m_nQuadraticFormControlRenderLimit; +} + +void SvtOptionsDrawinglayer_Impl::SetAntiAliasing( sal_Bool bState ) +{ + if(m_bAntiAliasing != bState) + { + m_bAntiAliasing = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetSnapHorVerLinesToDiscrete( sal_Bool bState ) +{ + if(m_bSnapHorVerLinesToDiscrete != bState) + { + m_bSnapHorVerLinesToDiscrete = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetSolidDragCreate( sal_Bool bState ) +{ + if(m_bSolidDragCreate != bState) + { + m_bSolidDragCreate = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetRenderDecoratedTextDirect( sal_Bool bState ) +{ + if(m_bRenderDecoratedTextDirect != bState) + { + m_bRenderDecoratedTextDirect = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetRenderSimpleTextDirect( sal_Bool bState ) +{ + if(m_bRenderSimpleTextDirect != bState) + { + m_bRenderSimpleTextDirect = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetQuadratic3DRenderLimit(sal_uInt32 nNew) +{ + if(m_nQuadratic3DRenderLimit != nNew) + { + m_nQuadratic3DRenderLimit = nNew; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetQuadraticFormControlRenderLimit(sal_uInt32 nNew) +{ + if(m_nQuadraticFormControlRenderLimit != nNew) + { + m_nQuadraticFormControlRenderLimit = nNew; + SetModified(); + } +} + +// #i97672# selection settings +sal_Bool SvtOptionsDrawinglayer_Impl::IsTransparentSelection() const +{ + return m_bTransparentSelection; +} + +void SvtOptionsDrawinglayer_Impl::SetTransparentSelection( sal_Bool bState ) +{ + if(m_bTransparentSelection != bState) + { + m_bTransparentSelection = bState; + SetModified(); + } +} + +void SvtOptionsDrawinglayer_Impl::SetTransparentSelectionPercent( sal_uInt16 nPercent ) +{ + if(m_nTransparentSelectionPercent != nPercent) + { + m_nTransparentSelectionPercent = nPercent; + SetModified(); + } +} + +sal_uInt16 SvtOptionsDrawinglayer_Impl::GetTransparentSelectionPercent() const +{ + return m_nTransparentSelectionPercent; +} + +void SvtOptionsDrawinglayer_Impl::SetSelectionMaximumLuminancePercent( sal_uInt16 nPercent ) +{ + if(m_nSelectionMaximumLuminancePercent != nPercent) + { + m_nSelectionMaximumLuminancePercent = nPercent; + SetModified(); + } +} + +sal_uInt16 SvtOptionsDrawinglayer_Impl::GetSelectionMaximumLuminancePercent() const +{ + return m_nSelectionMaximumLuminancePercent; +} + +//***************************************************************************************************************** +// private method +//***************************************************************************************************************** +Sequence< OUString > SvtOptionsDrawinglayer_Impl::impl_GetPropertyNames() +{ + // Build static list of configuration key names. + static const OUString pProperties[] = + { + PROPERTYNAME_OVERLAYBUFFER , + PROPERTYNAME_PAINTBUFFER , + PROPERTYNAME_STRIPE_COLOR_A , + PROPERTYNAME_STRIPE_COLOR_B , + PROPERTYNAME_STRIPE_LENGTH , + + // #i73602# + PROPERTYNAME_OVERLAYBUFFER_CALC, + PROPERTYNAME_OVERLAYBUFFER_WRITER, + PROPERTYNAME_OVERLAYBUFFER_DRAWIMPRESS, + + // #i74769#, #i75172# + PROPERTYNAME_PAINTBUFFER_CALC, + PROPERTYNAME_PAINTBUFFER_WRITER, + PROPERTYNAME_PAINTBUFFER_DRAWIMPRESS, + + // #i4219# + PROPERTYNAME_MAXIMUMPAPERWIDTH, + PROPERTYNAME_MAXIMUMPAPERHEIGHT, + PROPERTYNAME_MAXIMUMPAPERLEFTMARGIN, + PROPERTYNAME_MAXIMUMPAPERRIGHTMARGIN, + PROPERTYNAME_MAXIMUMPAPERTOPMARGIN, + PROPERTYNAME_MAXIMUMPAPERBOTTOMMARGIN, + + // primitives + PROPERTYNAME_ANTIALIASING, + PROPERTYNAME_SNAPHORVERLINESTODISCRETE, + PROPERTYNAME_SOLIDDRAGCREATE, + PROPERTYNAME_RENDERDECORATEDTEXTDIRECT, + PROPERTYNAME_RENDERSIMPLETEXTDIRECT, + PROPERTYNAME_QUADRATIC3DRENDERLIMIT, + PROPERTYNAME_QUADRATICFORMCONTROLRENDERLIMIT, + + // #i97672# selection settings + PROPERTYNAME_TRANSPARENTSELECTION, + PROPERTYNAME_TRANSPARENTSELECTIONPERCENT, + PROPERTYNAME_SELECTIONMAXIMUMLUMINANCEPERCENT + }; + + // Initialize return sequence with these list ... + static const Sequence< OUString > seqPropertyNames( pProperties, PROPERTYCOUNT ); + // ... and return it. + return seqPropertyNames; +} + +//***************************************************************************************************************** +// initialize static member +// DON'T DO IT IN YOUR HEADER! +// see definition for further informations +//***************************************************************************************************************** +SvtOptionsDrawinglayer_Impl* SvtOptionsDrawinglayer::m_pDataContainer = NULL; +sal_Int32 SvtOptionsDrawinglayer::m_nRefCount = 0; + +//***************************************************************************************************************** +// constructor +//***************************************************************************************************************** +SvtOptionsDrawinglayer::SvtOptionsDrawinglayer() +{ + // Global access, must be guarded (multithreading!). + MutexGuard aGuard( GetOwnStaticMutex() ); + // Increase ouer refcount ... + ++m_nRefCount; + // ... and initialize ouer data container only if it not already! + if( m_pDataContainer == NULL ) + { + m_pDataContainer = new SvtOptionsDrawinglayer_Impl(); + } +} + +//***************************************************************************************************************** +// destructor +//***************************************************************************************************************** +SvtOptionsDrawinglayer::~SvtOptionsDrawinglayer() +{ + // Global access, must be guarded (multithreading!) + MutexGuard aGuard( GetOwnStaticMutex() ); + // Decrease ouer refcount. + --m_nRefCount; + // If last instance was deleted ... + // we must destroy ouer static data container! + if( m_nRefCount <= 0 ) + { + delete m_pDataContainer; + m_pDataContainer = NULL; + } +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Bool SvtOptionsDrawinglayer::IsOverlayBuffer() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsOverlayBuffer(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_Bool SvtOptionsDrawinglayer::IsPaintBuffer() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsPaintBuffer(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +Color SvtOptionsDrawinglayer::GetStripeColorA() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetStripeColorA(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +Color SvtOptionsDrawinglayer::GetStripeColorB() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetStripeColorB(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +sal_uInt16 SvtOptionsDrawinglayer::GetStripeLength() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetStripeLength(); +} + +// #i73602# +sal_Bool SvtOptionsDrawinglayer::IsOverlayBuffer_Calc() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsOverlayBuffer_Calc(); +} + +sal_Bool SvtOptionsDrawinglayer::IsOverlayBuffer_Writer() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsOverlayBuffer_Writer(); +} + +sal_Bool SvtOptionsDrawinglayer::IsOverlayBuffer_DrawImpress() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsOverlayBuffer_DrawImpress(); +} + +// #i74769#, #i75172# +sal_Bool SvtOptionsDrawinglayer::IsPaintBuffer_Calc() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsPaintBuffer_Calc(); +} + +sal_Bool SvtOptionsDrawinglayer::IsPaintBuffer_Writer() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsPaintBuffer_Writer(); +} + +sal_Bool SvtOptionsDrawinglayer::IsPaintBuffer_DrawImpress() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsPaintBuffer_DrawImpress(); +} + +// #i4219# +sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperWidth() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMaximumPaperWidth(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperHeight() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMaximumPaperHeight(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperLeftMargin() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMaximumPaperLeftMargin(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperRightMargin() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMaximumPaperRightMargin(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperTopMargin() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMaximumPaperTopMargin(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetMaximumPaperBottomMargin() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetMaximumPaperBottomMargin(); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer::SetOverlayBuffer( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetOverlayBuffer( bState ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer::SetPaintBuffer( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetPaintBuffer( bState ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer::SetStripeColorA( Color aColor ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetStripeColorA( aColor ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer::SetStripeColorB( Color aColor ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetStripeColorB( aColor ); +} + +//***************************************************************************************************************** +// public method +//***************************************************************************************************************** +void SvtOptionsDrawinglayer::SetStripeLength( sal_uInt16 nLength ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetStripeLength( nLength ); +} + +// #i73602# +void SvtOptionsDrawinglayer::SetOverlayBuffer_Calc( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetOverlayBuffer_Calc( bState ); +} + +void SvtOptionsDrawinglayer::SetOverlayBuffer_Writer( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetOverlayBuffer_Writer( bState ); +} + +void SvtOptionsDrawinglayer::SetOverlayBuffer_DrawImpress( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetOverlayBuffer_DrawImpress( bState ); +} + +// #i74769#, #i75172# +void SvtOptionsDrawinglayer::SetPaintBuffer_Calc( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetPaintBuffer_Calc( bState ); +} + +void SvtOptionsDrawinglayer::SetPaintBuffer_Writer( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetPaintBuffer_Writer( bState ); +} + +void SvtOptionsDrawinglayer::SetPaintBuffer_DrawImpress( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetPaintBuffer_DrawImpress( bState ); +} + +// #i4219# +void SvtOptionsDrawinglayer::SetMaximumPaperWidth( sal_uInt32 nNew ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMaximumPaperWidth( nNew ); +} + +void SvtOptionsDrawinglayer::SetMaximumPaperHeight( sal_uInt32 nNew ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMaximumPaperHeight( nNew ); +} + +void SvtOptionsDrawinglayer::SetMaximumPaperLeftMargin( sal_uInt32 nNew ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMaximumPaperLeftMargin( nNew ); +} + +void SvtOptionsDrawinglayer::SetMaximumPaperRightMargin( sal_uInt32 nNew ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMaximumPaperRightMargin( nNew ); +} + +void SvtOptionsDrawinglayer::SetMaximumPaperTopMargin( sal_uInt32 nNew ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMaximumPaperTopMargin( nNew ); +} + +void SvtOptionsDrawinglayer::SetMaximumPaperBottomMargin( sal_uInt32 nNew ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetMaximumPaperBottomMargin( nNew ); +} + +// helper +sal_Bool SvtOptionsDrawinglayer::IsAAPossibleOnThisSystem() const +{ + return m_pDataContainer->IsAAPossibleOnThisSystem(); +} + +// primitives +sal_Bool SvtOptionsDrawinglayer::IsAntiAliasing() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsAntiAliasing() && IsAAPossibleOnThisSystem(); +} + +sal_Bool SvtOptionsDrawinglayer::IsSnapHorVerLinesToDiscrete() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsAntiAliasing() && m_pDataContainer->IsSnapHorVerLinesToDiscrete(); +} + +sal_Bool SvtOptionsDrawinglayer::IsSolidDragCreate() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsSolidDragCreate(); +} + +sal_Bool SvtOptionsDrawinglayer::IsRenderDecoratedTextDirect() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsRenderDecoratedTextDirect(); +} + +sal_Bool SvtOptionsDrawinglayer::IsRenderSimpleTextDirect() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsRenderSimpleTextDirect(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetQuadratic3DRenderLimit() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetQuadratic3DRenderLimit(); +} + +sal_uInt32 SvtOptionsDrawinglayer::GetQuadraticFormControlRenderLimit() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetQuadraticFormControlRenderLimit(); +} + +void SvtOptionsDrawinglayer::SetAntiAliasing( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetAntiAliasing( bState ); +} + +void SvtOptionsDrawinglayer::SetSnapHorVerLinesToDiscrete( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetSnapHorVerLinesToDiscrete( bState ); +} + +void SvtOptionsDrawinglayer::SetSolidDragCreate( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetSolidDragCreate( bState ); +} + +void SvtOptionsDrawinglayer::SetRenderDecoratedTextDirect( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetRenderDecoratedTextDirect( bState ); +} + +void SvtOptionsDrawinglayer::SetRenderSimpleTextDirect( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetRenderSimpleTextDirect( bState ); +} + +void SvtOptionsDrawinglayer::SetQuadratic3DRenderLimit(sal_uInt32 nNew) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetQuadratic3DRenderLimit( nNew ); +} + +void SvtOptionsDrawinglayer::SetQuadraticFormControlRenderLimit(sal_uInt32 nNew) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetQuadraticFormControlRenderLimit( nNew ); +} + +// #i97672# selection settings +sal_Bool SvtOptionsDrawinglayer::IsTransparentSelection() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsTransparentSelection(); +} + +void SvtOptionsDrawinglayer::SetTransparentSelection( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetTransparentSelection( bState ); +} + +sal_uInt16 SvtOptionsDrawinglayer::GetTransparentSelectionPercent() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + sal_uInt16 aRetval(m_pDataContainer->GetTransparentSelectionPercent()); + + // crop to range [10% .. 90%] + if(aRetval < 10) + { + aRetval = 10; + } + + if(aRetval > 90) + { + aRetval = 90; + } + + return aRetval; +} + +void SvtOptionsDrawinglayer::SetTransparentSelectionPercent( sal_uInt16 nPercent ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + + // crop to range [10% .. 90%] + if(nPercent < 10) + { + nPercent = 10; + } + + if(nPercent > 90) + { + nPercent = 90; + } + + m_pDataContainer->SetTransparentSelectionPercent( nPercent ); +} + +sal_uInt16 SvtOptionsDrawinglayer::GetSelectionMaximumLuminancePercent() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + sal_uInt16 aRetval(m_pDataContainer->GetSelectionMaximumLuminancePercent()); + + // crop to range [0% .. 100%] + if(aRetval > 90) + { + aRetval = 90; + } + + return aRetval; +} + +void SvtOptionsDrawinglayer::SetSelectionMaximumLuminancePercent( sal_uInt16 nPercent ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + + // crop to range [0% .. 100%] + if(nPercent > 90) + { + nPercent = 90; + } + + m_pDataContainer->SetSelectionMaximumLuminancePercent( nPercent ); +} + +//***************************************************************************************************************** +// private method +//***************************************************************************************************************** +Mutex& SvtOptionsDrawinglayer::GetOwnStaticMutex() +{ + // Initialize static mutex only for one time! + static Mutex* pMutex = NULL; + // If these method first called (Mutex not already exist!) ... + if( pMutex == NULL ) + { + // ... we must create a new one. Protect follow code with the global mutex - + // It must be - we create a static variable! + MutexGuard aGuard( Mutex::getGlobalMutex() ); + // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! + if( pMutex == NULL ) + { + // Create the new mutex and set it for return on static variable. + static Mutex aMutex; + pMutex = &aMutex; + } + } + // Return new created or already existing mutex object. + return *pMutex; +} + +// eof + diff --git a/svtools/source/config/printoptions.cxx b/svtools/source/config/printoptions.cxx new file mode 100644 index 000000000000..46e1f737d347 --- /dev/null +++ b/svtools/source/config/printoptions.cxx @@ -0,0 +1,870 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +//_________________________________________________________________________________________________________________ +// includes +//_________________________________________________________________________________________________________________ + +#include <svtools/printoptions.hxx> +#include <unotools/configmgr.hxx> +#include <unotools/configitem.hxx> +#include <tools/debug.hxx> +#include <vcl/print.hxx> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Sequence.hxx> + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ +#include <com/sun/star/container/XNameAccess.hpp> +#endif + +#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ +#include <com/sun/star/container/XNameContainer.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XSingleServiceFactory.hpp> +#endif + +#ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_ +#include <comphelper/configurationhelper.hxx> +#endif + +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif + +#ifndef _SVT_LOGHELPER_HXX +#include <unotools/loghelper.hxx> +#endif + +#include <itemholder2.hxx> + + +// ----------- +// - statics - +// ----------- + +static USHORT aDPIArray[] = { 72, 96, 150, 200, 300, 600 }; + +#define DPI_COUNT (sizeof(aDPIArray)/sizeof(aDPIArray[0 ])) + +// ----------- +// - Defines - +// ----------- + +#define ROOTNODE_START OUString(RTL_CONSTASCII_USTRINGPARAM("Office.Common/Print/Option")) +#define ROOTNODE_PRINTOPTION OUString(RTL_CONSTASCII_USTRINGPARAM("org.openoffice.Office.Common/Print/Option")) + +#define PROPERTYNAME_REDUCETRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceTransparency")) +#define PROPERTYNAME_REDUCEDTRANSPARENCYMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedTransparencyMode")) +#define PROPERTYNAME_REDUCEGRADIENTS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceGradients")) +#define PROPERTYNAME_REDUCEDGRADIENTMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientMode")) +#define PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedGradientStepCount")) +#define PROPERTYNAME_REDUCEBITMAPS OUString(RTL_CONSTASCII_USTRINGPARAM("ReduceBitmaps")) +#define PROPERTYNAME_REDUCEDBITMAPMODE OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapMode")) +#define PROPERTYNAME_REDUCEDBITMAPRESOLUTION OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapResolution")) +#define PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY OUString(RTL_CONSTASCII_USTRINGPARAM("ReducedBitmapIncludesTransparency")) +#define PROPERTYNAME_CONVERTTOGREYSCALES OUString(RTL_CONSTASCII_USTRINGPARAM("ConvertToGreyscales")) + +// -------------- +// - Namespaces - +// -------------- + +using namespace ::utl; +using namespace ::rtl; +using namespace ::osl; +using namespace ::com::sun::star::uno; +namespace css = com::sun::star; + +// ----------- +// - statics - +// ----------- + +static SvtPrintOptions_Impl* pPrinterOptionsDataContainer = NULL; +static SvtPrintOptions_Impl* pPrintFileOptionsDataContainer = NULL; + +SvtPrintOptions_Impl* SvtPrinterOptions::m_pStaticDataContainer = NULL; +sal_Int32 SvtPrinterOptions::m_nRefCount = 0; + +SvtPrintOptions_Impl* SvtPrintFileOptions::m_pStaticDataContainer = NULL; +sal_Int32 SvtPrintFileOptions::m_nRefCount = 0; + +// ------------------------ +// - SvtPrintOptions_Impl - +// ------------------------ + +class SvtPrintOptions_Impl +{ +public: + +//--------------------------------------------------------------------------------------------------------- +// constructor / destructor +//--------------------------------------------------------------------------------------------------------- + + SvtPrintOptions_Impl( const OUString& rConfigRoot ); + ~SvtPrintOptions_Impl(); + +//--------------------------------------------------------------------------------------------------------- +// public interface +//--------------------------------------------------------------------------------------------------------- + + sal_Bool IsReduceTransparency() const ; + sal_Int16 GetReducedTransparencyMode() const ; + sal_Bool IsReduceGradients() const ; + sal_Int16 GetReducedGradientMode() const ; + sal_Int16 GetReducedGradientStepCount() const ; + sal_Bool IsReduceBitmaps() const ; + sal_Int16 GetReducedBitmapMode() const ; + sal_Int16 GetReducedBitmapResolution() const ; + sal_Bool IsReducedBitmapIncludesTransparency() const ; + sal_Bool IsConvertToGreyscales() const; + + void SetReduceTransparency( sal_Bool bState ) ; + void SetReducedTransparencyMode( sal_Int16 nMode ) ; + void SetReduceGradients( sal_Bool bState ) ; + void SetReducedGradientMode( sal_Int16 nMode ) ; + void SetReducedGradientStepCount( sal_Int16 nStepCount ) ; + void SetReduceBitmaps( sal_Bool bState ) ; + void SetReducedBitmapMode( sal_Int16 nMode ) ; + void SetReducedBitmapResolution( sal_Int16 nResolution ) ; + void SetReducedBitmapIncludesTransparency( sal_Bool bState ) ; + void SetConvertToGreyscales( sal_Bool bState ) ; + +//------------------------------------------------------------------------------------------------------------- +// private API +//------------------------------------------------------------------------------------------------------------- + +private: + void impl_setValue (const ::rtl::OUString& sProp, + ::sal_Bool bNew ); + void impl_setValue (const ::rtl::OUString& sProp, + ::sal_Int16 nNew ); + +//------------------------------------------------------------------------------------------------------------- +// private member +//------------------------------------------------------------------------------------------------------------- + +private: + css::uno::Reference< css::container::XNameAccess > m_xCfg; + css::uno::Reference< css::container::XNameAccess > m_xNode; +}; + +SvtPrintOptions_Impl::SvtPrintOptions_Impl(const OUString& rConfigRoot) +{ + try + { + m_xCfg = css::uno::Reference< css::container::XNameAccess >( + ::comphelper::ConfigurationHelper::openConfig( + utl::getProcessServiceFactory(), + ROOTNODE_PRINTOPTION, + ::comphelper::ConfigurationHelper::E_STANDARD), + css::uno::UNO_QUERY); + + if (m_xCfg.is()) + { + UniString sTmp = UniString(rConfigRoot); + xub_StrLen nTokenCount = sTmp.GetTokenCount('/'); + sTmp = sTmp.GetToken(nTokenCount - 1, '/'); + m_xCfg->getByName(OUString(sTmp.GetBuffer())) >>= m_xNode; + } + } + catch (const css::uno::Exception& ex) + { + m_xNode.clear(); + m_xCfg.clear(); + LogHelper::logIt(ex); + } +} + +sal_Bool SvtPrintOptions_Impl::IsReduceTransparency() const +{ + sal_Bool bRet = sal_False; + try + { + if (m_xNode.is()) + { + css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + xSet->getPropertyValue(PROPERTYNAME_REDUCETRANSPARENCY) >>= bRet; + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Int16 SvtPrintOptions_Impl::GetReducedTransparencyMode() const +{ + sal_Int16 nRet = 0; + try + { + if (m_xNode.is()) + { + css::uno::Reference< css::beans::XPropertySet > xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + xSet->getPropertyValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE) >>= nRet; + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return nRet; +} + +sal_Bool SvtPrintOptions_Impl::IsReduceGradients() const +{ + sal_Bool bRet = sal_False; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEGRADIENTS) >>= bRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Int16 SvtPrintOptions_Impl::GetReducedGradientMode() const +{ + sal_Int16 nRet = 0; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTMODE) >>= nRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return nRet; +} + +sal_Int16 SvtPrintOptions_Impl::GetReducedGradientStepCount() const +{ + sal_Int16 nRet = 64; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT) >>= nRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return nRet; +} + +sal_Bool SvtPrintOptions_Impl::IsReduceBitmaps() const +{ + sal_Bool bRet = sal_False; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEBITMAPS) >>= bRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapMode() const +{ + sal_Int16 nRet = 1; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPMODE) >>= nRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return nRet; +} + +sal_Int16 SvtPrintOptions_Impl::GetReducedBitmapResolution() const +{ + sal_Int16 nRet = 3; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION) >>= nRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return nRet; +} + +sal_Bool SvtPrintOptions_Impl::IsReducedBitmapIncludesTransparency() const +{ + sal_Bool bRet = sal_True; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY) >>= bRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; +} + +sal_Bool SvtPrintOptions_Impl::IsConvertToGreyscales() const +{ + sal_Bool bRet = sal_False; + try + { + if (m_xNode.is()) + { + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if (xSet.is()) + { + xSet->getPropertyValue(PROPERTYNAME_CONVERTTOGREYSCALES) >>= bRet; + } + } + } + catch (const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } + + return bRet; + +} + +void SvtPrintOptions_Impl::SetReduceTransparency(sal_Bool bState) +{ + impl_setValue(PROPERTYNAME_REDUCETRANSPARENCY, bState); +} + +void SvtPrintOptions_Impl::SetReducedTransparencyMode(sal_Int16 nMode) +{ + impl_setValue(PROPERTYNAME_REDUCEDTRANSPARENCYMODE, nMode); +} + +void SvtPrintOptions_Impl::SetReduceGradients(sal_Bool bState) +{ + impl_setValue(PROPERTYNAME_REDUCEGRADIENTS, bState); +} + +void SvtPrintOptions_Impl::SetReducedGradientMode(sal_Int16 nMode) +{ + impl_setValue(PROPERTYNAME_REDUCEDGRADIENTMODE, nMode); +} + +void SvtPrintOptions_Impl::SetReducedGradientStepCount(sal_Int16 nStepCount ) +{ + impl_setValue(PROPERTYNAME_REDUCEDGRADIENTSTEPCOUNT, nStepCount); +} + +void SvtPrintOptions_Impl::SetReduceBitmaps(sal_Bool bState ) +{ + impl_setValue(PROPERTYNAME_REDUCEBITMAPS, bState); +} + +void SvtPrintOptions_Impl::SetReducedBitmapMode(sal_Int16 nMode ) +{ + impl_setValue(PROPERTYNAME_REDUCEDBITMAPMODE, nMode); +} + +void SvtPrintOptions_Impl::SetReducedBitmapResolution(sal_Int16 nResolution ) +{ + impl_setValue(PROPERTYNAME_REDUCEDBITMAPRESOLUTION, nResolution); +} + +void SvtPrintOptions_Impl::SetReducedBitmapIncludesTransparency(sal_Bool bState ) +{ + impl_setValue(PROPERTYNAME_REDUCEDBITMAPINCLUDESTRANSPARENCY, bState); +} + +void SvtPrintOptions_Impl::SetConvertToGreyscales(sal_Bool bState) +{ + impl_setValue(PROPERTYNAME_CONVERTTOGREYSCALES, bState); +} + +SvtPrintOptions_Impl::~SvtPrintOptions_Impl() +{ + m_xNode.clear(); + m_xCfg.clear(); +} + +void SvtPrintOptions_Impl::impl_setValue (const ::rtl::OUString& sProp, + ::sal_Bool bNew ) +{ + try + { + if ( ! m_xNode.is()) + return; + + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if ( ! xSet.is()) + return; + + ::sal_Bool bOld = ! bNew; + if ( ! (xSet->getPropertyValue(sProp) >>= bOld)) + return; + + if (bOld != bNew) + { + xSet->setPropertyValue(sProp, css::uno::makeAny(bNew)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +void SvtPrintOptions_Impl::impl_setValue (const ::rtl::OUString& sProp, + ::sal_Int16 nNew ) +{ + try + { + if ( ! m_xNode.is()) + return; + + css::uno::Reference<css::beans::XPropertySet> xSet(m_xNode, css::uno::UNO_QUERY); + if ( ! xSet.is()) + return; + + ::sal_Int16 nOld = nNew+1; + if ( ! (xSet->getPropertyValue(sProp) >>= nOld)) + return; + + if (nOld != nNew) + { + xSet->setPropertyValue(sProp, css::uno::makeAny(nNew)); + ::comphelper::ConfigurationHelper::flush(m_xCfg); + } + } + catch(const css::uno::Exception& ex) + { + LogHelper::logIt(ex); + } +} + +// ----------------------------------------------------------------------------- + + +// ----------------------- +// - SvtBasePrintOptions - +// ----------------------- + +SvtBasePrintOptions::SvtBasePrintOptions() +{ +} + +// ----------------------------------------------------------------------------- + +SvtBasePrintOptions::~SvtBasePrintOptions() +{ +} + +// ----------------------------------------------------------------------------- + +Mutex& SvtBasePrintOptions::GetOwnStaticMutex() +{ + // Initialize static mutex only for one time! + static Mutex* pMutex = NULL; + // If these method first called (Mutex not already exist!) ... + if( pMutex == NULL ) + { + // ... we must create a new one. Protect follow code with the global mutex - + // It must be - we create a static variable! + MutexGuard aGuard( Mutex::getGlobalMutex() ); + // We must check our pointer again - because it can be that another instance of ouer class will be fastr then these! + if( pMutex == NULL ) + { + // Create the new mutex and set it for return on static variable. + static Mutex aMutex; + pMutex = &aMutex; + } + } + // Return new created or already existing mutex object. + return *pMutex; +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvtBasePrintOptions::IsReduceTransparency() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsReduceTransparency(); +} + +// ----------------------------------------------------------------------------- + +sal_Int16 SvtBasePrintOptions::GetReducedTransparencyMode() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetReducedTransparencyMode(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvtBasePrintOptions::IsReduceGradients() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsReduceGradients(); +} + +// ----------------------------------------------------------------------------- + +sal_Int16 SvtBasePrintOptions::GetReducedGradientMode() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetReducedGradientMode(); +} + +// ----------------------------------------------------------------------------- + +sal_Int16 SvtBasePrintOptions::GetReducedGradientStepCount() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetReducedGradientStepCount(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvtBasePrintOptions::IsReduceBitmaps() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsReduceBitmaps(); +} + +// ----------------------------------------------------------------------------- + +sal_Int16 SvtBasePrintOptions::GetReducedBitmapMode() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetReducedBitmapMode(); +} + +// ----------------------------------------------------------------------------- + +sal_Int16 SvtBasePrintOptions::GetReducedBitmapResolution() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->GetReducedBitmapResolution(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvtBasePrintOptions::IsReducedBitmapIncludesTransparency() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsReducedBitmapIncludesTransparency(); +} + +// ----------------------------------------------------------------------------- + +sal_Bool SvtBasePrintOptions::IsConvertToGreyscales() const +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + return m_pDataContainer->IsConvertToGreyscales(); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReduceTransparency( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReduceTransparency( bState ) ; +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReducedTransparencyMode( sal_Int16 nMode ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReducedTransparencyMode( nMode ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReduceGradients( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReduceGradients( bState ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReducedGradientMode( sal_Int16 nMode ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReducedGradientMode( nMode ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReducedGradientStepCount( sal_Int16 nStepCount ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReducedGradientStepCount( nStepCount ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReduceBitmaps( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReduceBitmaps( bState ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReducedBitmapMode( sal_Int16 nMode ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReducedBitmapMode( nMode ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReducedBitmapResolution( sal_Int16 nResolution ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReducedBitmapResolution( nResolution ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetReducedBitmapIncludesTransparency( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetReducedBitmapIncludesTransparency( bState ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetConvertToGreyscales( sal_Bool bState ) +{ + MutexGuard aGuard( GetOwnStaticMutex() ); + m_pDataContainer->SetConvertToGreyscales( bState ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::GetPrinterOptions( PrinterOptions& rOptions ) const +{ + rOptions.SetReduceTransparency( IsReduceTransparency() ); + rOptions.SetReducedTransparencyMode( (PrinterTransparencyMode) GetReducedTransparencyMode() ); + rOptions.SetReduceGradients( IsReduceGradients() ); + rOptions.SetReducedGradientMode( (PrinterGradientMode) GetReducedGradientMode() ); + rOptions.SetReducedGradientStepCount( GetReducedGradientStepCount() ); + rOptions.SetReduceBitmaps( IsReduceBitmaps() ); + rOptions.SetReducedBitmapMode( (PrinterBitmapMode) GetReducedBitmapMode() ); + rOptions.SetReducedBitmapResolution( aDPIArray[ Min( (USHORT) GetReducedBitmapResolution(), (USHORT)( DPI_COUNT - 1 ) ) ] ); + rOptions.SetReducedBitmapIncludesTransparency( IsReducedBitmapIncludesTransparency() ); + rOptions.SetConvertToGreyscales( IsConvertToGreyscales() ); +} + +// ----------------------------------------------------------------------------- + +void SvtBasePrintOptions::SetPrinterOptions( const PrinterOptions& rOptions ) +{ + SetReduceTransparency( rOptions.IsReduceTransparency() ); + SetReducedTransparencyMode( + sal::static_int_cast< sal_Int16 >( + rOptions.GetReducedTransparencyMode()) ); + SetReduceGradients( rOptions.IsReduceGradients() ); + SetReducedGradientMode( + sal::static_int_cast< sal_Int16 >(rOptions.GetReducedGradientMode()) ); + SetReducedGradientStepCount( rOptions.GetReducedGradientStepCount() ); + SetReduceBitmaps( rOptions.IsReduceBitmaps() ); + SetReducedBitmapMode( + sal::static_int_cast< sal_Int16 >(rOptions.GetReducedBitmapMode()) ); + SetReducedBitmapIncludesTransparency( rOptions.IsReducedBitmapIncludesTransparency() ); + SetConvertToGreyscales( rOptions.IsConvertToGreyscales() ); + + const USHORT nDPI = rOptions.GetReducedBitmapResolution(); + + if( nDPI < aDPIArray[ 0 ] ) + SetReducedBitmapResolution( 0 ); + else + { + for( long i = ( DPI_COUNT - 1 ); i >= 0; i-- ) + { + if( nDPI >= aDPIArray[ i ] ) + { + SetReducedBitmapResolution( (sal_Int16) i ); + i = -1; + } + } + } +} + +// --------------------- +// - SvtPrinterOptions - +// --------------------- + +SvtPrinterOptions::SvtPrinterOptions() +{ + // Global access, must be guarded (multithreading!). + MutexGuard aGuard( GetOwnStaticMutex() ); + // Increase ouer refcount ... + ++m_nRefCount; + // ... and initialize ouer data container only if it not already! + if( m_pStaticDataContainer == NULL ) + { + OUString aRootPath( ROOTNODE_START ); + m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/Printer" ) ) ); + pPrinterOptionsDataContainer = m_pStaticDataContainer; + ItemHolder2::holdConfigItem(E_PRINTOPTIONS); + } + + SetDataContainer( m_pStaticDataContainer ); +} + +// ----------------------------------------------------------------------------- + +SvtPrinterOptions::~SvtPrinterOptions() +{ + // Global access, must be guarded (multithreading!) + MutexGuard aGuard( GetOwnStaticMutex() ); + // Decrease ouer refcount. + --m_nRefCount; + // If last instance was deleted ... + // we must destroy ouer static data container! + if( m_nRefCount <= 0 ) + { + delete m_pStaticDataContainer; + m_pStaticDataContainer = NULL; + pPrinterOptionsDataContainer = NULL; + } +} + +// --------------------- +// - SvtPrintFileOptions - +// --------------------- + +SvtPrintFileOptions::SvtPrintFileOptions() +{ + // Global access, must be guarded (multithreading!). + MutexGuard aGuard( GetOwnStaticMutex() ); + // Increase ouer refcount ... + ++m_nRefCount; + // ... and initialize ouer data container only if it not already! + if( m_pStaticDataContainer == NULL ) + { + OUString aRootPath( ROOTNODE_START ); + m_pStaticDataContainer = new SvtPrintOptions_Impl( aRootPath += OUString( RTL_CONSTASCII_USTRINGPARAM( "/File" ) ) ); + pPrintFileOptionsDataContainer = m_pStaticDataContainer; + + ItemHolder2::holdConfigItem(E_PRINTFILEOPTIONS); + } + + SetDataContainer( m_pStaticDataContainer ); +} + +// ----------------------------------------------------------------------------- + +SvtPrintFileOptions::~SvtPrintFileOptions() +{ + // Global access, must be guarded (multithreading!) + MutexGuard aGuard( GetOwnStaticMutex() ); + // Decrease ouer refcount. + --m_nRefCount; + // If last instance was deleted ... + // we must destroy ouer static data container! + if( m_nRefCount <= 0 ) + { + delete m_pStaticDataContainer; + m_pStaticDataContainer = NULL; + pPrintFileOptionsDataContainer = NULL; + } +} diff --git a/svtools/source/config/test/makefile.mk b/svtools/source/config/test/makefile.mk new file mode 100644 index 000000000000..71bea788d8de --- /dev/null +++ b/svtools/source/config/test/makefile.mk @@ -0,0 +1,62 @@ +#************************************************************************* +# +# 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. +# +#************************************************************************* +PRJ=..$/..$/.. + +PRJNAME= svtools +TARGET= test_configitems +LIBTARGET= NO +ENABLE_EXCEPTIONS= TRUE +USE_DEFFILE= TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE : settings.mk + +# --- application: "test" -------------------------------------------------- + +APP1TARGET= test + +APP1OBJS= $(SLO)$/test.obj \ + $(SLO)$/dynamicmenuoptions.obj + +DEPOBJFILES=$(APP1OBJS) + +APP1STDLIBS= $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ + $(UNOTOOLSLIB) \ + $(SALLIB) \ + $(VOSLIB) \ + $(TOOLSLIB) \ + $(VCLLIB) + +APP1DEPN= $(SLO)$/dynamicmenuoptions.obj + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + diff --git a/svtools/source/config/test/test.cxx b/svtools/source/config/test/test.cxx new file mode 100644 index 000000000000..ea4e0c0ec942 --- /dev/null +++ b/svtools/source/config/test/test.cxx @@ -0,0 +1,270 @@ +/************************************************************************* + * + * 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. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_svtools.hxx" + +//_________________________________________________________________________________________________________________ +// switches +// use it to enable test szenarios +//_________________________________________________________________________________________________________________ + +#define TEST_DYNAMICMENUOPTIONS + +//_________________________________________________________________________________________________________________ +// my own includes +//_________________________________________________________________________________________________________________ + +#include <unotools/dynamicmenuoptions.hxx> + +//_________________________________________________________________________________________________________________ +// interface includes +//_________________________________________________________________________________________________________________ +#include <cppuhelper/bootstrap.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/registry/XSimpleRegistry.hpp> + +//_________________________________________________________________________________________________________________ +// other includes +//_________________________________________________________________________________________________________________ + +#ifndef _COMPHELPER_PROCESSFACTORY_HXX_ +#include <comphelper/regpathhelper.hxx> +#endif +#include <cppuhelper/servicefactory.hxx> +#include <cppuhelper/bootstrap.hxx> +#include <comphelper/processfactory.hxx> +#include <com/sun/star/uno/Reference.h> +#include <com/sun/star/uno/Sequence.h> + +#ifndef _RTL_USTRING_ +#include <rtl/ustring> +#endif +#include <rtl/ustrbuf.hxx> +#include <osl/diagnose.h> +#include <osl/mutex.hxx> + +/* +#include <svtools/unoiface.hxx> +#include <tools/urlobj.hxx> +*/ +#include <vcl/event.hxx> +#include <vcl/svapp.hxx> +#include <vcl/wrkwin.hxx> +#include <vcl/msgbox.hxx> +#include <stdio.h> + +//_________________________________________________________________________________________________________________ +// const +//_________________________________________________________________________________________________________________ + +//_________________________________________________________________________________________________________________ +// namespace +//_________________________________________________________________________________________________________________ + +using namespace ::rtl ; +using namespace ::osl ; +using namespace ::comphelper ; +using namespace ::com::sun::star::uno ; +using namespace ::com::sun::star::lang ; +using namespace ::com::sun::star::beans ; +using namespace ::com::sun::star::registry ; + +//_________________________________________________________________________________________________________________ +// defines +//_________________________________________________________________________________________________________________ + +#define ASCII( STEXT ) OUString( RTL_CONSTASCII_USTRINGPARAM( STEXT )) + +#define SERVICENAME_SIMPLEREGISTRY OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.registry.SimpleRegistry" )) +#define SERVICENAME_NESTEDREGISTRY OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.registry.NestedRegistry" )) + +//_________________________________________________________________________________________________________________ +// declarations +//_________________________________________________________________________________________________________________ + +class TestApplication : public Application +{ + //************************************************************************************************************* + // interface + //************************************************************************************************************* + public: + void Main(); + + //************************************************************************************************************* + // test methods + //************************************************************************************************************* + private: + void impl_testDynamicMenuOptions(); + + //************************************************************************************************************* + // helper methods + //************************************************************************************************************* + private: + static Reference< XMultiServiceFactory > getUNOServiceManager(); + + //************************************************************************************************************* + // member + //************************************************************************************************************* + private: + +}; // class TestApplication + +//_________________________________________________________________________________________________________________ +// global variables +//_________________________________________________________________________________________________________________ + +TestApplication aTestApplication ; + +//_________________________________________________________________________________________________________________ +// main +//_________________________________________________________________________________________________________________ + +void TestApplication::Main() +{ + /**-*********************************************************************************************************** + initialize program + **************************************************************************************************************/ + + // Init global servicemanager and set it for external services. + ::comphelper::setProcessServiceFactory( TestApplication::getUNOServiceManager() ); + // Control sucess of operation. + OSL_ENSURE( !(::comphelper::getProcessServiceFactory()!=TestApplication::getUNOServiceManager()), "TestApplication::Main()\nGlobal servicemanager not right initialized.\n" ); + + /**-*********************************************************************************************************** + test area + **************************************************************************************************************/ + + #ifdef TEST_DYNAMICMENUOPTIONS + impl_testDynamicMenuOptions(); + #endif + +// Execute(); + OSL_ENSURE( sal_False, "Test was successful!\n" ); +} + +//***************************************************************************************************************** +// test configuration of dynamic menus "New" and "Wizard" +//***************************************************************************************************************** +void TestApplication::impl_testDynamicMenuOptions() +{ + SvtDynamicMenuOptions aCFG; + + // Test: + // read menus + // if( menus == empty ) + // { + // fill it with samples + // read it again + // } + // output content + + Sequence< Sequence< PropertyValue > > lNewMenu = aCFG.GetMenu( E_NEWMENU ); + Sequence< Sequence< PropertyValue > > lWizardMenu = aCFG.GetMenu( E_WIZARDMENU ); + + if( lNewMenu.getLength() < 1 ) + { + aCFG.AppendItem( E_NEWMENU, ASCII("private:factory/swriter"), ASCII("new writer"), ASCII("icon_writer"), ASCII("_blank") ); + aCFG.AppendItem( E_NEWMENU, ASCII("private:factory/scalc" ), ASCII("new calc" ), ASCII("icon_calc" ), ASCII("_blank") ); + aCFG.AppendItem( E_NEWMENU, ASCII("private:factory/sdraw" ), ASCII("new draw" ), ASCII("icon_draw" ), ASCII("_blank") ); + + lNewMenu = aCFG.GetMenu( E_NEWMENU ); + } + + if( lWizardMenu.getLength() < 1 ) + { + aCFG.AppendItem( E_WIZARDMENU, ASCII("file://a"), ASCII("system file"), ASCII("icon_file"), ASCII("_self") ); + aCFG.AppendItem( E_WIZARDMENU, ASCII("ftp://b" ), ASCII("ftp host" ), ASCII("icon_ftp" ), ASCII("_self") ); + aCFG.AppendItem( E_WIZARDMENU, ASCII("http://c"), ASCII("www" ), ASCII("icon_www" ), ASCII("_self") ); + + lWizardMenu = aCFG.GetMenu( E_WIZARDMENU ); + } + + sal_uInt32 nItemCount ; + sal_uInt32 nItem ; + sal_uInt32 nPropertyCount; + sal_uInt32 nProperty ; + OUString sPropertyValue; + OUStringBuffer sOut( 5000 ) ; + + nItemCount = lNewMenu.getLength(); + for( nItem=0; nItem<nItemCount; ++nItem ) + { + nPropertyCount = lNewMenu[nItem].getLength(); + for( nProperty=0; nProperty<nPropertyCount; ++nProperty ) + { + lNewMenu[nItem][nProperty].Value >>= sPropertyValue; + + sOut.appendAscii ( "New/" ); + sOut.append ( (sal_Int32)nItem ); + sOut.appendAscii ( "/" ); + sOut.append ( lNewMenu[nItem][nProperty].Name ); + sOut.appendAscii ( " = " ); + sOut.append ( sPropertyValue ); + sOut.appendAscii ( "\n" ); + } + } + + sOut.appendAscii("\n--------------------------------------\n"); + + nItemCount = lWizardMenu.getLength(); + for( nItem=0; nItem<nItemCount; ++nItem ) + { + nPropertyCount = lNewMenu[nItem].getLength(); + for( nProperty=0; nProperty<nPropertyCount; ++nProperty ) + { + lWizardMenu[nItem][nProperty].Value >>= sPropertyValue; + + sOut.appendAscii ( "Wizard/" ); + sOut.append ( (sal_Int32)nItem ); + sOut.appendAscii ( "/" ); + sOut.append ( lNewMenu[nItem][nProperty].Name ); + sOut.appendAscii ( " = " ); + sOut.append ( sPropertyValue ); + sOut.appendAscii ( "\n" ); + } + } + + OSL_ENSURE( sal_False, OUStringToOString( sOut.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr() ); +} + +//***************************************************************************************************************** +// create new uno servicemanager by using normall applicat.rdb and user.rdb of an office installation! +// Don't use this application at same time like the office! +//***************************************************************************************************************** +Reference< XMultiServiceFactory > TestApplication::getUNOServiceManager() +{ + static Reference< XMultiServiceFactory > smgr; + if( ! smgr.is() ) + { + Reference< XComponentContext > rCtx = + cppu::defaultBootstrap_InitialComponentContext(); + smgr = Reference< XMultiServiceFactory > ( rCtx->getServiceManager() , UNO_QUERY ); + } + return smgr; +} |