LCOV - code coverage report
Current view: top level - cui/source/options - optgdlg.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 990 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 60 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <svl/zforlist.hxx>
      21             : #include <svl/currencytable.hxx>
      22             : #include <svtools/grfmgr.hxx>
      23             : #include <svl/flagitem.hxx>
      24             : #include <sfx2/dispatch.hxx>
      25             : #include <unotools/lingucfg.hxx>
      26             : #include <svl/szitem.hxx>
      27             : #include <sfx2/viewsh.hxx>
      28             : #include <sfx2/viewfrm.hxx>
      29             : #include <sfx2/imgmgr.hxx>
      30             : #include <vcl/configsettings.hxx>
      31             : #include <vcl/layout.hxx>
      32             : #include <vcl/mnemonic.hxx>
      33             : #include <i18nlangtag/mslangid.hxx>
      34             : #include <i18nlangtag/languagetag.hxx>
      35             : #include <unotools/compatibility.hxx>
      36             : #include <unotools/useroptions.hxx>
      37             : #include <unotools/fontoptions.hxx>
      38             : #include <svtools/menuoptions.hxx>
      39             : #include <svl/languageoptions.hxx>
      40             : #include <svtools/miscopt.hxx>
      41             : #include <unotools/printwarningoptions.hxx>
      42             : #include <unotools/syslocaleoptions.hxx>
      43             : #include <svtools/accessibilityoptions.hxx>
      44             : #include <unotools/configitem.hxx>
      45             : #include <sfx2/objsh.hxx>
      46             : #include <comphelper/string.hxx>
      47             : #include <comphelper/types.hxx>
      48             : #include <svtools/langtab.hxx>
      49             : #include <unotools/localfilehelper.hxx>
      50             : #include <unotools/configmgr.hxx>
      51             : #include "cuioptgenrl.hxx"
      52             : #include "optpath.hxx"
      53             : #include "optsave.hxx"
      54             : #include "optlingu.hxx"
      55             : #include <svx/xpool.hxx>
      56             : #include <svx/dlgutil.hxx>
      57             : #include "cuitabarea.hxx"
      58             : #include <cuires.hrc>
      59             : #include <editeng/unolingu.hxx>
      60             : #include <editeng/langitem.hxx>
      61             : #include <comphelper/processfactory.hxx>
      62             : #include <rtl/ustrbuf.hxx>
      63             : #include <editeng/editids.hrc>
      64             : #include <svx/svxids.hrc>
      65             : #include <svl/intitem.hxx>
      66             : #include <dialmgr.hxx>
      67             : #include <svtools/helpopt.hxx>
      68             : #include <unotools/saveopt.hxx>
      69             : #include <unotools/searchopt.hxx>
      70             : #include <sal/macros.h>
      71             : #include <officecfg/Office/Common.hxx>
      72             : #include <comphelper/configuration.hxx>
      73             : 
      74             : #include <com/sun/star/configuration/theDefaultProvider.hpp>
      75             : #include <com/sun/star/container/XNameAccess.hpp>
      76             : #include <com/sun/star/container/XNameReplace.hpp>
      77             : #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
      78             : #include <com/sun/star/lang/XComponent.hpp>
      79             : #include <com/sun/star/lang/XInitialization.hpp>
      80             : #include <com/sun/star/beans/NamedValue.hpp>
      81             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      82             : #include <com/sun/star/beans/XPropertySet.hpp>
      83             : #include <com/sun/star/util/XChangesBatch.hpp>
      84             : #include <com/sun/star/uno/Any.hxx>
      85             : #include <com/sun/star/container/XContentEnumerationAccess.hpp>
      86             : #include <com/sun/star/container/XSet.hpp>
      87             : #include <com/sun/star/i18n/ScriptType.hpp>
      88             : #include <com/sun/star/office/Quickstart.hpp>
      89             : 
      90             : #include <vcl/svapp.hxx>
      91             : #include <vcl/settings.hxx>
      92             : #include <vcl/IconThemeInfo.hxx>
      93             : 
      94             : #include "optgdlg.hxx"
      95             : #include <svx/ofaitem.hxx>
      96             : #include <svtools/apearcfg.hxx>
      97             : #include <svtools/optionsdrawinglayer.hxx>
      98             : 
      99             : #include <config_vclplug.h>
     100             : 
     101             : using namespace ::com::sun::star::uno;
     102             : using namespace ::com::sun::star::lang;
     103             : using namespace ::com::sun::star::beans;
     104             : using namespace ::com::sun::star::container;
     105             : using namespace ::com::sun::star::util;
     106             : using namespace ::utl;
     107             : 
     108             : namespace svt {
     109             : 
     110             : class OpenGLCfg
     111             : {
     112             : private:
     113             :     bool mbUseOpenGL;
     114             :     bool mbForceOpenGL;
     115             :     bool mbModified;
     116             : 
     117             : public:
     118             :     OpenGLCfg();
     119             :     ~OpenGLCfg();
     120             : 
     121             :     bool useOpenGL() const;
     122             :     bool forceOpenGL() const;
     123             : 
     124             :     void setUseOpenGL(bool bOpenGL);
     125             :     void setForceOpenGL(bool bOpenGL);
     126             : 
     127             :     void reset();
     128             : };
     129             : 
     130           0 : OpenGLCfg::OpenGLCfg():
     131           0 :     mbModified(false)
     132             : {
     133           0 :     reset();
     134           0 : }
     135             : 
     136           0 : void OpenGLCfg::reset()
     137             : {
     138           0 :     mbUseOpenGL = officecfg::Office::Common::VCL::UseOpenGL::get();
     139           0 :     mbForceOpenGL = officecfg::Office::Common::VCL::ForceOpenGL::get();
     140           0 :     mbModified = false;
     141           0 : }
     142             : 
     143           0 : OpenGLCfg::~OpenGLCfg()
     144             : {
     145           0 :     if (mbModified)
     146             :     {
     147           0 :         std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
     148           0 :         officecfg::Office::Common::VCL::UseOpenGL::set(mbUseOpenGL, batch);
     149           0 :         officecfg::Office::Common::VCL::ForceOpenGL::set(mbForceOpenGL, batch);
     150           0 :         batch->commit();
     151             :     }
     152           0 : }
     153             : 
     154           0 : bool OpenGLCfg::useOpenGL() const
     155             : {
     156           0 :     return mbUseOpenGL;
     157             : }
     158             : 
     159           0 : bool OpenGLCfg::forceOpenGL() const
     160             : {
     161           0 :     return mbForceOpenGL;
     162             : }
     163             : 
     164           0 : void OpenGLCfg::setUseOpenGL(bool bOpenGL)
     165             : {
     166           0 :     if (bOpenGL != mbUseOpenGL)
     167             :     {
     168           0 :         mbUseOpenGL = bOpenGL;
     169           0 :         mbModified = true;
     170             :     }
     171           0 : }
     172             : 
     173           0 : void OpenGLCfg::setForceOpenGL(bool bOpenGL)
     174             : {
     175           0 :     if (mbForceOpenGL != bOpenGL)
     176             :     {
     177           0 :         mbForceOpenGL = bOpenGL;
     178           0 :         mbModified = true;
     179             :     }
     180           0 : }
     181             : 
     182             : }
     183             : 
     184             : // class OfaMiscTabPage --------------------------------------------------
     185             : 
     186           0 : SvxGeneralTabPage::sfxpg OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
     187             : {
     188           0 :     if ( pSet_ )
     189           0 :         FillItemSet( pSet_ );
     190           0 :     return LEAVE_PAGE;
     191             : }
     192             : 
     193             : namespace
     194             : {
     195           0 :         static OUString impl_SystemFileOpenServiceName()
     196             :         {
     197           0 :             const OUString &rDesktopEnvironment = Application::GetDesktopEnvironment();
     198             : 
     199           0 :             if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde4") )
     200             :             {
     201             :                 #if ENABLE_KDE4
     202             :                 return OUString("com.sun.star.ui.dialogs.KDE4FilePicker" );
     203             :                 #else
     204           0 :                 return OUString();
     205             :                 #endif
     206             :             }
     207           0 :             else if ( rDesktopEnvironment.equalsIgnoreAsciiCase("kde") )
     208             :             {
     209             :                 #if ENABLE_KDE
     210             :                 return OUString("com.sun.star.ui.dialogs.KDEFilePicker");
     211             :                 #else
     212           0 :                 return OUString();
     213             :                 #endif
     214             :             }
     215           0 :             else if ( rDesktopEnvironment.equalsIgnoreAsciiCase("tde") )
     216             :             {
     217             :                 #if ENABLE_TDE
     218             :                 return OUString("com.sun.star.ui.dialogs.TDEFilePicker");
     219             :                 #else
     220           0 :                 return OUString();
     221             :                 #endif
     222             :             }
     223             :             #if defined WNT
     224             :             return OUString("com.sun.star.ui.dialogs.SystemFilePicker");
     225             :             #elif defined MACOSX
     226             :             return OUString("com.sun.star.ui.dialogs.AquaFilePicker");
     227             :             #else
     228           0 :             return OUString();
     229             :             #endif
     230             :         }
     231             : 
     232           0 :         static bool lcl_HasSystemFilePicker()
     233             :         {
     234           0 :             if( Application::hasNativeFileSelection() )
     235           0 :                 return true;
     236             : 
     237             :             // Otherwise fall-back on querying services
     238           0 :             bool bRet = false;
     239           0 :             Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
     240             : 
     241           0 :             Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
     242           0 :             Reference< XSet > xSet( xFactory, UNO_QUERY );
     243             : 
     244           0 :             if ( ! xEnumAccess.is() || ! xSet.is() )
     245           0 :                 return bRet;
     246             : 
     247             :             try
     248             :             {
     249           0 :                 OUString aFileService = impl_SystemFileOpenServiceName();
     250           0 :                 Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
     251           0 :                 if ( xEnum.is() && xEnum->hasMoreElements() )
     252           0 :                     bRet = true;
     253             :             }
     254           0 :             catch (const IllegalArgumentException&)
     255             :             {
     256             :             }
     257           0 :             catch (const ElementExistException&)
     258             :             {
     259             :             }
     260           0 :             return bRet;
     261             :         }
     262             : }
     263             : 
     264           0 : OfaMiscTabPage::OfaMiscTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
     265           0 :     : SfxTabPage(pParent, "OptGeneralPage", "cui/ui/optgeneralpage.ui", &rSet)
     266             : {
     267           0 :     get(m_pToolTipsCB, "tooltips");
     268           0 :     get(m_pExtHelpCB, "exthelp");
     269           0 :     if (!lcl_HasSystemFilePicker())
     270           0 :         get<VclContainer>("filedlgframe")->Hide();
     271             : #if ! ENABLE_GTK
     272             :     get<VclContainer>("printdlgframe")->Hide();
     273             : #else
     274           0 :     if (!SvtMiscOptions().IsExperimentalMode())
     275             :     {
     276           0 :         get<VclContainer>("printdlgframe")->Hide();
     277             :     }
     278             : #endif
     279           0 :     get(m_pFileDlgCB, "filedlg");
     280           0 :     get(m_pFileDlgROImage, "lockimage");
     281           0 :     get(m_pPrintDlgCB, "printdlg");
     282           0 :     get(m_pDocStatusCB, "docstatus");
     283           0 :     get(m_pSaveAlwaysCB, "savealways");
     284           0 :     get(m_pYearFrame, "yearframe");
     285           0 :     get(m_pYearValueField, "year");
     286           0 :     get(m_pToYearFT, "toyear");
     287           0 :     get(m_pCollectUsageInfo, "collectusageinfo");
     288             : 
     289           0 :     if (m_pFileDlgCB->IsVisible() && SvtMiscOptions().IsUseSystemFileDialogReadOnly())
     290             :     {
     291           0 :         m_pFileDlgROImage->Show();
     292           0 :         m_pFileDlgCB->Disable();
     293             :     }
     294             : 
     295           0 :     m_aStrDateInfo = m_pToYearFT->GetText();
     296           0 :     m_pYearValueField->SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
     297           0 :     Link<> aLink = LINK( this, OfaMiscTabPage, TwoFigureConfigHdl );
     298           0 :     m_pYearValueField->SetDownHdl( aLink );
     299           0 :     m_pYearValueField->SetUpHdl( aLink );
     300           0 :     m_pYearValueField->SetLoseFocusHdl( aLink );
     301           0 :     m_pYearValueField->SetFirstHdl( aLink );
     302           0 :     TwoFigureConfigHdl(m_pYearValueField);
     303             : 
     304           0 :     SetExchangeSupport();
     305             : 
     306           0 :     aLink = LINK( this, OfaMiscTabPage, HelpCheckHdl_Impl );
     307           0 :     m_pToolTipsCB->SetClickHdl( aLink );
     308           0 : }
     309             : 
     310           0 : OfaMiscTabPage::~OfaMiscTabPage()
     311             : {
     312           0 :     disposeOnce();
     313           0 : }
     314             : 
     315           0 : void OfaMiscTabPage::dispose()
     316             : {
     317           0 :     m_pToolTipsCB.clear();
     318           0 :     m_pExtHelpCB.clear();
     319           0 :     m_pFileDlgROImage.clear();
     320           0 :     m_pFileDlgCB.clear();
     321           0 :     m_pPrintDlgCB.clear();
     322           0 :     m_pDocStatusCB.clear();
     323           0 :     m_pSaveAlwaysCB.clear();
     324           0 :     m_pYearFrame.clear();
     325           0 :     m_pYearValueField.clear();
     326           0 :     m_pToYearFT.clear();
     327           0 :     m_pCollectUsageInfo.clear();
     328           0 :     SfxTabPage::dispose();
     329           0 : }
     330             : 
     331           0 : VclPtr<SfxTabPage> OfaMiscTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
     332             : {
     333           0 :     return VclPtr<OfaMiscTabPage>::Create( pParent, *rAttrSet );
     334             : }
     335             : 
     336           0 : bool OfaMiscTabPage::FillItemSet( SfxItemSet* rSet )
     337             : {
     338           0 :     bool bModified = false;
     339           0 :     std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
     340             : 
     341           0 :     SvtHelpOptions aHelpOptions;
     342           0 :     if ( m_pToolTipsCB->IsValueChangedFromSaved() )
     343           0 :         aHelpOptions.SetHelpTips( m_pToolTipsCB->IsChecked() );
     344           0 :     bool bChecked = ( m_pExtHelpCB->IsChecked() && m_pToolTipsCB->IsChecked() );
     345           0 :     if ( bChecked != (m_pExtHelpCB->GetSavedValue() == TRISTATE_TRUE) )
     346           0 :         aHelpOptions.SetExtendedHelp( bChecked );
     347             : 
     348           0 :     if ( m_pFileDlgCB->IsValueChangedFromSaved() )
     349             :     {
     350           0 :         SvtMiscOptions aMiscOpt;
     351           0 :         aMiscOpt.SetUseSystemFileDialog( !m_pFileDlgCB->IsChecked() );
     352           0 :         bModified = true;
     353             :     }
     354             : 
     355           0 :     if ( m_pPrintDlgCB->IsValueChangedFromSaved() )
     356             :     {
     357           0 :         SvtMiscOptions aMiscOpt;
     358           0 :         aMiscOpt.SetUseSystemPrintDialog( !m_pPrintDlgCB->IsChecked() );
     359           0 :         bModified = true;
     360             :     }
     361             : 
     362           0 :     if ( m_pDocStatusCB->IsValueChangedFromSaved() )
     363             :     {
     364           0 :         SvtPrintWarningOptions aPrintOptions;
     365           0 :         aPrintOptions.SetModifyDocumentOnPrintingAllowed( m_pDocStatusCB->IsChecked() );
     366           0 :         bModified = true;
     367             :     }
     368             : 
     369           0 :     if ( m_pSaveAlwaysCB->IsValueChangedFromSaved() )
     370             :     {
     371           0 :         SvtMiscOptions aMiscOpt;
     372           0 :         aMiscOpt.SetSaveAlwaysAllowed( m_pSaveAlwaysCB->IsChecked() );
     373           0 :         bModified = true;
     374             :     }
     375             : 
     376             :     const SfxUInt16Item* pUInt16Item =
     377           0 :         PTR_CAST( SfxUInt16Item, GetOldItem( *rSet, SID_ATTR_YEAR2000 ) );
     378           0 :     sal_uInt16 nNum = (sal_uInt16)m_pYearValueField->GetText().toInt32();
     379           0 :     if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
     380             :     {
     381           0 :         bModified = true;
     382           0 :         rSet->Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
     383             :     }
     384             : 
     385           0 :     if (m_pCollectUsageInfo->IsValueChangedFromSaved())
     386             :     {
     387           0 :         officecfg::Office::Common::Misc::CollectUsageInformation::set(m_pCollectUsageInfo->IsChecked(), batch);
     388           0 :         bModified = true;
     389             :     }
     390             : 
     391           0 :     batch->commit();
     392             : 
     393           0 :     return bModified;
     394             : }
     395             : 
     396           0 : void OfaMiscTabPage::Reset( const SfxItemSet* rSet )
     397             : {
     398           0 :     SvtHelpOptions aHelpOptions;
     399           0 :     m_pToolTipsCB->Check( aHelpOptions.IsHelpTips() );
     400           0 :     m_pExtHelpCB->Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
     401             : 
     402           0 :     m_pToolTipsCB->SaveValue();
     403           0 :     m_pExtHelpCB->SaveValue();
     404             : 
     405           0 :     SvtMiscOptions aMiscOpt;
     406           0 :     m_pFileDlgCB->Check( !aMiscOpt.UseSystemFileDialog() );
     407           0 :     m_pFileDlgCB->SaveValue();
     408           0 :     m_pPrintDlgCB->Check( !aMiscOpt.UseSystemPrintDialog() );
     409           0 :     m_pPrintDlgCB->SaveValue();
     410           0 :     m_pSaveAlwaysCB->Check( aMiscOpt.IsSaveAlwaysAllowed() );
     411           0 :     m_pSaveAlwaysCB->SaveValue();
     412             : 
     413           0 :     SvtPrintWarningOptions aPrintOptions;
     414           0 :     m_pDocStatusCB->Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
     415           0 :     m_pDocStatusCB->SaveValue();
     416             : 
     417           0 :     const SfxPoolItem* pItem = NULL;
     418           0 :     if ( SfxItemState::SET == rSet->GetItemState( SID_ATTR_YEAR2000, false, &pItem ) )
     419             :     {
     420           0 :         m_pYearValueField->SetValue( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
     421           0 :         TwoFigureConfigHdl(m_pYearValueField);
     422             :     }
     423             :     else
     424             :     {
     425           0 :         m_pYearFrame->Enable(false);
     426             :     }
     427             : 
     428           0 :     m_pCollectUsageInfo->Check(officecfg::Office::Common::Misc::CollectUsageInformation::get());
     429           0 :     m_pCollectUsageInfo->SaveValue();
     430           0 : }
     431             : 
     432           0 : IMPL_LINK( OfaMiscTabPage, TwoFigureHdl, NumericField*, pEd )
     433             : {
     434             :     (void)pEd;
     435             : 
     436           0 :     OUString aOutput( m_aStrDateInfo );
     437           0 :     OUString aStr( m_pYearValueField->GetText() );
     438           0 :     OUString sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
     439           0 :     sal_Int32 nIndex = 0;
     440           0 :     while ((nIndex = aStr.indexOf( sSep, nIndex)) != -1)
     441           0 :         aStr = aStr.replaceAt( nIndex, sSep.getLength(), "");
     442           0 :     sal_Int32 nNum = aStr.toInt32();
     443           0 :     if ( aStr.getLength() != 4 || nNum < m_pYearValueField->GetMin() || nNum > m_pYearValueField->GetMax() )
     444           0 :         aOutput += "????";
     445             :     else
     446             :     {
     447           0 :         nNum += 99;
     448           0 :         aOutput += OUString::number( nNum );
     449             :     }
     450           0 :     m_pToYearFT->SetText( aOutput );
     451           0 :     return 0;
     452             : }
     453             : 
     454           0 : IMPL_LINK( OfaMiscTabPage, TwoFigureConfigHdl, NumericField*, pEd )
     455             : {
     456           0 :     sal_Int64 nNum = m_pYearValueField->GetValue();
     457           0 :     OUString aOutput(OUString::number(nNum));
     458           0 :     m_pYearValueField->SetText(aOutput);
     459           0 :     m_pYearValueField->SetSelection( Selection( 0, aOutput.getLength() ) );
     460           0 :     TwoFigureHdl( pEd );
     461           0 :     return 0;
     462             : }
     463             : 
     464           0 : IMPL_LINK_NOARG(OfaMiscTabPage, HelpCheckHdl_Impl)
     465             : {
     466           0 :     m_pExtHelpCB->Enable( m_pToolTipsCB->IsChecked() );
     467           0 :     return 0;
     468             : }
     469             : 
     470           0 : class CanvasSettings
     471             : {
     472             : public:
     473             :     CanvasSettings();
     474             : 
     475             :     bool    IsHardwareAccelerationEnabled() const;
     476             :     bool    IsHardwareAccelerationAvailable() const;
     477             :     bool    IsHardwareAccelerationRO() const;
     478             :     void    EnabledHardwareAcceleration( bool _bEnabled ) const;
     479             : 
     480             : private:
     481             :     typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
     482             : 
     483             :     Reference<XNameAccess> mxForceFlagNameAccess;
     484             :     ServiceVector          maAvailableImplementations;
     485             :     mutable bool           mbHWAccelAvailable;
     486             :     mutable bool           mbHWAccelChecked;
     487             : };
     488             : 
     489           0 : CanvasSettings::CanvasSettings() :
     490             :     mxForceFlagNameAccess(),
     491             :     mbHWAccelAvailable(false),
     492           0 :     mbHWAccelChecked(false)
     493             : {
     494             :     try
     495             :     {
     496             :         Reference<XMultiServiceFactory> xConfigProvider(
     497             :             com::sun::star::configuration::theDefaultProvider::get(
     498           0 :                 comphelper::getProcessComponentContext()));
     499             : 
     500             :         Any propValue(
     501             :             makeAny( NamedValue(
     502             :                          OUString("nodepath"),
     503           0 :                          makeAny( OUString("/org.openoffice.Office.Canvas") ) ) ) );
     504             : 
     505             :         mxForceFlagNameAccess.set(
     506           0 :             xConfigProvider->createInstanceWithArguments(
     507             :                 OUString("com.sun.star.configuration.ConfigurationUpdateAccess"),
     508           0 :                 Sequence<Any>( &propValue, 1 ) ),
     509           0 :             UNO_QUERY_THROW );
     510             : 
     511           0 :         propValue = makeAny(
     512             :             NamedValue(
     513             :                 OUString("nodepath"),
     514           0 :                 makeAny( OUString("/org.openoffice.Office.Canvas/CanvasServiceList") ) ) );
     515             : 
     516             :         Reference<XNameAccess> xNameAccess(
     517           0 :             xConfigProvider->createInstanceWithArguments(
     518             :                 OUString("com.sun.star.configuration.ConfigurationAccess"),
     519           0 :                 Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
     520             :         Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
     521           0 :             xNameAccess, UNO_QUERY_THROW);
     522             : 
     523           0 :         Sequence<OUString> serviceNames = xNameAccess->getElementNames();
     524           0 :         const OUString* pCurr = serviceNames.getConstArray();
     525           0 :         const OUString* const pEnd = pCurr + serviceNames.getLength();
     526           0 :         while( pCurr != pEnd )
     527             :         {
     528             :             Reference<XNameAccess> xEntryNameAccess(
     529           0 :                 xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
     530           0 :                 UNO_QUERY );
     531             : 
     532           0 :             if( xEntryNameAccess.is() )
     533             :             {
     534           0 :                 Sequence<OUString> preferredImplementations;
     535           0 :                 if( (xEntryNameAccess->getByName("PreferredImplementations") >>= preferredImplementations) )
     536           0 :                     maAvailableImplementations.push_back( std::make_pair(*pCurr,preferredImplementations) );
     537             :             }
     538             : 
     539           0 :             ++pCurr;
     540           0 :         }
     541             :     }
     542           0 :     catch (const Exception&)
     543             :     {
     544             :     }
     545           0 : }
     546             : 
     547           0 : bool CanvasSettings::IsHardwareAccelerationAvailable() const
     548             : {
     549           0 :     if( !mbHWAccelChecked )
     550             :     {
     551           0 :         mbHWAccelChecked = true;
     552             : 
     553           0 :         Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
     554             : 
     555             :         // check whether any of the service lists has an
     556             :         // implementation that presents the "HardwareAcceleration" property
     557           0 :         ServiceVector::const_iterator       aCurr=maAvailableImplementations.begin();
     558           0 :         const ServiceVector::const_iterator aEnd=maAvailableImplementations.end();
     559           0 :         while( aCurr != aEnd )
     560             :         {
     561           0 :             const OUString* pCurrImpl = aCurr->second.getConstArray();
     562           0 :             const OUString* const pEndImpl = pCurrImpl + aCurr->second.getLength();
     563             : 
     564           0 :             while( pCurrImpl != pEndImpl )
     565             :             {
     566             :                 try
     567             :                 {
     568           0 :                     Reference<XPropertySet> xPropSet( xFactory->createInstance(
     569           0 :                                                           pCurrImpl->trim() ),
     570           0 :                                                       UNO_QUERY_THROW );
     571           0 :                     bool bHasAccel(false);
     572           0 :                     if( (xPropSet->getPropertyValue("HardwareAcceleration") >>= bHasAccel) )
     573           0 :                         if( bHasAccel )
     574             :                         {
     575           0 :                             mbHWAccelAvailable = true;
     576           0 :                             return mbHWAccelAvailable;
     577           0 :                         }
     578             :                 }
     579           0 :                 catch (const Exception&)
     580             :                 {
     581             :                 }
     582             : 
     583           0 :                 ++pCurrImpl;
     584             :             }
     585             : 
     586           0 :             ++aCurr;
     587           0 :         }
     588             :     }
     589             : 
     590           0 :     return mbHWAccelAvailable;
     591             : }
     592             : 
     593           0 : bool CanvasSettings::IsHardwareAccelerationEnabled() const
     594             : {
     595           0 :     bool bForceLastEntry(false);
     596           0 :     if( !mxForceFlagNameAccess.is() )
     597           0 :         return true;
     598             : 
     599           0 :     if( !(mxForceFlagNameAccess->getByName("ForceSafeServiceImpl") >>= bForceLastEntry) )
     600           0 :         return true;
     601             : 
     602           0 :     return !bForceLastEntry;
     603             : }
     604             : 
     605           0 : bool CanvasSettings::IsHardwareAccelerationRO() const
     606             : {
     607           0 :     Reference< XPropertySet > xSet(mxForceFlagNameAccess, UNO_QUERY);
     608           0 :     if (!xSet.is())
     609           0 :         return true;
     610             : 
     611           0 :     Reference< XPropertySetInfo > xInfo = xSet->getPropertySetInfo();
     612           0 :     Property aProp = xInfo->getPropertyByName("ForceSafeServiceImpl");
     613           0 :     return ((aProp.Attributes & css::beans::PropertyAttribute::READONLY ) == css::beans::PropertyAttribute::READONLY);
     614             : }
     615             : 
     616           0 : void CanvasSettings::EnabledHardwareAcceleration( bool _bEnabled ) const
     617             : {
     618             :     Reference< XNameReplace > xNameReplace(
     619           0 :         mxForceFlagNameAccess, UNO_QUERY );
     620             : 
     621           0 :     if( !xNameReplace.is() )
     622           0 :         return;
     623             : 
     624           0 :     xNameReplace->replaceByName( OUString("ForceSafeServiceImpl"),
     625           0 :                                  makeAny(!_bEnabled) );
     626             : 
     627             :     Reference< XChangesBatch > xChangesBatch(
     628           0 :         mxForceFlagNameAccess, UNO_QUERY );
     629             : 
     630           0 :     if( !xChangesBatch.is() )
     631           0 :         return;
     632             : 
     633           0 :     xChangesBatch->commitChanges();
     634             : }
     635             : 
     636             : // class OfaViewTabPage --------------------------------------------------
     637             : 
     638           0 : OfaViewTabPage::OfaViewTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
     639             :     : SfxTabPage(pParent, "OptViewPage", "cui/ui/optviewpage.ui", &rSet)
     640             :     , nSizeLB_InitialSelection(0)
     641             :     , nStyleLB_InitialSelection(0)
     642           0 :     , pAppearanceCfg(new SvtTabAppearanceCfg)
     643           0 :     , pCanvasSettings(new CanvasSettings)
     644           0 :     , mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
     645           0 :     , mpOpenGLConfig(new svt::OpenGLCfg)
     646             : {
     647           0 :     get(m_pWindowSizeMF, "windowsize");
     648           0 :     get(m_pIconSizeLB, "iconsize");
     649           0 :     get(m_pIconStyleLB, "iconstyle");
     650             : 
     651           0 :     get(m_pFontAntiAliasing, "aafont");
     652           0 :     get(m_pAAPointLimitLabel, "aafrom");
     653           0 :     get(m_pAAPointLimit, "aanf");
     654           0 :     get(m_pMenuIconsLB, "menuicons");
     655           0 :     get(m_pFontShowCB, "showfontpreview");
     656           0 :     get(m_pFontHistoryCB, "showfonthistory");
     657           0 :     get(m_pUseHardwareAccell, "useaccel");
     658           0 :     get(m_pUseAntiAliase, "useaa");
     659           0 :     get(m_pUseOpenGL, "useopengl");
     660           0 :     get(m_pForceOpenGL, "forceopengl");
     661           0 :     get(m_pMousePosLB, "mousepos");
     662           0 :     get(m_pMouseMiddleLB, "mousemiddle");
     663             :     // #i97672#
     664           0 :     get(m_pSelectionCB, "trans");
     665           0 :     get(m_pSelectionMF, "transmf");
     666             : 
     667             : #if defined( UNX )
     668           0 :     m_pFontAntiAliasing->SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
     669             : #else
     670             :     // on this platform, we do not have the anti aliasing options
     671             :     m_pFontAntiAliasing->Hide();
     672             :     m_pAAPointLimitLabel->Hide();
     673             :     m_pAAPointLimit->Hide();
     674             : 
     675             : #endif
     676             : 
     677             :     // #i97672#
     678           0 :     m_pSelectionCB->SetToggleHdl( LINK( this, OfaViewTabPage, OnSelectionToggled ) );
     679             : 
     680             :     // Set known icon themes
     681           0 :     OUString sAutoStr( m_pIconStyleLB->GetEntry( 0 ) );
     682           0 :     m_pIconStyleLB->Clear();
     683           0 :     StyleSettings aStyleSettings = Application::GetSettings().GetStyleSettings();
     684           0 :     mInstalledIconThemes = aStyleSettings.GetInstalledIconThemes();
     685             : 
     686             :     // Start with the automatically chosen icon theme
     687           0 :     OUString autoThemeId = aStyleSettings.GetAutomaticallyChosenIconTheme();
     688           0 :     const vcl::IconThemeInfo& autoIconTheme = vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, autoThemeId);
     689             : 
     690           0 :     OUString entryForAuto = sAutoStr + " (" +
     691           0 :                                 autoIconTheme.GetDisplayName() +
     692           0 :                                 ")";
     693           0 :     m_pIconStyleLB->InsertEntry(entryForAuto);
     694             : 
     695           0 :     for (std::vector<vcl::IconThemeInfo>::const_iterator aI = mInstalledIconThemes.begin(); aI != mInstalledIconThemes.end(); ++aI) {
     696           0 :         m_pIconStyleLB->InsertEntry(aI->GetDisplayName());
     697             :     }
     698             : 
     699             :     // separate auto and other icon themes
     700           0 :     m_pIconStyleLB->SetSeparatorPos( 0 );
     701           0 :     m_pIconStyleLB->SelectEntryPos(0);
     702           0 : }
     703             : 
     704           0 : OfaViewTabPage::~OfaViewTabPage()
     705             : {
     706           0 :     disposeOnce();
     707           0 : }
     708             : 
     709           0 : void OfaViewTabPage::dispose()
     710             : {
     711           0 :     delete mpDrawinglayerOpt;
     712           0 :     mpDrawinglayerOpt = NULL;
     713           0 :     delete pCanvasSettings;
     714           0 :     pCanvasSettings = NULL;
     715           0 :     delete pAppearanceCfg;
     716           0 :     pAppearanceCfg = NULL;
     717           0 :     m_pWindowSizeMF.clear();
     718           0 :     m_pIconSizeLB.clear();
     719           0 :     m_pIconStyleLB.clear();
     720           0 :     m_pFontAntiAliasing.clear();
     721           0 :     m_pAAPointLimitLabel.clear();
     722           0 :     m_pAAPointLimit.clear();
     723           0 :     m_pMenuIconsLB.clear();
     724           0 :     m_pFontShowCB.clear();
     725           0 :     m_pFontHistoryCB.clear();
     726           0 :     m_pUseHardwareAccell.clear();
     727           0 :     m_pUseAntiAliase.clear();
     728           0 :     m_pUseOpenGL.clear();
     729           0 :     m_pForceOpenGL.clear();
     730           0 :     m_pMousePosLB.clear();
     731           0 :     m_pMouseMiddleLB.clear();
     732           0 :     m_pSelectionCB.clear();
     733           0 :     m_pSelectionMF.clear();
     734           0 :     SfxTabPage::dispose();
     735           0 : }
     736             : 
     737             : #if defined( UNX )
     738           0 : IMPL_LINK_NOARG( OfaViewTabPage, OnAntialiasingToggled )
     739             : {
     740           0 :     bool bAAEnabled = m_pFontAntiAliasing->IsChecked();
     741             : 
     742           0 :     m_pAAPointLimitLabel->Enable( bAAEnabled );
     743           0 :     m_pAAPointLimit->Enable( bAAEnabled );
     744             : 
     745           0 :     return 0L;
     746             : }
     747             : #endif
     748             : 
     749             : // #i97672#
     750           0 : IMPL_LINK_NOARG( OfaViewTabPage, OnSelectionToggled )
     751             : {
     752           0 :     const bool bSelectionEnabled(m_pSelectionCB->IsChecked());
     753           0 :     m_pSelectionMF->Enable(bSelectionEnabled);
     754           0 :     return 0;
     755             : }
     756             : 
     757           0 : VclPtr<SfxTabPage> OfaViewTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
     758             : {
     759           0 :     return VclPtr<OfaViewTabPage>::Create(pParent, *rAttrSet);
     760             : }
     761             : 
     762           0 : bool OfaViewTabPage::FillItemSet( SfxItemSet* )
     763             : {
     764           0 :     SvtFontOptions aFontOpt;
     765           0 :     SvtMenuOptions aMenuOpt;
     766             : 
     767           0 :     bool bModified = false;
     768           0 :     bool bMenuOptModified = false;
     769           0 :     bool bRepaintWindows(false);
     770             : 
     771           0 :     SvtMiscOptions aMiscOptions;
     772           0 :     sal_uInt16 nSizeLB_NewSelection = m_pIconSizeLB->GetSelectEntryPos();
     773           0 :     if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
     774             :     {
     775             :         // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
     776           0 :         sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
     777           0 :         switch( nSizeLB_NewSelection )
     778             :         {
     779           0 :             case 0: eSet = SFX_SYMBOLS_SIZE_AUTO;  break;
     780           0 :             case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
     781           0 :             case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
     782             :             default:
     783             :                 OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pIconSizeLB should not be possible!" );
     784             :         }
     785           0 :         aMiscOptions.SetSymbolsSize( eSet );
     786             :     }
     787             : 
     788           0 :     sal_uInt16 nStyleLB_NewSelection = m_pIconStyleLB->GetSelectEntryPos();
     789           0 :     if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
     790             :     {
     791             :         // 0 means choose style automatically
     792           0 :         if (nStyleLB_NewSelection == 0)
     793           0 :             aMiscOptions.SetIconTheme("auto");
     794             :         else
     795             :         {
     796           0 :             sal_uInt16 pos = m_pIconStyleLB->GetSelectEntryPos();
     797           0 :             const vcl::IconThemeInfo& iconThemeId = mInstalledIconThemes.at(pos-1);
     798           0 :             aMiscOptions.SetIconTheme(iconThemeId.GetThemeId());
     799             :         }
     800           0 :         nStyleLB_InitialSelection = nStyleLB_NewSelection;
     801             :     }
     802             : 
     803           0 :     bool bAppearanceChanged = false;
     804             : 
     805             : 
     806             :     // Screen Scaling
     807           0 :     sal_uInt16 nOldScale = pAppearanceCfg->GetScaleFactor();
     808           0 :     sal_uInt16 nNewScale = (sal_uInt16)m_pWindowSizeMF->GetValue();
     809             : 
     810           0 :     if ( nNewScale != nOldScale )
     811             :     {
     812           0 :         pAppearanceCfg->SetScaleFactor(nNewScale);
     813           0 :         bAppearanceChanged = true;
     814             :     }
     815             : 
     816             :     // Mouse Snap Mode
     817           0 :     short eOldSnap = pAppearanceCfg->GetSnapMode();
     818           0 :     short eNewSnap = m_pMousePosLB->GetSelectEntryPos();
     819           0 :     if(eNewSnap > 2)
     820           0 :         eNewSnap = 2;
     821             : 
     822           0 :     if ( eNewSnap != eOldSnap )
     823             :     {
     824           0 :         pAppearanceCfg->SetSnapMode(eNewSnap );
     825           0 :         bAppearanceChanged = true;
     826             :     }
     827             : 
     828             :     // Middle Mouse Button
     829           0 :     MouseMiddleButtonAction eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
     830           0 :     short eNewMiddleMouse = m_pMouseMiddleLB->GetSelectEntryPos();
     831           0 :     if(eNewMiddleMouse > 2)
     832           0 :         eNewMiddleMouse = 2;
     833             : 
     834           0 :     if ( eNewMiddleMouse != static_cast<short>(eOldMiddleMouse) )
     835             :     {
     836           0 :         pAppearanceCfg->SetMiddleMouseButton( static_cast<MouseMiddleButtonAction>(eNewMiddleMouse) );
     837           0 :         bAppearanceChanged = true;
     838             :     }
     839             : 
     840             : #if defined( UNX )
     841           0 :     if ( m_pFontAntiAliasing->IsValueChangedFromSaved() )
     842             :     {
     843           0 :         pAppearanceCfg->SetFontAntiAliasing( m_pFontAntiAliasing->IsChecked() );
     844           0 :         bAppearanceChanged = true;
     845             :     }
     846             : 
     847           0 :     if ( m_pAAPointLimit->IsValueChangedFromSaved() )
     848             :     {
     849           0 :         pAppearanceCfg->SetFontAntialiasingMinPixelHeight( m_pAAPointLimit->GetValue() );
     850           0 :         bAppearanceChanged = true;
     851             :     }
     852             : #endif
     853             : 
     854           0 :     if ( m_pFontShowCB->IsValueChangedFromSaved() )
     855             :     {
     856           0 :         aFontOpt.EnableFontWYSIWYG( m_pFontShowCB->IsChecked() );
     857           0 :         bModified = true;
     858             :     }
     859             : 
     860           0 :     if(m_pMenuIconsLB->IsValueChangedFromSaved())
     861             :     {
     862           0 :         aMenuOpt.SetMenuIconsState(m_pMenuIconsLB->GetSelectEntryPos() == 0 ?
     863             :             TRISTATE_INDET :
     864           0 :             static_cast<TriState>(m_pMenuIconsLB->GetSelectEntryPos() - 1));
     865           0 :         bModified = true;
     866           0 :         bMenuOptModified = true;
     867           0 :         bAppearanceChanged = true;
     868             :     }
     869             : 
     870           0 :     if ( m_pFontHistoryCB->IsValueChangedFromSaved() )
     871             :     {
     872           0 :         aFontOpt.EnableFontHistory( m_pFontHistoryCB->IsChecked() );
     873           0 :         bModified = true;
     874             :     }
     875             : 
     876             :     // #i95644#  if disabled, do not use value, see in ::Reset()
     877           0 :     if(m_pUseHardwareAccell->IsEnabled())
     878             :     {
     879           0 :         if(m_pUseHardwareAccell->IsValueChangedFromSaved())
     880             :         {
     881           0 :             pCanvasSettings->EnabledHardwareAcceleration(m_pUseHardwareAccell->IsChecked());
     882           0 :             bModified = true;
     883             :         }
     884             :     }
     885             : 
     886             :     // #i95644#  if disabled, do not use value, see in ::Reset()
     887           0 :     if(m_pUseAntiAliase->IsEnabled())
     888             :     {
     889           0 :         if(m_pUseAntiAliase->IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
     890             :         {
     891           0 :             mpDrawinglayerOpt->SetAntiAliasing(m_pUseAntiAliase->IsChecked());
     892           0 :             bModified = true;
     893           0 :             bRepaintWindows = true;
     894             :         }
     895             :     }
     896             : 
     897           0 :     mpOpenGLConfig->setUseOpenGL(m_pUseOpenGL->IsChecked());
     898           0 :     mpOpenGLConfig->setForceOpenGL(m_pForceOpenGL->IsChecked());
     899             : 
     900             :     // #i97672#
     901           0 :     if(m_pSelectionCB->IsEnabled())
     902             :     {
     903           0 :         const bool bNewSelection(m_pSelectionCB->IsChecked());
     904           0 :         const sal_uInt16 nNewTransparence((sal_uInt16)m_pSelectionMF->GetValue());
     905             : 
     906           0 :         if(bNewSelection != (bool)mpDrawinglayerOpt->IsTransparentSelection())
     907             :         {
     908           0 :             mpDrawinglayerOpt->SetTransparentSelection(m_pSelectionCB->IsChecked());
     909           0 :             bModified = true;
     910           0 :             bRepaintWindows = true;
     911             :         }
     912             : 
     913             :         // #i104150# even read the value when m_pSelectionMF is disabled; it may have been
     914             :         // modified by enabling-modify-disabling by the user
     915           0 :         if(nNewTransparence != mpDrawinglayerOpt->GetTransparentSelectionPercent())
     916             :         {
     917           0 :             mpDrawinglayerOpt->SetTransparentSelectionPercent(nNewTransparence);
     918           0 :             bModified = true;
     919           0 :             bRepaintWindows = true;
     920             :         }
     921             :     }
     922             : 
     923           0 :     SvtAccessibilityOptions     aAccessibilityOptions;
     924             : 
     925           0 :     if( bMenuOptModified )
     926             :     {
     927             :         // Set changed settings to the application instance
     928           0 :         AllSettings aAllSettings = Application::GetSettings();
     929           0 :         StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
     930           0 :         aAllSettings.SetStyleSettings(aStyleSettings);
     931           0 :         Application::MergeSystemSettings( aAllSettings );
     932           0 :         Application::SetSettings(aAllSettings);
     933             :     }
     934             : 
     935           0 :     if ( bAppearanceChanged )
     936             :     {
     937           0 :         pAppearanceCfg->Commit();
     938           0 :         pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
     939             :     }
     940             : 
     941           0 :     if(bRepaintWindows)
     942             :     {
     943           0 :         vcl::Window* pAppWindow = Application::GetFirstTopLevelWindow();
     944             : 
     945           0 :         while(pAppWindow)
     946             :         {
     947           0 :             pAppWindow->Invalidate();
     948           0 :             pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
     949             :         }
     950             :     }
     951             : 
     952           0 :     return bModified;
     953             : }
     954             : 
     955           0 : void OfaViewTabPage::Reset( const SfxItemSet* )
     956             : {
     957           0 :     SvtMiscOptions aMiscOptions;
     958           0 :     mpOpenGLConfig->reset();
     959             : 
     960           0 :     if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO )
     961           0 :         nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
     962           0 :     m_pIconSizeLB->SelectEntryPos( nSizeLB_InitialSelection );
     963           0 :     m_pIconSizeLB->SaveValue();
     964             : 
     965           0 :     if (aMiscOptions.IconThemeWasSetAutomatically()) {
     966           0 :         nStyleLB_InitialSelection = 0;
     967             :     }
     968             :     else {
     969           0 :         const OUString& selected = aMiscOptions.GetIconTheme();
     970             :         const vcl::IconThemeInfo& selectedInfo =
     971           0 :                 vcl::IconThemeInfo::FindIconThemeById(mInstalledIconThemes, selected);
     972           0 :         nStyleLB_InitialSelection = m_pIconStyleLB->GetEntryPos(selectedInfo.GetDisplayName());
     973             :     }
     974             : 
     975           0 :     m_pIconStyleLB->SelectEntryPos( nStyleLB_InitialSelection );
     976           0 :     m_pIconStyleLB->SaveValue();
     977             : 
     978             :     // Screen Scaling
     979           0 :     m_pWindowSizeMF->SetValue ( pAppearanceCfg->GetScaleFactor() );
     980             :     // Mouse Snap
     981           0 :     m_pMousePosLB->SelectEntryPos(pAppearanceCfg->GetSnapMode());
     982           0 :     m_pMousePosLB->SaveValue();
     983             : 
     984             :     // Mouse Snap
     985           0 :     m_pMouseMiddleLB->SelectEntryPos(static_cast<short>(pAppearanceCfg->GetMiddleMouseButton()));
     986           0 :     m_pMouseMiddleLB->SaveValue();
     987             : 
     988             : #if defined( UNX )
     989           0 :     m_pFontAntiAliasing->Check( pAppearanceCfg->IsFontAntiAliasing() );
     990           0 :     m_pAAPointLimit->SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
     991             : #endif
     992             : 
     993             :     // WorkingSet
     994           0 :     SvtFontOptions aFontOpt;
     995           0 :     m_pFontShowCB->Check( aFontOpt.IsFontWYSIWYGEnabled() );
     996           0 :     SvtMenuOptions aMenuOpt;
     997           0 :     m_pMenuIconsLB->SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
     998           0 :     m_pMenuIconsLB->SaveValue();
     999           0 :     m_pFontHistoryCB->Check( aFontOpt.IsFontHistoryEnabled() );
    1000             : 
    1001             :     { // #i95644# HW accel (unified to disable mechanism)
    1002           0 :         if(pCanvasSettings->IsHardwareAccelerationAvailable())
    1003             :         {
    1004           0 :             m_pUseHardwareAccell->Check(pCanvasSettings->IsHardwareAccelerationEnabled());
    1005           0 :             m_pUseHardwareAccell->Enable(!pCanvasSettings->IsHardwareAccelerationRO());
    1006             :         }
    1007             :         else
    1008             :         {
    1009           0 :             m_pUseHardwareAccell->Check(false);
    1010           0 :             m_pUseHardwareAccell->Disable();
    1011             :         }
    1012             : 
    1013           0 :         m_pUseHardwareAccell->SaveValue();
    1014             :     }
    1015             : 
    1016             :     { // #i95644# AntiAliasing
    1017           0 :         if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
    1018             :         {
    1019           0 :             m_pUseAntiAliase->Check(mpDrawinglayerOpt->IsAntiAliasing());
    1020             :         }
    1021             :         else
    1022             :         {
    1023           0 :             m_pUseAntiAliase->Check(false);
    1024           0 :             m_pUseAntiAliase->Disable();
    1025             :         }
    1026             : 
    1027           0 :         m_pUseAntiAliase->SaveValue();
    1028             :     }
    1029           0 :     m_pUseOpenGL->Check(mpOpenGLConfig->useOpenGL());
    1030           0 :     m_pForceOpenGL->Check(mpOpenGLConfig->forceOpenGL());
    1031             : 
    1032             :     {
    1033             :         // #i97672# Selection
    1034             :         // check if transparent selection is possible on this system
    1035             :         const bool bTransparentSelectionPossible(
    1036           0 :             !GetSettings().GetStyleSettings().GetHighContrastMode()
    1037           0 :             && SupportsOperation(OutDevSupport_TransparentRect));
    1038             : 
    1039             :         // enter values
    1040           0 :         if(bTransparentSelectionPossible)
    1041             :         {
    1042           0 :             m_pSelectionCB->Check(mpDrawinglayerOpt->IsTransparentSelection());
    1043             :         }
    1044             :         else
    1045             :         {
    1046           0 :             m_pSelectionCB->Enable(false);
    1047             :         }
    1048             : 
    1049           0 :         m_pSelectionMF->SetValue(mpDrawinglayerOpt->GetTransparentSelectionPercent());
    1050           0 :         m_pSelectionMF->Enable(mpDrawinglayerOpt->IsTransparentSelection() && bTransparentSelectionPossible);
    1051             :     }
    1052             : 
    1053             : #if defined( UNX )
    1054           0 :     m_pFontAntiAliasing->SaveValue();
    1055           0 :     m_pAAPointLimit->SaveValue();
    1056             : #endif
    1057           0 :     m_pFontShowCB->SaveValue();
    1058           0 :     m_pFontHistoryCB->SaveValue();
    1059             : 
    1060             : #if defined( UNX )
    1061           0 :     LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL );
    1062             : #endif
    1063           0 : }
    1064             : 
    1065           0 : struct LanguageConfig_Impl
    1066             : {
    1067             :     SvtLanguageOptions aLanguageOptions;
    1068             :     SvtSysLocaleOptions aSysLocaleOptions;
    1069             :     SvtLinguConfig aLinguConfig;
    1070             : };
    1071             : 
    1072             : static bool bLanguageCurrentDoc_Impl = false;
    1073             : 
    1074             : // some things we'll need...
    1075             : static const char sAccessSrvc[] = "com.sun.star.configuration.ConfigurationAccess";
    1076             : static const char sAccessUpdSrvc[] = "com.sun.star.configuration.ConfigurationUpdateAccess";
    1077             : static const char sInstalledLocalesPath[] = "org.openoffice.Setup/Office/InstalledLocales";
    1078             : static const char sUserLocalePath[] = "org.openoffice.Office.Linguistic/General";
    1079             : static const char sUserLocaleKey[] = "UILocale";
    1080           0 : static Sequence< OUString > seqInstalledLanguages;
    1081             : 
    1082           0 : static OUString lcl_getDatePatternsConfigString( const LocaleDataWrapper& rLocaleWrapper )
    1083             : {
    1084           0 :     Sequence< OUString > aDateAcceptancePatterns = rLocaleWrapper.getDateAcceptancePatterns();
    1085           0 :     sal_Int32 nPatterns = aDateAcceptancePatterns.getLength();
    1086           0 :     OUStringBuffer aBuf( nPatterns * 6 );   // 6 := length of Y-M-D;
    1087             :     SAL_WARN_IF( !nPatterns, "cui.options", "No date acceptance pattern");
    1088           0 :     if (nPatterns)
    1089             :     {
    1090           0 :         const OUString* pPatterns = aDateAcceptancePatterns.getConstArray();
    1091           0 :         aBuf.append( pPatterns[0]);
    1092           0 :         for (sal_Int32 i=1; i < nPatterns; ++i)
    1093           0 :             aBuf.append(';').append( pPatterns[i]);
    1094             :     }
    1095           0 :     return aBuf.makeStringAndClear();
    1096             : }
    1097             : 
    1098           0 : OfaLanguagesTabPage::OfaLanguagesTabPage(vcl::Window* pParent, const SfxItemSet& rSet)
    1099             :     : SfxTabPage(pParent,"OptLanguagesPage","cui/ui/optlanguagespage.ui", &rSet)
    1100           0 :     , pLangConfig(new LanguageConfig_Impl)
    1101           0 :     , m_bDatePatternsValid(false)
    1102             : {
    1103           0 :     get(m_pUserInterfaceLB, "userinterface");
    1104           0 :     m_pUserInterfaceLB->SetStyle(m_pUserInterfaceLB->GetStyle() | WB_SORT);
    1105           0 :     get(m_pLocaleSettingLB, "localesetting");
    1106           0 :     m_pLocaleSettingLB->SetStyle(m_pLocaleSettingLB->GetStyle() | WB_SORT);
    1107           0 :     get(m_pLocaleSettingFT, "localesettingFT");
    1108           0 :     get(m_pDecimalSeparatorCB, "decimalseparator");
    1109           0 :     get(m_pCurrencyFT, "defaultcurrency");
    1110           0 :     get(m_pCurrencyLB, "currencylb");
    1111           0 :     m_pCurrencyLB->SetStyle(m_pCurrencyLB->GetStyle() | WB_SORT);
    1112           0 :     get(m_pDatePatternsFT,"dataaccpatterns");
    1113           0 :     get(m_pDatePatternsED, "datepatterns");
    1114             : 
    1115           0 :     get(m_pWesternLanguageLB, "westernlanguage");
    1116           0 :     m_pWesternLanguageLB->SetStyle(m_pWesternLanguageLB->GetStyle() | WB_SORT);
    1117           0 :     get(m_pWesternLanguageFT, "western");
    1118           0 :     get(m_pAsianLanguageLB, "asianlanguage");
    1119           0 :     m_pAsianLanguageLB->SetStyle(m_pAsianLanguageLB->GetStyle() | WB_SORT);
    1120           0 :     get(m_pComplexLanguageLB, "complexlanguage");
    1121           0 :     m_pComplexLanguageLB->SetStyle(m_pComplexLanguageLB->GetStyle() | WB_SORT);
    1122           0 :     get(m_pCurrentDocCB, "currentdoc");
    1123           0 :     get(m_pAsianSupportCB, "asiansupport");
    1124           0 :     get(m_pCTLSupportCB, "ctlsupport");
    1125           0 :     get(m_pIgnoreLanguageChangeCB, "ignorelanguagechange");
    1126             : 
    1127             :     // initialize user interface language selection
    1128           0 :     m_sSystemDefaultString = SvtLanguageTable::GetLanguageString( LANGUAGE_SYSTEM );
    1129             : 
    1130           0 :     OUString aUILang = m_sSystemDefaultString +
    1131           0 :                        " - " +
    1132           0 :                        SvtLanguageTable::GetLanguageString( Application::GetSettings().GetUILanguageTag().getLanguageType(), true );
    1133             : 
    1134           0 :     m_pUserInterfaceLB->InsertEntry(aUILang);
    1135           0 :     m_pUserInterfaceLB->SetEntryData(0, 0);
    1136           0 :     m_pUserInterfaceLB->SelectEntryPos(0);
    1137             :     try
    1138             :     {
    1139             :         Reference< XMultiServiceFactory > theConfigProvider(
    1140             :             com::sun::star::configuration::theDefaultProvider::get(
    1141           0 :                 comphelper::getProcessComponentContext()));
    1142           0 :         Sequence< Any > theArgs(1);
    1143           0 :         Reference< XNameAccess > theNameAccess;
    1144             : 
    1145             :         // find out which locales are currently installed and add them to the listbox
    1146           0 :         theArgs[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(OUString(sInstalledLocalesPath))));
    1147           0 :     theNameAccess = Reference< XNameAccess > (
    1148           0 :             theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
    1149           0 :         seqInstalledLanguages = theNameAccess->getElementNames();
    1150           0 :         LanguageType aLang = LANGUAGE_DONTKNOW;
    1151           0 :         for (sal_IntPtr i=0; i<seqInstalledLanguages.getLength(); i++)
    1152             :         {
    1153           0 :             aLang = LanguageTag::convertToLanguageTypeWithFallback(seqInstalledLanguages[i]);
    1154           0 :             if (aLang != LANGUAGE_DONTKNOW)
    1155             :             {
    1156             :                 //sal_uInt16 p = m_pUserInterfaceLB->InsertLanguage(aLang);
    1157           0 :                 OUString aLangStr( SvtLanguageTable::GetLanguageString( aLang, true ) );
    1158           0 :                 sal_uInt16 p = m_pUserInterfaceLB->InsertEntry(aLangStr);
    1159           0 :                 m_pUserInterfaceLB->SetEntryData(p, reinterpret_cast<void*>(i+1));
    1160             :             }
    1161             :         }
    1162             : 
    1163             :         // find out whether the user has a specific locale specified
    1164           0 :         Sequence< Any > theArgs2(1);
    1165           0 :         theArgs2[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(OUString(sUserLocalePath))));
    1166           0 :         theNameAccess = Reference< XNameAccess > (
    1167           0 :             theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
    1168           0 :         if (theNameAccess->hasByName(sUserLocaleKey))
    1169           0 :             theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
    1170             :         // select the user specified locale in the listbox
    1171           0 :         if (!m_sUserLocaleValue.isEmpty())
    1172             :         {
    1173           0 :             sal_Int32 d = 0;
    1174           0 :             for (sal_Int32 i=0; i < m_pUserInterfaceLB->GetEntryCount(); i++)
    1175             :             {
    1176           0 :                 d = (sal_Int32)reinterpret_cast<sal_IntPtr>(m_pUserInterfaceLB->GetEntryData(i));
    1177           0 :                 if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1].equals(m_sUserLocaleValue))
    1178           0 :                     m_pUserInterfaceLB->SelectEntryPos(i);
    1179             :             }
    1180           0 :         }
    1181             : 
    1182             :     }
    1183           0 :     catch (const Exception &e)
    1184             :     {
    1185             :         // we'll just leave the box in it's default setting and won't
    1186             :         // even give it event handler...
    1187             :         SAL_WARN("cui.options", "ignoring Exception \"" << e.Message << "\"");
    1188             :     }
    1189             : 
    1190           0 :     m_pWesternLanguageLB->SetLanguageList( SvxLanguageListFlags::WESTERN | SvxLanguageListFlags::ONLY_KNOWN, true, false, true );
    1191           0 :     m_pWesternLanguageLB->InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN );
    1192           0 :     m_pAsianLanguageLB->SetLanguageList( SvxLanguageListFlags::CJK     | SvxLanguageListFlags::ONLY_KNOWN, true, false, true );
    1193           0 :     m_pAsianLanguageLB->InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN );
    1194           0 :     m_pComplexLanguageLB->SetLanguageList( SvxLanguageListFlags::CTL     | SvxLanguageListFlags::ONLY_KNOWN, true, false, true );
    1195           0 :     m_pComplexLanguageLB->InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX );
    1196             : 
    1197           0 :     m_pLocaleSettingLB->SetLanguageList( SvxLanguageListFlags::ALL     | SvxLanguageListFlags::ONLY_KNOWN, false, false, false);
    1198           0 :     m_pLocaleSettingLB->InsertSystemLanguage( );
    1199             : 
    1200           0 :     const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
    1201           0 :     const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
    1202             :     // insert SYSTEM entry
    1203           0 :     OUString aDefaultCurr = m_sSystemDefaultString + " - " + rCurr.GetBankSymbol();
    1204           0 :     m_pCurrencyLB->InsertEntry( aDefaultCurr );
    1205             :     // all currencies
    1206           0 :     OUString aTwoSpace( "  " );
    1207           0 :     sal_uInt16 nCurrCount = rCurrTab.size();
    1208             :     // first entry is SYSTEM, skip it
    1209           0 :     for ( sal_uInt16 j=1; j < nCurrCount; ++j )
    1210             :     {
    1211           0 :         const NfCurrencyEntry* pCurr = &rCurrTab[j];
    1212           0 :         OUString aStr_ = pCurr->GetBankSymbol() +
    1213           0 :                          aTwoSpace +
    1214           0 :                          pCurr->GetSymbol();
    1215           0 :         aStr_ = ApplyLreOrRleEmbedding( aStr_ ) +
    1216           0 :                 aTwoSpace +
    1217           0 :                 ApplyLreOrRleEmbedding( SvtLanguageTable::GetLanguageString( pCurr->GetLanguage() ) );
    1218           0 :         sal_uInt16 nPos = m_pCurrencyLB->InsertEntry( aStr_ );
    1219           0 :         m_pCurrencyLB->SetEntryData( nPos, const_cast<NfCurrencyEntry *>(pCurr) );
    1220           0 :     }
    1221             : 
    1222           0 :     m_pLocaleSettingLB->SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
    1223           0 :     m_pDatePatternsED->SetModifyHdl( LINK( this, OfaLanguagesTabPage, DatePatternsHdl ) );
    1224             : 
    1225           0 :     Link<> aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
    1226           0 :     m_pAsianSupportCB->SetClickHdl( aLink );
    1227           0 :     m_pCTLSupportCB->SetClickHdl( aLink );
    1228             : 
    1229           0 :     m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled();
    1230           0 :     m_pAsianSupportCB->Check(m_bOldAsian);
    1231           0 :     m_pAsianSupportCB->SaveValue();
    1232           0 :     bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
    1233           0 :     m_pAsianSupportCB->Enable(!bReadonly);
    1234           0 :     SupportHdl( m_pAsianSupportCB );
    1235             : 
    1236           0 :     m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled();
    1237           0 :     m_pCTLSupportCB->Check(m_bOldCtl);
    1238           0 :     m_pCTLSupportCB->SaveValue();
    1239           0 :     bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
    1240           0 :     m_pCTLSupportCB->Enable(!bReadonly);
    1241           0 :     SupportHdl( m_pCTLSupportCB );
    1242             : 
    1243           0 :     m_pIgnoreLanguageChangeCB->Check( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange() );
    1244           0 : }
    1245             : 
    1246           0 : OfaLanguagesTabPage::~OfaLanguagesTabPage()
    1247             : {
    1248           0 :     disposeOnce();
    1249           0 : }
    1250             : 
    1251           0 : void OfaLanguagesTabPage::dispose()
    1252             : {
    1253           0 :     delete pLangConfig;
    1254           0 :     pLangConfig = NULL;
    1255           0 :     m_pUserInterfaceLB.clear();
    1256           0 :     m_pLocaleSettingFT.clear();
    1257           0 :     m_pLocaleSettingLB.clear();
    1258           0 :     m_pDecimalSeparatorCB.clear();
    1259           0 :     m_pCurrencyFT.clear();
    1260           0 :     m_pCurrencyLB.clear();
    1261           0 :     m_pDatePatternsFT.clear();
    1262           0 :     m_pDatePatternsED.clear();
    1263           0 :     m_pWesternLanguageLB.clear();
    1264           0 :     m_pWesternLanguageFT.clear();
    1265           0 :     m_pAsianLanguageLB.clear();
    1266           0 :     m_pComplexLanguageLB.clear();
    1267           0 :     m_pCurrentDocCB.clear();
    1268           0 :     m_pAsianSupportCB.clear();
    1269           0 :     m_pCTLSupportCB.clear();
    1270           0 :     m_pIgnoreLanguageChangeCB.clear();
    1271           0 :     SfxTabPage::dispose();
    1272           0 : }
    1273             : 
    1274           0 : VclPtr<SfxTabPage> OfaLanguagesTabPage::Create( vcl::Window* pParent, const SfxItemSet* rAttrSet )
    1275             : {
    1276           0 :     return VclPtr<OfaLanguagesTabPage>::Create(pParent, *rAttrSet);
    1277             : }
    1278             : 
    1279           0 : static void lcl_UpdateAndDelete(SfxVoidItem* pInvalidItems[], SfxBoolItem* pBoolItems[], sal_uInt16 nCount)
    1280             : {
    1281           0 :     SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
    1282           0 :     SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
    1283           0 :     while(pViewFrm)
    1284             :     {
    1285           0 :         SfxBindings& rBind = pViewFrm->GetBindings();
    1286           0 :         for(sal_Int16 i = 0; i < nCount; i++)
    1287             :         {
    1288           0 :             if(pCurrentFrm == pViewFrm)
    1289           0 :                 rBind.InvalidateAll(false);
    1290           0 :             rBind.SetState( *pInvalidItems[i] );
    1291           0 :             rBind.SetState( *pBoolItems[i] );
    1292             :         }
    1293           0 :         pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
    1294             :     }
    1295           0 :     for(sal_Int16 i = 0; i < nCount; i++)
    1296             :     {
    1297           0 :         delete pInvalidItems[i];
    1298           0 :         delete pBoolItems[i] ;
    1299             :     }
    1300           0 : }
    1301             : 
    1302           0 : bool OfaLanguagesTabPage::FillItemSet( SfxItemSet* rSet )
    1303             : {
    1304             :     // lock configuration broadcasters so that we can coordinate the notifications
    1305           0 :     pLangConfig->aSysLocaleOptions.BlockBroadcasts( true );
    1306           0 :     pLangConfig->aLanguageOptions.BlockBroadcasts( true );
    1307           0 :     pLangConfig->aLinguConfig.BlockBroadcasts( true );
    1308             : 
    1309             :     /*
    1310             :      * Sequence checking only matters when CTL support is enabled.
    1311             :      *
    1312             :      * So we only need to check for sequence checking if
    1313             :      * a) previously it was unchecked and is now checked or
    1314             :      * b) it was already checked but the CTL language has changed
    1315             :      */
    1316           0 :     if (
    1317           0 :          m_pCTLSupportCB->IsChecked() &&
    1318           0 :          (m_pCTLSupportCB->GetSavedValue() != TRISTATE_TRUE ||
    1319           0 :          m_pComplexLanguageLB->IsValueChangedFromSaved())
    1320             :        )
    1321             :     {
    1322             :         //sequence checking has to be switched on depending on the selected CTL language
    1323           0 :         LanguageType eCTLLang = m_pComplexLanguageLB->GetSelectLanguage();
    1324           0 :         bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
    1325           0 :         pLangConfig->aLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
    1326           0 :         pLangConfig->aLanguageOptions.SetCTLSequenceChecking(bOn);
    1327           0 :         pLangConfig->aLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
    1328             :     }
    1329             :     try
    1330             :     {
    1331             :         // handle settings for UI Language
    1332             :         // a change of setting needs to bring up a warning message
    1333           0 :         OUString aLangString;
    1334           0 :         sal_Int32 d = (sal_Int32)reinterpret_cast<sal_IntPtr>(m_pUserInterfaceLB->GetSelectEntryData());
    1335           0 :         if( d > 0 && seqInstalledLanguages.getLength() > d-1)
    1336           0 :             aLangString = seqInstalledLanguages[d-1];
    1337             : 
    1338             :         /*
    1339             :         if( m_pUserInterfaceLB->GetSelectEntryPos() > 0)
    1340             :             aLangString = ConvertLanguageToIsoString(m_pUserInterfaceLB->GetSelectLanguage());
    1341             :         */
    1342             :         Reference< XMultiServiceFactory > theConfigProvider(
    1343             :             com::sun::star::configuration::theDefaultProvider::get(
    1344           0 :                 comphelper::getProcessComponentContext()));
    1345           0 :         Sequence< Any > theArgs(1);
    1346           0 :         theArgs[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(OUString(sUserLocalePath))));
    1347             :         Reference< XPropertySet >xProp(
    1348           0 :             theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
    1349           0 :         if ( !m_sUserLocaleValue.equals(aLangString))
    1350             :         {
    1351             :             // OSL_FAIL("UserInterface language was changed, restart.");
    1352             :             // write new value
    1353           0 :             xProp->setPropertyValue(sUserLocaleKey, makeAny(aLangString));
    1354           0 :             Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
    1355             :             // display info
    1356           0 :             ScopedVclPtrInstance< MessageDialog > aBox(this, CUI_RES(RID_SVXSTR_LANGUAGE_RESTART), VCL_MESSAGE_INFO);
    1357           0 :             aBox->Execute();
    1358             : 
    1359             :             // tell quickstarter to stop being a veto listener
    1360             : 
    1361             :             Reference< XComponentContext > xContext(
    1362           0 :                 comphelper::getProcessComponentContext());
    1363           0 :             css::office::Quickstart::createAndSetVeto(xContext, false, false, false/*DisableVeto*/);
    1364           0 :         }
    1365             :     }
    1366           0 :     catch (const Exception& e)
    1367             :     {
    1368             :         // we'll just leave the box in it's default setting and won't
    1369             :         // even give it event handler...
    1370             :         SAL_WARN("cui.options", "ignoring Exception \"" << e.Message << "\"");
    1371             :     }
    1372             : 
    1373           0 :     OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
    1374           0 :     LanguageType eOldLocale = (!sLang.isEmpty() ?
    1375           0 :         LanguageTag::convertToLanguageTypeWithFallback( sLang ) : LANGUAGE_SYSTEM);
    1376           0 :     LanguageType eNewLocale = m_pLocaleSettingLB->GetSelectLanguage();
    1377             : 
    1378             :     // If the "Default ..." entry was selected that means SYSTEM, the actual
    1379             :     // eNewLocale value is temporary for the dialog only, do not resolve to
    1380             :     // what system currently is.
    1381           0 :     if (eNewLocale == LANGUAGE_USER_SYSTEM_CONFIG)
    1382           0 :         eNewLocale = LANGUAGE_SYSTEM;
    1383             : 
    1384           0 :     if ( eOldLocale != eNewLocale )
    1385             :     {
    1386             :         // an empty string denotes SYSTEM locale
    1387           0 :         OUString sNewLang;
    1388           0 :         if ( eNewLocale != LANGUAGE_SYSTEM )
    1389           0 :             sNewLang = LanguageTag::convertToBcp47( eNewLocale);
    1390             : 
    1391             :         // locale nowadays get to AppSettings via notification
    1392             :         // this will happen after releasing the lock on the ConfigurationBroadcaster at
    1393             :         // the end of this method
    1394           0 :         pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
    1395           0 :         rSet->Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, true ) );
    1396             : 
    1397           0 :         SvtScriptType nNewType = SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale );
    1398           0 :         bool bNewCJK = bool( nNewType & SvtScriptType::ASIAN );
    1399           0 :         SvtCompatibilityOptions aCompatOpts;
    1400           0 :         aCompatOpts.SetDefault( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE, !bNewCJK );
    1401             :     }
    1402             : 
    1403           0 :     if(m_pDecimalSeparatorCB->IsValueChangedFromSaved())
    1404           0 :         pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(m_pDecimalSeparatorCB->IsChecked());
    1405             : 
    1406           0 :     if(m_pIgnoreLanguageChangeCB->IsValueChangedFromSaved())
    1407           0 :         pLangConfig->aSysLocaleOptions.SetIgnoreLanguageChange(m_pIgnoreLanguageChangeCB->IsChecked());
    1408             : 
    1409             :     // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
    1410           0 :     OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
    1411           0 :     const NfCurrencyEntry* pCurr = static_cast<const NfCurrencyEntry*>(m_pCurrencyLB->GetSelectEntryData());
    1412           0 :     OUString sNewCurr;
    1413           0 :     if ( pCurr )
    1414           0 :         sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
    1415           0 :             pCurr->GetBankSymbol(), pCurr->GetLanguage() );
    1416           0 :     if ( sOldCurr != sNewCurr )
    1417           0 :         pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
    1418             : 
    1419             :     // Configured date acceptance patterns, for example Y-M-D;M-D or empty for
    1420             :     // locale default.
    1421           0 :     if (m_bDatePatternsValid && m_pDatePatternsED->IsValueChangedFromSaved())
    1422           0 :         pLangConfig->aSysLocaleOptions.SetDatePatternsConfigString( m_pDatePatternsED->GetText());
    1423             : 
    1424           0 :     SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
    1425           0 :     Reference< css::linguistic2::XLinguProperties > xLinguProp = LinguMgr::GetLinguPropertySet();
    1426           0 :     bool bCurrentDocCBChecked = m_pCurrentDocCB->IsChecked();
    1427           0 :     if(m_pCurrentDocCB->IsEnabled())
    1428           0 :         bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
    1429           0 :     bool bCurrentDocCBChanged = m_pCurrentDocCB->IsValueChangedFromSaved();
    1430             : 
    1431           0 :     bool bValChanged = m_pWesternLanguageLB->IsValueChangedFromSaved();
    1432           0 :     if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
    1433             :     {
    1434           0 :         LanguageType eSelectLang = m_pWesternLanguageLB->GetSelectLanguage();
    1435           0 :         if(!bCurrentDocCBChecked)
    1436             :         {
    1437           0 :             Any aValue;
    1438           0 :             Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
    1439           0 :             aValue <<= aLocale;
    1440           0 :             OUString aPropName( "DefaultLocale" );
    1441           0 :             pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
    1442           0 :             if (xLinguProp.is())
    1443           0 :                 xLinguProp->setDefaultLocale( aLocale );
    1444             :         }
    1445           0 :         if(pCurrentDocShell)
    1446             :         {
    1447           0 :             rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN),
    1448           0 :                 SID_ATTR_LANGUAGE));
    1449             :         }
    1450             :     }
    1451           0 :     bValChanged = m_pAsianLanguageLB->IsValueChangedFromSaved();
    1452           0 :     if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
    1453             :     {
    1454           0 :         LanguageType eSelectLang = m_pAsianLanguageLB->GetSelectLanguage();
    1455           0 :         if(!bCurrentDocCBChecked)
    1456             :         {
    1457           0 :             Any aValue;
    1458           0 :             Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
    1459           0 :             aValue <<= aLocale;
    1460           0 :             OUString aPropName( "DefaultLocale_CJK" );
    1461           0 :             pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
    1462           0 :             if (xLinguProp.is())
    1463           0 :                 xLinguProp->setDefaultLocale_CJK( aLocale );
    1464             :         }
    1465           0 :         if(pCurrentDocShell)
    1466             :         {
    1467           0 :             rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN),
    1468           0 :                 SID_ATTR_CHAR_CJK_LANGUAGE));
    1469             :         }
    1470             :     }
    1471           0 :     bValChanged = m_pComplexLanguageLB->IsValueChangedFromSaved();
    1472           0 :     if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
    1473             :     {
    1474           0 :         LanguageType eSelectLang = m_pComplexLanguageLB->GetSelectLanguage();
    1475           0 :         if(!bCurrentDocCBChecked)
    1476             :         {
    1477           0 :             Any aValue;
    1478           0 :             Locale aLocale = LanguageTag::convertToLocale( eSelectLang, false);
    1479           0 :             aValue <<= aLocale;
    1480           0 :             OUString aPropName( "DefaultLocale_CTL" );
    1481           0 :             pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
    1482           0 :             if (xLinguProp.is())
    1483           0 :                 xLinguProp->setDefaultLocale_CTL( aLocale );
    1484             :         }
    1485           0 :         if(pCurrentDocShell)
    1486             :         {
    1487           0 :             rSet->Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX),
    1488           0 :                 SID_ATTR_CHAR_CTL_LANGUAGE));
    1489             :         }
    1490             :     }
    1491             : 
    1492           0 :     if(m_pAsianSupportCB->IsValueChangedFromSaved() )
    1493             :     {
    1494           0 :         bool bChecked = m_pAsianSupportCB->IsChecked();
    1495           0 :         pLangConfig->aLanguageOptions.SetAll(bChecked);
    1496             : 
    1497             :         //iterate over all bindings to invalidate vertical text direction
    1498           0 :         const sal_uInt16 STATE_COUNT = 2;
    1499             : 
    1500             :         SfxBoolItem* pBoolItems[STATE_COUNT];
    1501           0 :         pBoolItems[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE, false);
    1502           0 :         pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, false);
    1503             : 
    1504             :         SfxVoidItem* pInvalidItems[STATE_COUNT];
    1505           0 :         pInvalidItems[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE);
    1506           0 :         pInvalidItems[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL);
    1507             : 
    1508           0 :         lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
    1509             :     }
    1510             : 
    1511           0 :     if ( m_pCTLSupportCB->IsValueChangedFromSaved() )
    1512             :     {
    1513           0 :         SvtSearchOptions aOpt;
    1514           0 :         aOpt.SetIgnoreDiacritics_CTL(true);
    1515           0 :         aOpt.SetIgnoreKashida_CTL(true);
    1516           0 :         aOpt.Commit();
    1517           0 :         pLangConfig->aLanguageOptions.SetCTLFontEnabled( m_pCTLSupportCB->IsChecked() );
    1518             : 
    1519           0 :         const sal_uInt16 STATE_COUNT = 1;
    1520             :         SfxBoolItem* pBoolItems[STATE_COUNT];
    1521           0 :         pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, false);
    1522             :         SfxVoidItem* pInvalidItems[STATE_COUNT];
    1523           0 :         pInvalidItems[0] = new SfxVoidItem(SID_CTLFONT_STATE);
    1524           0 :         lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
    1525             :     }
    1526             : 
    1527           0 :     if ( pLangConfig->aSysLocaleOptions.IsModified() )
    1528           0 :         pLangConfig->aSysLocaleOptions.Commit();
    1529             : 
    1530             :     // first release the lock on the ConfigurationBroadcaster for Locale changes
    1531             :     // it seems that our code relies on the fact that before other changes like e.g. currency
    1532             :     // are broadcasted locale changes have been done
    1533           0 :     pLangConfig->aSysLocaleOptions.BlockBroadcasts( false );
    1534           0 :     pLangConfig->aLanguageOptions.BlockBroadcasts( false );
    1535           0 :     pLangConfig->aLinguConfig.BlockBroadcasts( false );
    1536             : 
    1537           0 :     return false;
    1538             : }
    1539             : 
    1540           0 : void OfaLanguagesTabPage::Reset( const SfxItemSet* rSet )
    1541             : {
    1542           0 :     OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
    1543           0 :     if ( !sLang.isEmpty() )
    1544           0 :         m_pLocaleSettingLB->SelectLanguage(LanguageTag::convertToLanguageTypeWithFallback(sLang));
    1545             :     else
    1546           0 :         m_pLocaleSettingLB->SelectLanguage( LANGUAGE_USER_SYSTEM_CONFIG );
    1547           0 :     bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_LOCALE);
    1548           0 :     m_pLocaleSettingLB->Enable(!bReadonly);
    1549           0 :     m_pLocaleSettingFT->Enable(!bReadonly);
    1550             : 
    1551             : 
    1552           0 :     m_pDecimalSeparatorCB->Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
    1553           0 :     m_pDecimalSeparatorCB->SaveValue();
    1554             : 
    1555           0 :     m_pIgnoreLanguageChangeCB->Check( pLangConfig->aSysLocaleOptions.IsIgnoreLanguageChange());
    1556           0 :     m_pIgnoreLanguageChangeCB->SaveValue();
    1557             : 
    1558             :     // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
    1559             :     // #i15812# must be done *before* the configured currency is set
    1560             :     // and update the decimal separator used for the given locale
    1561           0 :     LocaleSettingHdl(m_pLocaleSettingLB);
    1562             : 
    1563             :     // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
    1564           0 :     OUString aAbbrev;
    1565             :     LanguageType eLang;
    1566           0 :     const NfCurrencyEntry* pCurr = NULL;
    1567           0 :     sLang = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
    1568           0 :     if ( !sLang.isEmpty() )
    1569             :     {
    1570           0 :         SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sLang );
    1571           0 :         pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
    1572             :     }
    1573             :     // if pCurr==NULL the SYSTEM entry is selected
    1574           0 :     sal_uInt16 nPos = m_pCurrencyLB->GetEntryPos( static_cast<void const *>(pCurr) );
    1575           0 :     m_pCurrencyLB->SelectEntryPos( nPos );
    1576           0 :     bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY);
    1577           0 :     m_pCurrencyLB->Enable(!bReadonly);
    1578           0 :     m_pCurrencyFT->Enable(!bReadonly);
    1579             : 
    1580             :     // date acceptance patterns
    1581           0 :     OUString aDatePatternsString = pLangConfig->aSysLocaleOptions.GetDatePatternsConfigString();
    1582           0 :     if (aDatePatternsString.isEmpty())
    1583             :     {
    1584           0 :         const LocaleDataWrapper& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
    1585           0 :         aDatePatternsString = lcl_getDatePatternsConfigString( rLocaleWrapper);
    1586             :     }
    1587             :     // Let's assume patterns are valid at this point.
    1588           0 :     m_bDatePatternsValid = true;
    1589           0 :     m_pDatePatternsED->SetText( aDatePatternsString);
    1590           0 :     bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_DATEPATTERNS);
    1591           0 :     m_pDatePatternsED->Enable(!bReadonly);
    1592           0 :     m_pDatePatternsFT->Enable(!bReadonly);
    1593           0 :     m_pDatePatternsED->SaveValue();
    1594             : 
    1595             :     //western/CJK/CLK language
    1596           0 :     LanguageType eCurLang = LANGUAGE_NONE;
    1597           0 :     LanguageType eCurLangCJK = LANGUAGE_NONE;
    1598           0 :     LanguageType eCurLangCTL = LANGUAGE_NONE;
    1599           0 :     SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
    1600             :     //collect the configuration values first
    1601           0 :     m_pCurrentDocCB->Enable(false);
    1602             : 
    1603           0 :     Any aWestLang;
    1604           0 :     Any aCJKLang;
    1605           0 :     Any aCTLLang;
    1606             :     try
    1607             :     {
    1608           0 :         aWestLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale");
    1609           0 :         Locale aLocale;
    1610           0 :         aWestLang >>= aLocale;
    1611             : 
    1612           0 :         eCurLang = LanguageTag::convertToLanguageType( aLocale, false);
    1613             : 
    1614           0 :         aCJKLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CJK");
    1615           0 :         aLocale = Locale();
    1616           0 :         aCJKLang >>= aLocale;
    1617           0 :         eCurLangCJK = LanguageTag::convertToLanguageType( aLocale, false);
    1618             : 
    1619           0 :         aCTLLang = pLangConfig->aLinguConfig.GetProperty("DefaultLocale_CTL");
    1620           0 :         aLocale = Locale();
    1621           0 :         aCTLLang >>= aLocale;
    1622           0 :         eCurLangCTL = LanguageTag::convertToLanguageType( aLocale, false);
    1623             :     }
    1624           0 :     catch (const Exception&)
    1625             :     {
    1626             :     }
    1627             :     //overwrite them by the values provided by the DocShell
    1628           0 :     if(pCurrentDocShell)
    1629             :     {
    1630           0 :         m_pCurrentDocCB->Enable(true);
    1631           0 :         m_pCurrentDocCB->Check(bLanguageCurrentDoc_Impl);
    1632             :         const SfxPoolItem* pLang;
    1633           0 :         if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_LANGUAGE, false, &pLang))
    1634             :         {
    1635           0 :             LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
    1636           0 :             if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang)
    1637           0 :                 eCurLang = eTempCurLang;
    1638             :         }
    1639             : 
    1640           0 :         if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, false, &pLang))
    1641             :         {
    1642           0 :             LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
    1643           0 :             if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang)
    1644           0 :                 eCurLangCJK = eTempCurLang;
    1645             :         }
    1646             : 
    1647           0 :         if( SfxItemState::SET == rSet->GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, false, &pLang))
    1648             :         {
    1649           0 :             LanguageType eTempCurLang = static_cast<const SvxLanguageItem*>(pLang)->GetValue();
    1650           0 :             if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang)
    1651           0 :                 eCurLangCTL = eTempCurLang;
    1652             :         }
    1653             :     }
    1654           0 :     if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
    1655           0 :         m_pWesternLanguageLB->SelectLanguage(LANGUAGE_NONE);
    1656             :     else
    1657           0 :         m_pWesternLanguageLB->SelectLanguage(eCurLang);
    1658             : 
    1659           0 :     if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
    1660           0 :         m_pAsianLanguageLB->SelectLanguage(LANGUAGE_NONE);
    1661             :     else
    1662           0 :         m_pAsianLanguageLB->SelectLanguage(eCurLangCJK);
    1663             : 
    1664           0 :     if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
    1665           0 :         m_pComplexLanguageLB->SelectLanguage(LANGUAGE_NONE);
    1666             :     else
    1667           0 :         m_pComplexLanguageLB->SelectLanguage(eCurLangCTL);
    1668             : 
    1669           0 :     m_pWesternLanguageLB->SaveValue();
    1670           0 :     m_pAsianLanguageLB->SaveValue();
    1671           0 :     m_pComplexLanguageLB->SaveValue();
    1672           0 :     m_pIgnoreLanguageChangeCB->SaveValue();
    1673           0 :     m_pCurrentDocCB->SaveValue();
    1674             : 
    1675           0 :     bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale" );
    1676           0 :     m_pWesternLanguageFT->Enable( bEnable );
    1677           0 :     m_pWesternLanguageLB->Enable( bEnable );
    1678             : 
    1679             : 
    1680             : 
    1681             :     // #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
    1682             : #if 0
    1683             :     bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale_CJK" ) && m_pAsianSupportCB->IsChecked() );
    1684             :     m_pAsianLanguageLB->Enable( bEnable );
    1685             : 
    1686             :     bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( "DefaultLocale_CTL" ) && m_pCTLSupportCB->IsChecked() );
    1687             :     m_pComplexLanguageLB->Enable( bEnable );
    1688             : #endif
    1689             :     // check the box "For the current document only"
    1690             :     // set the focus to the Western Language box
    1691           0 :     const SfxPoolItem* pLang = 0;
    1692           0 :     if ( SfxItemState::SET == rSet->GetItemState(SID_SET_DOCUMENT_LANGUAGE, false, &pLang ) && static_cast<const SfxBoolItem*>(pLang)->GetValue() )
    1693             :     {
    1694           0 :         m_pWesternLanguageLB->GrabFocus();
    1695           0 :         m_pCurrentDocCB->Enable(true);
    1696           0 :         m_pCurrentDocCB->Check(true);
    1697           0 :     }
    1698           0 : }
    1699             : 
    1700           0 : IMPL_LINK(  OfaLanguagesTabPage, SupportHdl, CheckBox*, pBox )
    1701             : {
    1702             :     DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
    1703             : 
    1704           0 :     bool bCheck = pBox->IsChecked();
    1705           0 :     if ( m_pAsianSupportCB == pBox )
    1706             :     {
    1707           0 :         bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CJK");
    1708           0 :         bCheck = ( bCheck && !bReadonly );
    1709           0 :         m_pAsianLanguageLB->Enable( bCheck );
    1710           0 :         if( pBox->IsEnabled() )
    1711           0 :             m_bOldAsian = bCheck;
    1712             :     }
    1713           0 :     else if ( m_pCTLSupportCB == pBox )
    1714             :     {
    1715           0 :         bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly("DefaultLocale_CTL");
    1716           0 :         bCheck = ( bCheck && !bReadonly  );
    1717           0 :         m_pComplexLanguageLB->Enable( bCheck );
    1718           0 :         if( pBox->IsEnabled() )
    1719           0 :             m_bOldCtl = bCheck;
    1720             :     }
    1721             :     else
    1722             :         SAL_WARN( "cui.options", "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
    1723             : 
    1724           0 :     return 0;
    1725             : }
    1726             : 
    1727             : namespace
    1728             : {
    1729           0 :     void lcl_checkLanguageCheckBox(CheckBox* _rCB,bool _bNewValue,bool _bOldValue)
    1730             :     {
    1731           0 :         if ( _bNewValue )
    1732           0 :             _rCB->Check(true);
    1733             :         else
    1734           0 :             _rCB->Check( _bOldValue );
    1735             : // #i15082# do not call SaveValue() in running dialog...
    1736             : //      _rCB.SaveValue();
    1737           0 :         _rCB->Enable( !_bNewValue );
    1738           0 :     }
    1739             : }
    1740             : 
    1741           0 : IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
    1742             : {
    1743           0 :     LanguageType eLang = pBox->GetSelectLanguage();
    1744           0 :     SvtScriptType nType = SvtLanguageOptions::GetScriptTypeOfLanguage(eLang);
    1745             :     // first check if CTL must be enabled
    1746             :     // #103299# - if CTL font setting is not readonly
    1747           0 :     if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT))
    1748             :     {
    1749           0 :         bool bIsCTLFixed = bool(nType & SvtScriptType::COMPLEX);
    1750           0 :         lcl_checkLanguageCheckBox(m_pCTLSupportCB, bIsCTLFixed, m_bOldCtl);
    1751           0 :         SupportHdl( m_pCTLSupportCB );
    1752             :     }
    1753             :     // second check if CJK must be enabled
    1754             :     // #103299# - if CJK support is not readonly
    1755           0 :     if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
    1756             :     {
    1757           0 :         bool bIsCJKFixed = bool(nType & SvtScriptType::ASIAN);
    1758           0 :         lcl_checkLanguageCheckBox(m_pAsianSupportCB, bIsCJKFixed, m_bOldAsian);
    1759           0 :         SupportHdl( m_pAsianSupportCB );
    1760             :     }
    1761             : 
    1762             :     const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry(
    1763           0 :             ((eLang == LANGUAGE_USER_SYSTEM_CONFIG) ? MsLangId::getSystemLanguage() : eLang));
    1764           0 :     sal_uInt16 nPos = m_pCurrencyLB->GetEntryPos( nullptr );
    1765           0 :     if (pCurr)
    1766             :     {
    1767             :         // Update the "Default ..." currency.
    1768           0 :         m_pCurrencyLB->RemoveEntry( nPos );
    1769           0 :         OUString aDefaultCurr = m_sSystemDefaultString + " - " + pCurr->GetBankSymbol();
    1770           0 :         nPos = m_pCurrencyLB->InsertEntry( aDefaultCurr );
    1771             :     }
    1772           0 :     m_pCurrencyLB->SelectEntryPos( nPos );
    1773             : 
    1774             :     // obtain corresponding locale data
    1775           0 :     LanguageTag aLanguageTag( eLang);
    1776           0 :     LocaleDataWrapper aLocaleWrapper( aLanguageTag );
    1777             : 
    1778             :     // update the decimal separator key of the related CheckBox
    1779           0 :     OUString sTempLabel(m_pDecimalSeparatorCB->GetText());
    1780           0 :     sTempLabel = sTempLabel.replaceFirst("%1", aLocaleWrapper.getNumDecimalSep() );
    1781           0 :     m_pDecimalSeparatorCB->SetText(sTempLabel);
    1782             : 
    1783             :     // update the date acceptance patterns
    1784           0 :     OUString aDatePatternsString = lcl_getDatePatternsConfigString( aLocaleWrapper);
    1785           0 :     m_bDatePatternsValid = true;
    1786           0 :     m_pDatePatternsED->SetText( aDatePatternsString);
    1787             : 
    1788           0 :     return 0;
    1789             : }
    1790             : 
    1791           0 : IMPL_LINK( OfaLanguagesTabPage, DatePatternsHdl, Edit*, pEd )
    1792             : {
    1793           0 :     const OUString aPatterns( pEd->GetText());
    1794           0 :     OUStringBuffer aBuf( aPatterns);
    1795           0 :     sal_Int32 nChar = 0;
    1796           0 :     bool bValid = true;
    1797           0 :     bool bModified = false;
    1798           0 :     if (!aPatterns.isEmpty())
    1799             :     {
    1800           0 :         for (sal_Int32 nIndex=0; nIndex >= 0 && bValid; ++nChar)
    1801             :         {
    1802           0 :             const OUString aPat( aPatterns.getToken( 0, ';', nIndex));
    1803           0 :             if (aPat.isEmpty() && nIndex < 0)
    1804             :             {
    1805             :                 // Indicating failure when about to append a pattern is too
    1806             :                 // confusing. Empty patterns are ignored anyway when sequencing
    1807             :                 // to SvtSysLocale.
    1808           0 :                 continue;   // for
    1809             :             }
    1810           0 :             else if (aPat.getLength() < 2)
    1811           0 :                 bValid = false;
    1812             :             else
    1813             :             {
    1814             :                 bool bY, bM, bD;
    1815           0 :                 bY = bM = bD = false;
    1816           0 :                 bool bSep = true;
    1817           0 :                 for (sal_Int32 i = 0; i < aPat.getLength() && bValid; /*nop*/)
    1818             :                 {
    1819           0 :                     const sal_Int32 j = i;
    1820           0 :                     const sal_uInt32 c = aPat.iterateCodePoints( &i);
    1821             :                     // Only one Y,M,D per pattern, separated by any character(s).
    1822           0 :                     switch (c)
    1823             :                     {
    1824             :                         case 'y':
    1825             :                         case 'Y':
    1826           0 :                             if (bY || !bSep)
    1827           0 :                                 bValid = false;
    1828           0 :                             else if (c == 'y')
    1829             :                             {
    1830           0 :                                 aBuf[nChar] = 'Y';
    1831           0 :                                 bModified = true;
    1832             :                             }
    1833           0 :                             bY = true;
    1834           0 :                             bSep = false;
    1835           0 :                             break;
    1836             :                         case 'm':
    1837             :                         case 'M':
    1838           0 :                             if (bM || !bSep)
    1839           0 :                                 bValid = false;
    1840           0 :                             else if (c == 'm')
    1841             :                             {
    1842           0 :                                 aBuf[nChar] = 'M';
    1843           0 :                                 bModified = true;
    1844             :                             }
    1845           0 :                             bM = true;
    1846           0 :                             bSep = false;
    1847           0 :                             break;
    1848             :                         case 'd':
    1849             :                         case 'D':
    1850           0 :                             if (bD || !bSep)
    1851           0 :                                 bValid = false;
    1852           0 :                             else if (c == 'd')
    1853             :                             {
    1854           0 :                                 aBuf[nChar] = 'D';
    1855           0 :                                 bModified = true;
    1856             :                             }
    1857           0 :                             bD = true;
    1858           0 :                             bSep = false;
    1859           0 :                             break;
    1860             :                         default:
    1861             :                             // A pattern must not start with a separator (but
    1862             :                             // may end with).
    1863           0 :                             if (!(bY || bM || bD))
    1864           0 :                                 bValid = false;
    1865           0 :                             bSep = true;
    1866             :                     }
    1867           0 :                     nChar += i-j;
    1868             :                 }
    1869             :                 // At least one of Y,M,D
    1870           0 :                 bValid &= (bY || bM || bD);
    1871             :             }
    1872           0 :         }
    1873             :     }
    1874           0 :     if (bModified)
    1875             :     {
    1876             :         // Do not use SetText(...,GetSelection()) because internally the
    1877             :         // reference's pointer of the selection is obtained resulting in the
    1878             :         // entire text being selected at the end.
    1879           0 :         Selection aSelection( pEd->GetSelection());
    1880           0 :         pEd->SetText( aBuf.makeStringAndClear(), aSelection);
    1881             :     }
    1882           0 :     if (bValid)
    1883             :     {
    1884           0 :         pEd->SetControlForeground();
    1885           0 :         pEd->SetControlBackground();
    1886             :     }
    1887             :     else
    1888             :     {
    1889             : #if 0
    1890             :         //! Gives white on white!?! instead of white on reddish.
    1891             :         pEd->SetControlBackground( ::Color( RGB_COLORDATA( 0xff, 0x65, 0x63)));
    1892             :         pEd->SetControlForeground( ::Color( COL_WHITE));
    1893             : #else
    1894           0 :         pEd->SetControlForeground( ::Color( RGB_COLORDATA( 0xf0, 0, 0)));
    1895             : #endif
    1896             :     }
    1897           0 :     m_bDatePatternsValid = bValid;
    1898           0 :     return 0;
    1899           0 : }
    1900             : 
    1901             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11