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

Generated by: LCOV version 1.10