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

Generated by: LCOV version 1.10