1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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"
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 <sal/macros.h>
70 #include <com/sun/star/configuration/theDefaultProvider.hpp>
71 #include <com/sun/star/container/XNameAccess.hpp>
72 #include <com/sun/star/container/XNameReplace.hpp>
73 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
74 #include <com/sun/star/lang/XComponent.hpp>
75 #include <com/sun/star/lang/XInitialization.hpp>
76 #include <com/sun/star/beans/NamedValue.hpp>
77 #include <com/sun/star/beans/XPropertySet.hpp>
78 #include <com/sun/star/util/XChangesBatch.hpp>
79 #include <com/sun/star/uno/Any.hxx>
80 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
81 #include <com/sun/star/container/XSet.hpp>
82 #include <com/sun/star/i18n/ScriptType.hpp>
84 #include <vcl/svapp.hxx>
86 #include "optgdlg.hrc"
87 #include "optgdlg.hxx"
88 #include <svx/ofaitem.hxx>
89 #include <svtools/apearcfg.hxx>
90 #include <svtools/optionsdrawinglayer.hxx>
92 #include <config_vclplug.h>
94 using namespace ::com::sun::star::uno
;
95 using namespace ::com::sun::star::lang
;
96 using namespace ::com::sun::star::beans
;
97 using namespace ::com::sun::star::container
;
98 using namespace ::com::sun::star::util
;
99 using namespace ::utl
;
101 // class OfaMiscTabPage --------------------------------------------------
103 int OfaMiscTabPage::DeactivatePage( SfxItemSet
* pSet_
)
106 FillItemSet( *pSet_
);
112 static OUString
impl_SystemFileOpenServiceName()
114 const OUString
&rDesktopEnvironment
= Application::GetDesktopEnvironment();
116 if ( rDesktopEnvironment
.equalsIgnoreAsciiCase("kde4") )
119 return OUString("com.sun.star.ui.dialogs.KDE4FilePicker" );
124 else if ( rDesktopEnvironment
.equalsIgnoreAsciiCase("kde") )
127 return OUString("com.sun.star.ui.dialogs.KDEFilePicker");
132 else if ( rDesktopEnvironment
.equalsIgnoreAsciiCase("tde") )
135 return OUString("com.sun.star.ui.dialogs.TDEFilePicker");
141 return OUString("com.sun.star.ui.dialogs.SystemFilePicker");
143 return OUString("com.sun.star.ui.dialogs.AquaFilePicker");
149 static bool lcl_HasSystemFilePicker()
151 if( Application::hasNativeFileSelection() )
154 // Otherwise fall-back on querying services
156 Reference
< XMultiServiceFactory
> xFactory
= comphelper::getProcessServiceFactory();
158 Reference
< XContentEnumerationAccess
> xEnumAccess( xFactory
, UNO_QUERY
);
159 Reference
< XSet
> xSet( xFactory
, UNO_QUERY
);
161 if ( ! xEnumAccess
.is() || ! xSet
.is() )
166 OUString aFileService
= impl_SystemFileOpenServiceName();
167 Reference
< XEnumeration
> xEnum
= xEnumAccess
->createContentEnumeration( aFileService
);
168 if ( xEnum
.is() && xEnum
->hasMoreElements() )
171 catch (const IllegalArgumentException
&)
174 catch (const ElementExistException
&)
181 // -----------------------------------------------------------------------
183 OfaMiscTabPage::OfaMiscTabPage(Window
* pParent
, const SfxItemSet
& rSet
)
184 : SfxTabPage(pParent
, "OptGeneralPage", "cui/ui/optgeneralpage.ui", rSet
)
186 get(m_pToolTipsCB
, "tooltips");
187 get(m_pExtHelpCB
, "exthelp");
188 if (!lcl_HasSystemFilePicker())
189 get
<VclContainer
>("filedlgframe")->Hide();
191 get
<VclContainer
>("printdlgframe")->Hide();
193 if (!SvtMiscOptions().IsExperimentalMode())
195 get
<VclContainer
>("printdlgframe")->Hide();
198 get(m_pFileDlgCB
, "filedlg");
199 get(m_pPrintDlgCB
, "printdlg");
200 get(m_pDocStatusCB
, "docstatus");
201 get(m_pSaveAlwaysCB
, "savealways");
202 get(m_pYearFrame
, "yearframe");
203 get(m_pYearValueField
, "year");
204 get(m_pToYearFT
, "toyear");
206 if (m_pFileDlgCB
->IsVisible() && SvtMiscOptions().IsUseSystemFileDialogReadOnly())
208 m_pFileDlgROImage
->Show();
209 m_pFileDlgCB
->Disable();
212 m_aStrDateInfo
= m_pToYearFT
->GetText();
213 m_pYearValueField
->SetModifyHdl( LINK( this, OfaMiscTabPage
, TwoFigureHdl
) );
214 Link aLink
= LINK( this, OfaMiscTabPage
, TwoFigureConfigHdl
);
215 m_pYearValueField
->SetDownHdl( aLink
);
216 m_pYearValueField
->SetUpHdl( aLink
);
217 m_pYearValueField
->SetLoseFocusHdl( aLink
);
218 m_pYearValueField
->SetFirstHdl( aLink
);
219 TwoFigureConfigHdl(m_pYearValueField
);
221 SetExchangeSupport();
223 aLink
= LINK( this, OfaMiscTabPage
, HelpCheckHdl_Impl
);
224 m_pToolTipsCB
->SetClickHdl( aLink
);
227 // -----------------------------------------------------------------------
229 OfaMiscTabPage::~OfaMiscTabPage()
233 // -----------------------------------------------------------------------
235 SfxTabPage
* OfaMiscTabPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
237 return new OfaMiscTabPage( pParent
, rAttrSet
);
240 // -----------------------------------------------------------------------
242 sal_Bool
OfaMiscTabPage::FillItemSet( SfxItemSet
& rSet
)
244 sal_Bool bModified
= sal_False
;
246 SvtHelpOptions aHelpOptions
;
247 sal_Bool bChecked
= m_pToolTipsCB
->IsChecked();
248 if ( bChecked
!= m_pToolTipsCB
->GetSavedValue() )
249 aHelpOptions
.SetHelpTips( bChecked
);
250 bChecked
= ( m_pExtHelpCB
->IsChecked() && m_pToolTipsCB
->IsChecked() );
251 if ( bChecked
!= m_pExtHelpCB
->GetSavedValue() )
252 aHelpOptions
.SetExtendedHelp( bChecked
);
254 if ( m_pFileDlgCB
->IsChecked() != m_pFileDlgCB
->GetSavedValue() )
256 SvtMiscOptions aMiscOpt
;
257 aMiscOpt
.SetUseSystemFileDialog( !m_pFileDlgCB
->IsChecked() );
258 bModified
= sal_True
;
261 if ( m_pPrintDlgCB
->IsChecked() != m_pPrintDlgCB
->GetSavedValue() )
263 SvtMiscOptions aMiscOpt
;
264 aMiscOpt
.SetUseSystemPrintDialog( !m_pPrintDlgCB
->IsChecked() );
265 bModified
= sal_True
;
268 if ( m_pDocStatusCB
->IsChecked() != m_pDocStatusCB
->GetSavedValue() )
270 SvtPrintWarningOptions aPrintOptions
;
271 aPrintOptions
.SetModifyDocumentOnPrintingAllowed( m_pDocStatusCB
->IsChecked() );
272 bModified
= sal_True
;
275 if ( m_pSaveAlwaysCB
->IsChecked() != m_pSaveAlwaysCB
->GetSavedValue() )
277 SvtMiscOptions aMiscOpt
;
278 aMiscOpt
.SetSaveAlwaysAllowed( m_pSaveAlwaysCB
->IsChecked() );
279 bModified
= sal_True
;
282 const SfxUInt16Item
* pUInt16Item
=
283 PTR_CAST( SfxUInt16Item
, GetOldItem( rSet
, SID_ATTR_YEAR2000
) );
284 sal_uInt16 nNum
= (sal_uInt16
)m_pYearValueField
->GetText().toInt32();
285 if ( pUInt16Item
&& pUInt16Item
->GetValue() != nNum
)
287 bModified
= sal_True
;
288 rSet
.Put( SfxUInt16Item( SID_ATTR_YEAR2000
, nNum
) );
294 // -----------------------------------------------------------------------
296 void OfaMiscTabPage::Reset( const SfxItemSet
& rSet
)
298 SvtHelpOptions aHelpOptions
;
299 m_pToolTipsCB
->Check( aHelpOptions
.IsHelpTips() );
300 m_pExtHelpCB
->Check( aHelpOptions
.IsHelpTips() && aHelpOptions
.IsExtendedHelp() );
302 m_pToolTipsCB
->SaveValue();
303 m_pExtHelpCB
->SaveValue();
305 SvtMiscOptions aMiscOpt
;
306 m_pFileDlgCB
->Check( !aMiscOpt
.UseSystemFileDialog() );
307 m_pFileDlgCB
->SaveValue();
308 m_pPrintDlgCB
->Check( !aMiscOpt
.UseSystemPrintDialog() );
309 m_pPrintDlgCB
->SaveValue();
310 m_pSaveAlwaysCB
->Check( aMiscOpt
.IsSaveAlwaysAllowed() );
311 m_pSaveAlwaysCB
->SaveValue();
313 SvtPrintWarningOptions aPrintOptions
;
314 m_pDocStatusCB
->Check(aPrintOptions
.IsModifyDocumentOnPrintingAllowed());
315 m_pDocStatusCB
->SaveValue();
317 const SfxPoolItem
* pItem
= NULL
;
318 if ( SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_YEAR2000
, sal_False
, &pItem
) )
320 m_pYearValueField
->SetValue( ((SfxUInt16Item
*)pItem
)->GetValue() );
321 TwoFigureConfigHdl(m_pYearValueField
);
325 m_pYearFrame
->Enable(sal_False
);
329 // -----------------------------------------------------------------------
331 IMPL_LINK( OfaMiscTabPage
, TwoFigureHdl
, NumericField
*, pEd
)
335 OUString
aOutput( m_aStrDateInfo
);
336 OUString
aStr( m_pYearValueField
->GetText() );
337 OUString
sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
338 sal_Int32 nIndex
= 0;
339 while ((nIndex
= aStr
.indexOf( sSep
, nIndex
)) != -1)
340 aStr
= aStr
.replaceAt( nIndex
, sSep
.getLength(), "");
341 sal_Int32 nNum
= aStr
.toInt32();
342 if ( aStr
.getLength() != 4 || nNum
< m_pYearValueField
->GetMin() || nNum
> m_pYearValueField
->GetMax() )
347 aOutput
+= OUString::number( nNum
);
349 m_pToYearFT
->SetText( aOutput
);
353 // -----------------------------------------------------------------------
355 IMPL_LINK( OfaMiscTabPage
, TwoFigureConfigHdl
, NumericField
*, pEd
)
357 sal_Int64 nNum
= m_pYearValueField
->GetValue();
358 OUString
aOutput(OUString::number(nNum
));
359 m_pYearValueField
->SetText(aOutput
);
360 m_pYearValueField
->SetSelection( Selection( 0, aOutput
.getLength() ) );
365 // -----------------------------------------------------------------------
367 IMPL_LINK_NOARG(OfaMiscTabPage
, HelpCheckHdl_Impl
)
369 m_pExtHelpCB
->Enable( m_pToolTipsCB
->IsChecked() );
373 // -----------------------------------------------------------------------
380 sal_Bool
IsHardwareAccelerationEnabled() const;
381 sal_Bool
IsHardwareAccelerationAvailable() const;
382 void EnabledHardwareAcceleration( sal_Bool _bEnabled
) const;
385 typedef std::vector
< std::pair
<OUString
,Sequence
<OUString
> > > ServiceVector
;
387 Reference
<XNameAccess
> mxForceFlagNameAccess
;
388 ServiceVector maAvailableImplementations
;
389 mutable sal_Bool mbHWAccelAvailable
;
390 mutable sal_Bool mbHWAccelChecked
;
393 // -------------------------------------------------------------------
394 CanvasSettings::CanvasSettings() :
395 mxForceFlagNameAccess(),
396 mbHWAccelAvailable(sal_False
),
397 mbHWAccelChecked(sal_False
)
401 Reference
<XMultiServiceFactory
> xConfigProvider(
402 com::sun::star::configuration::theDefaultProvider::get(
403 comphelper::getProcessComponentContext()));
407 OUString("nodepath"),
408 makeAny( OUString("/org.openoffice.Office.Canvas") ) ) ) );
410 mxForceFlagNameAccess
.set(
411 xConfigProvider
->createInstanceWithArguments(
412 OUString("com.sun.star.configuration.ConfigurationUpdateAccess"),
413 Sequence
<Any
>( &propValue
, 1 ) ),
418 OUString("nodepath"),
419 makeAny( OUString("/org.openoffice.Office.Canvas/CanvasServiceList") ) ) );
421 Reference
<XNameAccess
> xNameAccess(
422 xConfigProvider
->createInstanceWithArguments(
423 OUString("com.sun.star.configuration.ConfigurationAccess"),
424 Sequence
<Any
>( &propValue
, 1 ) ), UNO_QUERY_THROW
);
425 Reference
<XHierarchicalNameAccess
> xHierarchicalNameAccess(
426 xNameAccess
, UNO_QUERY_THROW
);
428 Sequence
<OUString
> serviceNames
= xNameAccess
->getElementNames();
429 const OUString
* pCurr
= serviceNames
.getConstArray();
430 const OUString
* const pEnd
= pCurr
+ serviceNames
.getLength();
431 while( pCurr
!= pEnd
)
433 Reference
<XNameAccess
> xEntryNameAccess(
434 xHierarchicalNameAccess
->getByHierarchicalName(*pCurr
),
437 if( xEntryNameAccess
.is() )
439 Sequence
<OUString
> preferredImplementations
;
440 if( (xEntryNameAccess
->getByName( OUString("PreferredImplementations") ) >>= preferredImplementations
) )
441 maAvailableImplementations
.push_back( std::make_pair(*pCurr
,preferredImplementations
) );
447 catch (const Exception
&)
452 // -------------------------------------------------------------------
453 sal_Bool
CanvasSettings::IsHardwareAccelerationAvailable() const
455 if( !mbHWAccelChecked
)
457 mbHWAccelChecked
= true;
459 Reference
< XMultiServiceFactory
> xFactory
= comphelper::getProcessServiceFactory();
461 // check whether any of the service lists has an
462 // implementation that presents the "HardwareAcceleration" property
463 ServiceVector::const_iterator aCurr
=maAvailableImplementations
.begin();
464 const ServiceVector::const_iterator aEnd
=maAvailableImplementations
.end();
465 while( aCurr
!= aEnd
)
467 const OUString
* pCurrImpl
= aCurr
->second
.getConstArray();
468 const OUString
* const pEndImpl
= pCurrImpl
+ aCurr
->second
.getLength();
470 while( pCurrImpl
!= pEndImpl
)
474 Reference
<XPropertySet
> xPropSet( xFactory
->createInstance(
477 bool bHasAccel(false);
478 if( (xPropSet
->getPropertyValue(OUString("HardwareAcceleration")) >>= bHasAccel
) )
481 mbHWAccelAvailable
= true;
482 return mbHWAccelAvailable
;
485 catch (const Exception
&)
496 return mbHWAccelAvailable
;
499 // -------------------------------------------------------------------
500 sal_Bool
CanvasSettings::IsHardwareAccelerationEnabled() const
502 bool bForceLastEntry(false);
503 if( !mxForceFlagNameAccess
.is() )
506 if( !(mxForceFlagNameAccess
->getByName( OUString("ForceSafeServiceImpl") ) >>= bForceLastEntry
) )
509 return !bForceLastEntry
;
512 // -------------------------------------------------------------------
513 void CanvasSettings::EnabledHardwareAcceleration( sal_Bool _bEnabled
) const
515 Reference
< XNameReplace
> xNameReplace(
516 mxForceFlagNameAccess
, UNO_QUERY
);
518 if( !xNameReplace
.is() )
521 xNameReplace
->replaceByName( OUString("ForceSafeServiceImpl"),
522 makeAny(!_bEnabled
) );
524 Reference
< XChangesBatch
> xChangesBatch(
525 mxForceFlagNameAccess
, UNO_QUERY
);
527 if( !xChangesBatch
.is() )
530 xChangesBatch
->commitChanges();
533 // class OfaViewTabPage --------------------------------------------------
535 OfaViewTabPage::OfaViewTabPage(Window
* pParent
, const SfxItemSet
& rSet
)
536 : SfxTabPage(pParent
, "OptViewPage", "cui/ui/optviewpage.ui", rSet
)
537 , nSizeLB_InitialSelection(0)
538 , nStyleLB_InitialSelection(0)
539 , pAppearanceCfg(new SvtTabAppearanceCfg
)
540 , pCanvasSettings(new CanvasSettings
)
541 , mpDrawinglayerOpt(new SvtOptionsDrawinglayer
)
543 get(m_pWindowSizeMF
, "windowsize");
544 get(m_pIconSizeLB
, "iconsize");
545 get(m_pIconStyleLB
, "iconstyle");
546 get(m_pSystemFont
, "systemfont");
547 get(m_pFontAntiAliasing
, "aafont");
548 get(m_pAAPointLimitLabel
, "aafrom");
549 get(m_pAAPointLimit
, "aanf");
550 get(m_pAAPointLimitUnits
, "aaunits");
551 get(m_pMenuIconsLB
, "menuicons");
552 get(m_pFontShowCB
, "showfontpreview");
553 get(m_pFontHistoryCB
, "showfonthistory");
554 get(m_pUseHardwareAccell
, "useaccel");
555 get(m_pUseAntiAliase
, "useaa");
556 get(m_pMousePosLB
, "mousepos");
557 get(m_pMouseMiddleLB
, "mousemiddle");
559 get(m_pSelectionCB
, "trans");
560 get(m_pSelectionMF
, "transmf");
563 m_pFontAntiAliasing
->SetToggleHdl( LINK( this, OfaViewTabPage
, OnAntialiasingToggled
) );
565 // on this platform, we do not have the anti aliasing options
566 m_pFontAntiAliasing
->Hide();
567 m_pAAPointLimitLabel
->Hide();
568 m_pAAPointLimit
->Hide();
569 m_pAAPointLimitUnits
->Hide();
574 m_pSelectionCB
->SetToggleHdl( LINK( this, OfaViewTabPage
, OnSelectionToggled
) );
576 if( ! Application::ValidateSystemFont() )
578 m_pSystemFont
->Check(false);
579 m_pSystemFont
->Enable(false);
582 const StyleSettings
& aStyleSettings
= Application::GetSettings().GetStyleSettings();
584 // remove non-installed icon themes
585 if( m_pIconStyleLB
->GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX
)
587 // do not check 0th item == auto; it is not a real theme
588 aIconStyleItemId
[0] = 0;
590 for ( sal_uLong n
=0; ++n
< STYLE_SYMBOLS_THEMES_MAX
; )
592 if ( aStyleSettings
.CheckSymbolStyle( n
) )
594 // existing style => save the item id
595 aIconStyleItemId
[n
] = nItem
++;
599 // non-existing style => remove item;
600 m_pIconStyleLB
->RemoveEntry( nItem
);
601 aIconStyleItemId
[n
] = 0;
606 // add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
607 if( m_pIconStyleLB
->GetEntryCount() > 1 )
609 OUString
aAutoStr( m_pIconStyleLB
->GetEntry( 0 ) );
613 // prefer the icon style set by the desktop native widgets modules
614 sal_uLong nAutoStyle
= aStyleSettings
.GetPreferredSymbolsStyle();
615 // fallback to the statically defined values
616 if ( nAutoStyle
== STYLE_SYMBOLS_AUTO
|| !aIconStyleItemId
[nAutoStyle
] )
617 nAutoStyle
= aStyleSettings
.GetAutoSymbolsStyle();
618 if ( aIconStyleItemId
[nAutoStyle
] )
619 aAutoStr
+= m_pIconStyleLB
->GetEntry( aIconStyleItemId
[nAutoStyle
] );
621 m_pIconStyleLB
->RemoveEntry( 0 );
622 m_pIconStyleLB
->InsertEntry( aAutoStr
+= OUString(")" ), 0 );
623 // separate auto and other icon themes
624 m_pIconStyleLB
->SetSeparatorPos( 0 );
628 OfaViewTabPage::~OfaViewTabPage()
630 delete mpDrawinglayerOpt
;
631 delete pCanvasSettings
;
632 delete pAppearanceCfg
;
636 IMPL_LINK( OfaViewTabPage
, OnAntialiasingToggled
, void*, NOTINTERESTEDIN
)
638 (void)NOTINTERESTEDIN
;
640 sal_Bool bAAEnabled
= m_pFontAntiAliasing
->IsChecked();
642 m_pAAPointLimitLabel
->Enable( bAAEnabled
);
643 m_pAAPointLimit
->Enable( bAAEnabled
);
644 m_pAAPointLimitUnits
->Enable( bAAEnabled
);
651 IMPL_LINK( OfaViewTabPage
, OnSelectionToggled
, void*, NOTINTERESTEDIN
)
653 (void)NOTINTERESTEDIN
;
654 const bool bSelectionEnabled(m_pSelectionCB
->IsChecked());
655 m_pSelectionMF
->Enable(bSelectionEnabled
);
659 SfxTabPage
* OfaViewTabPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
661 return new OfaViewTabPage(pParent
, rAttrSet
);
664 sal_Bool
OfaViewTabPage::FillItemSet( SfxItemSet
& )
666 SvtFontOptions aFontOpt
;
667 SvtMenuOptions aMenuOpt
;
669 sal_Bool bModified
= sal_False
;
670 sal_Bool bMenuOptModified
= sal_False
;
671 bool bRepaintWindows(false);
673 SvtMiscOptions aMiscOptions
;
674 sal_uInt16 nSizeLB_NewSelection
= m_pIconSizeLB
->GetSelectEntryPos();
675 if( nSizeLB_InitialSelection
!= nSizeLB_NewSelection
)
677 // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
678 sal_Int16 eSet
= SFX_SYMBOLS_SIZE_AUTO
;
679 switch( nSizeLB_NewSelection
)
681 case 0: eSet
= SFX_SYMBOLS_SIZE_AUTO
; break;
682 case 1: eSet
= SFX_SYMBOLS_SIZE_SMALL
; break;
683 case 2: eSet
= SFX_SYMBOLS_SIZE_LARGE
; break;
685 OSL_FAIL( "OfaViewTabPage::FillItemSet(): This state of m_pIconSizeLB should not be possible!" );
687 aMiscOptions
.SetSymbolsSize( eSet
);
690 sal_uInt16 nStyleLB_NewSelection
= m_pIconStyleLB
->GetSelectEntryPos();
691 if( nStyleLB_InitialSelection
!= nStyleLB_NewSelection
)
693 // find the style name in the aIconStyleItemId table
694 // items from the non-installed icon themes were removed
695 for ( sal_uLong n
=0; n
< STYLE_SYMBOLS_THEMES_MAX
; n
++ )
697 if ( aIconStyleItemId
[n
] == nStyleLB_NewSelection
)
699 aMiscOptions
.SetSymbolsStyle( n
);
700 n
= STYLE_SYMBOLS_THEMES_MAX
;
705 sal_Bool bAppearanceChanged
= sal_False
;
709 sal_uInt16 nOldScale
= pAppearanceCfg
->GetScaleFactor();
710 sal_uInt16 nNewScale
= (sal_uInt16
)m_pWindowSizeMF
->GetValue();
712 if ( nNewScale
!= nOldScale
)
714 pAppearanceCfg
->SetScaleFactor(nNewScale
);
715 bAppearanceChanged
= sal_True
;
719 short eOldSnap
= pAppearanceCfg
->GetSnapMode();
720 short eNewSnap
= m_pMousePosLB
->GetSelectEntryPos();
724 if ( eNewSnap
!= eOldSnap
)
726 pAppearanceCfg
->SetSnapMode(eNewSnap
);
727 bAppearanceChanged
= sal_True
;
730 // Middle Mouse Button
731 short eOldMiddleMouse
= pAppearanceCfg
->GetMiddleMouseButton();
732 short eNewMiddleMouse
= m_pMouseMiddleLB
->GetSelectEntryPos();
733 if(eNewMiddleMouse
> 2)
736 if ( eNewMiddleMouse
!= eOldMiddleMouse
)
738 pAppearanceCfg
->SetMiddleMouseButton( eNewMiddleMouse
);
739 bAppearanceChanged
= sal_True
;
743 if ( m_pFontAntiAliasing
->IsChecked() != m_pFontAntiAliasing
->GetSavedValue() )
745 pAppearanceCfg
->SetFontAntiAliasing( m_pFontAntiAliasing
->IsChecked() );
746 bAppearanceChanged
= sal_True
;
749 if ( m_pAAPointLimit
->GetValue() != m_pAAPointLimit
->GetSavedValue().toInt32() )
751 pAppearanceCfg
->SetFontAntialiasingMinPixelHeight( m_pAAPointLimit
->GetValue() );
752 bAppearanceChanged
= sal_True
;
756 if ( m_pFontShowCB
->IsChecked() != m_pFontShowCB
->GetSavedValue() )
758 aFontOpt
.EnableFontWYSIWYG( m_pFontShowCB
->IsChecked() );
759 bModified
= sal_True
;
762 if(m_pMenuIconsLB
->GetSelectEntryPos() != m_pMenuIconsLB
->GetSavedValue())
764 aMenuOpt
.SetMenuIconsState( m_pMenuIconsLB
->GetSelectEntryPos() == 0 ? 2 : m_pMenuIconsLB
->GetSelectEntryPos() - 1);
765 bModified
= sal_True
;
766 bMenuOptModified
= sal_True
;
767 bAppearanceChanged
= sal_True
;
770 if ( m_pFontHistoryCB
->IsChecked() != m_pFontHistoryCB
->GetSavedValue() )
772 aFontOpt
.EnableFontHistory( m_pFontHistoryCB
->IsChecked() );
773 bModified
= sal_True
;
776 // #i95644# if disabled, do not use value, see in ::Reset()
777 if(m_pUseHardwareAccell
->IsEnabled())
779 if(m_pUseHardwareAccell
->IsChecked() != m_pUseHardwareAccell
->GetSavedValue())
781 pCanvasSettings
->EnabledHardwareAcceleration(m_pUseHardwareAccell
->IsChecked());
782 bModified
= sal_True
;
786 // #i95644# if disabled, do not use value, see in ::Reset()
787 if(m_pUseAntiAliase
->IsEnabled())
789 if(m_pUseAntiAliase
->IsChecked() != mpDrawinglayerOpt
->IsAntiAliasing())
791 mpDrawinglayerOpt
->SetAntiAliasing(m_pUseAntiAliase
->IsChecked());
792 bModified
= sal_True
;
793 bRepaintWindows
= true;
798 if(m_pSelectionCB
->IsEnabled())
800 const bool bNewSelection(m_pSelectionCB
->IsChecked());
801 const sal_uInt16
nNewTransparence((sal_uInt16
)m_pSelectionMF
->GetValue());
803 if(bNewSelection
!= (bool)mpDrawinglayerOpt
->IsTransparentSelection())
805 mpDrawinglayerOpt
->SetTransparentSelection(m_pSelectionCB
->IsChecked());
806 bModified
= sal_True
;
807 bRepaintWindows
= true;
810 // #i104150# even read the value when m_pSelectionMF is disabled; it may have been
811 // modified by enabling-modify-disabling by the user
812 if(nNewTransparence
!= mpDrawinglayerOpt
->GetTransparentSelectionPercent())
814 mpDrawinglayerOpt
->SetTransparentSelectionPercent(nNewTransparence
);
815 bModified
= sal_True
;
816 bRepaintWindows
= true;
820 SvtAccessibilityOptions aAccessibilityOptions
;
821 if( aAccessibilityOptions
.GetIsSystemFont() != m_pSystemFont
->IsChecked() &&
822 m_pSystemFont
->IsEnabled() )
824 aAccessibilityOptions
.SetIsSystemFont( m_pSystemFont
->IsChecked() );
825 bModified
= sal_True
;
826 bMenuOptModified
= sal_True
;
829 if( bMenuOptModified
)
831 // Set changed settings to the application instance
832 AllSettings aAllSettings
= Application::GetSettings();
833 StyleSettings aStyleSettings
= aAllSettings
.GetStyleSettings();
834 if( m_pSystemFont
->IsEnabled() )
835 aStyleSettings
.SetUseSystemUIFonts( m_pSystemFont
->IsChecked() );
836 aAllSettings
.SetStyleSettings(aStyleSettings
);
837 Application::MergeSystemSettings( aAllSettings
);
838 Application::SetSettings(aAllSettings
);
841 if ( bAppearanceChanged
)
843 pAppearanceCfg
->Commit();
844 pAppearanceCfg
->SetApplicationDefaults ( GetpApp() );
849 Window
* pAppWindow
= Application::GetFirstTopLevelWindow();
853 pAppWindow
->Invalidate();
854 pAppWindow
= Application::GetNextTopLevelWindow(pAppWindow
);
861 void OfaViewTabPage::Reset( const SfxItemSet
& )
863 SvtMiscOptions aMiscOptions
;
865 if( aMiscOptions
.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO
)
866 nSizeLB_InitialSelection
= ( aMiscOptions
.AreCurrentSymbolsLarge() )? 2 : 1;
867 m_pIconSizeLB
->SelectEntryPos( nSizeLB_InitialSelection
);
868 m_pIconSizeLB
->SaveValue();
870 if( aMiscOptions
.GetSymbolsStyle() != STYLE_SYMBOLS_AUTO
)
871 nStyleLB_InitialSelection
= aIconStyleItemId
[aMiscOptions
.GetCurrentSymbolsStyle()];
873 m_pIconStyleLB
->SelectEntryPos( nStyleLB_InitialSelection
);
874 m_pIconStyleLB
->SaveValue();
876 if( m_pSystemFont
->IsEnabled() )
878 SvtAccessibilityOptions aAccessibilityOptions
;
879 m_pSystemFont
->Check( aAccessibilityOptions
.GetIsSystemFont() );
883 m_pWindowSizeMF
->SetValue ( pAppearanceCfg
->GetScaleFactor() );
885 m_pMousePosLB
->SelectEntryPos(pAppearanceCfg
->GetSnapMode());
886 m_pMousePosLB
->SaveValue();
889 m_pMouseMiddleLB
->SelectEntryPos(pAppearanceCfg
->GetMiddleMouseButton());
890 m_pMouseMiddleLB
->SaveValue();
893 m_pFontAntiAliasing
->Check( pAppearanceCfg
->IsFontAntiAliasing() );
894 m_pAAPointLimit
->SetValue( pAppearanceCfg
->GetFontAntialiasingMinPixelHeight() );
898 SvtFontOptions aFontOpt
;
899 m_pFontShowCB
->Check( aFontOpt
.IsFontWYSIWYGEnabled() );
900 SvtMenuOptions aMenuOpt
;
901 m_pMenuIconsLB
->SelectEntryPos(aMenuOpt
.GetMenuIconsState() == 2 ? 0 : aMenuOpt
.GetMenuIconsState() + 1);
902 m_pMenuIconsLB
->SaveValue();
903 m_pFontHistoryCB
->Check( aFontOpt
.IsFontHistoryEnabled() );
905 { // #i95644# HW accel (unified to disable mechanism)
906 if(pCanvasSettings
->IsHardwareAccelerationAvailable())
908 m_pUseHardwareAccell
->Check(pCanvasSettings
->IsHardwareAccelerationEnabled());
912 m_pUseHardwareAccell
->Check(false);
913 m_pUseHardwareAccell
->Disable();
916 m_pUseHardwareAccell
->SaveValue();
919 { // #i95644# AntiAliasing
920 if(mpDrawinglayerOpt
->IsAAPossibleOnThisSystem())
922 m_pUseAntiAliase
->Check(mpDrawinglayerOpt
->IsAntiAliasing());
926 m_pUseAntiAliase
->Check(false);
927 m_pUseAntiAliase
->Disable();
930 m_pUseAntiAliase
->SaveValue();
934 // #i97672# Selection
935 // check if transparent selection is possible on this system
936 const bool bTransparentSelectionPossible(
937 !GetSettings().GetStyleSettings().GetHighContrastMode()
938 && supportsOperation(OutDevSupport_TransparentRect
));
941 if(bTransparentSelectionPossible
)
943 m_pSelectionCB
->Check(mpDrawinglayerOpt
->IsTransparentSelection());
947 m_pSelectionCB
->Enable(false);
950 m_pSelectionMF
->SetValue(mpDrawinglayerOpt
->GetTransparentSelectionPercent());
951 m_pSelectionMF
->Enable(mpDrawinglayerOpt
->IsTransparentSelection() && bTransparentSelectionPossible
);
955 m_pFontAntiAliasing
->SaveValue();
956 m_pAAPointLimit
->SaveValue();
958 m_pFontShowCB
->SaveValue();
959 m_pFontHistoryCB
->SaveValue();
962 LINK( this, OfaViewTabPage
, OnAntialiasingToggled
).Call( NULL
);
966 struct LanguageConfig_Impl
968 SvtLanguageOptions aLanguageOptions
;
969 SvtSysLocaleOptions aSysLocaleOptions
;
970 SvtLinguConfig aLinguConfig
;
973 static sal_Bool bLanguageCurrentDoc_Impl
= sal_False
;
975 // some things we'll need...
976 static const OUString
sAccessSrvc("com.sun.star.configuration.ConfigurationAccess");
977 static const OUString
sAccessUpdSrvc("com.sun.star.configuration.ConfigurationUpdateAccess");
978 static const OUString
sInstalledLocalesPath("org.openoffice.Setup/Office/InstalledLocales");
979 static OUString
sUserLocalePath("org.openoffice.Office.Linguistic/General");
980 //static const OUString sUserLocalePath("org.openoffice.Office/Linguistic");
981 static const OUString
sUserLocaleKey("UILocale");
982 static Sequence
< OUString
> seqInstalledLanguages
;
984 static OUString
lcl_getDatePatternsConfigString( const LocaleDataWrapper
& rLocaleWrapper
)
986 Sequence
< OUString
> aDateAcceptancePatterns
= rLocaleWrapper
.getDateAcceptancePatterns();
987 sal_Int32 nPatterns
= aDateAcceptancePatterns
.getLength();
988 OUStringBuffer
aBuf( nPatterns
* 6 ); // 6 := length of Y-M-D;
989 SAL_WARN_IF( !nPatterns
, "cui.options", "No date acceptance pattern");
992 const OUString
* pPatterns
= aDateAcceptancePatterns
.getConstArray();
993 aBuf
.append( pPatterns
[0]);
994 for (sal_Int32 i
=1; i
< nPatterns
; ++i
)
995 aBuf
.append(';').append( pPatterns
[i
]);
997 return aBuf
.makeStringAndClear();
1000 OfaLanguagesTabPage::OfaLanguagesTabPage( Window
* pParent
, const SfxItemSet
& rSet
) :
1001 SfxTabPage( pParent
, CUI_RES( OFA_TP_LANGUAGES
), rSet
),
1002 aUILanguageGB(this, CUI_RES(FL_UI_LANG
)),
1003 aLocaleSettingFI(this, CUI_RES(FI_LOCALESETTING
)),
1004 aUserInterfaceFT(this, CUI_RES(FT_USERINTERFACE
)),
1005 aUserInterfaceLB(this, CUI_RES(LB_USERINTERFACE
)),
1006 aLocaleSettingFT(this, CUI_RES(FT_LOCALESETTING
)),
1007 aLocaleSettingLB(this, CUI_RES(LB_LOCALESETTING
)),
1008 aCurrencyFI( this, CUI_RES(FI_CURRENCY
)),
1009 aDecimalSeparatorFT(this, CUI_RES(FT_DECIMALSEPARATOR
)),
1010 aDecimalSeparatorCB(this, CUI_RES(CB_DECIMALSEPARATOR
)),
1011 aCurrencyFT( this, CUI_RES(FT_CURRENCY
)),
1012 aCurrencyLB( this, CUI_RES(LB_CURRENCY
)),
1013 aDatePatternsFI( this, CUI_RES(FI_DATEPATTERNS
)),
1014 aDatePatternsFT( this, CUI_RES(FT_DATEPATTERNS
)),
1015 aDatePatternsED( this, CUI_RES(ED_DATEPATTERNS
)),
1016 aLinguLanguageGB(this, CUI_RES(FL_LINGU_LANG
)),
1017 aWesternLanguageFI(this, CUI_RES(FI_WEST_LANG
)),
1018 aWesternLanguageFT(this, CUI_RES(FT_WEST_LANG
)),
1019 aWesternLanguageLB(this, CUI_RES(LB_WEST_LANG
)),
1020 aAsianLanguageFI(this, CUI_RES(FI_ASIAN_LANG
)),
1021 aAsianLanguageFT(this, CUI_RES(FT_ASIAN_LANG
)),
1022 aAsianLanguageLB(this, CUI_RES(LB_ASIAN_LANG
)),
1023 aComplexLanguageFI(this, CUI_RES(FI_COMPLEX_LANG
)),
1024 aComplexLanguageFT(this, CUI_RES(FT_COMPLEX_LANG
)),
1025 aComplexLanguageLB(this, CUI_RES(LB_COMPLEX_LANG
)),
1026 aCurrentDocCB(this, CUI_RES(CB_CURRENT_DOC
)),
1027 aEnhancedFL(this, CUI_RES(FL_ENHANCED
)),
1028 aAsianSupportFI(this, CUI_RES(FI_ASIANSUPPORT
)),
1029 aAsianSupportCB(this, CUI_RES(CB_ASIANSUPPORT
)),
1030 aCTLSupportFI(this, CUI_RES(FI_CTLSUPPORT
)),
1031 aCTLSupportCB(this, CUI_RES(CB_CTLSUPPORT
)),
1032 aIgnoreLanguageChangeCB(this, CUI_RES(CB_IGNORE_LANG_CHANGE
)),
1033 sDecimalSeparatorLabel(aDecimalSeparatorCB
.GetText()),
1034 pLangConfig(new LanguageConfig_Impl
)
1038 // initialize user interface language selection
1039 SvtLanguageTable
* pLanguageTable
= new SvtLanguageTable
;
1040 const OUString
aStr( pLanguageTable
->GetString( LANGUAGE_SYSTEM
) );
1042 OUString aUILang
= aStr
+
1044 pLanguageTable
->GetString( Application::GetSettings().GetUILanguageTag().getLanguageType(), true );
1046 aUserInterfaceLB
.InsertEntry(aUILang
);
1047 aUserInterfaceLB
.SetEntryData(0, 0);
1048 aUserInterfaceLB
.SelectEntryPos(0);
1051 Reference
< XMultiServiceFactory
> theConfigProvider(
1052 com::sun::star::configuration::theDefaultProvider::get(
1053 comphelper::getProcessComponentContext()));
1054 Sequence
< Any
> theArgs(1);
1055 Reference
< XNameAccess
> theNameAccess
;
1057 // find out which locales are currently installed and add them to the listbox
1058 theArgs
[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(sInstalledLocalesPath
)));
1059 theNameAccess
= Reference
< XNameAccess
> (
1060 theConfigProvider
->createInstanceWithArguments(sAccessSrvc
, theArgs
), UNO_QUERY_THROW
);
1061 seqInstalledLanguages
= theNameAccess
->getElementNames();
1062 LanguageType aLang
= LANGUAGE_DONTKNOW
;
1063 for (sal_IntPtr i
=0; i
<seqInstalledLanguages
.getLength(); i
++)
1065 aLang
= LanguageTag(seqInstalledLanguages
[i
]).getLanguageType();
1066 if (aLang
!= LANGUAGE_DONTKNOW
)
1068 //sal_uInt16 p = aUserInterfaceLB.InsertLanguage(aLang);
1069 OUString
aLangStr( pLanguageTable
->GetString( aLang
, true ) );
1070 sal_uInt16 p
= aUserInterfaceLB
.InsertEntry(aLangStr
);
1071 aUserInterfaceLB
.SetEntryData(p
, (void*)(i
+1));
1075 // find out whether the user has a specific locale specified
1076 Sequence
< Any
> theArgs2(1);
1077 theArgs2
[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(sUserLocalePath
)));
1078 theNameAccess
= Reference
< XNameAccess
> (
1079 theConfigProvider
->createInstanceWithArguments(sAccessSrvc
, theArgs2
), UNO_QUERY_THROW
);
1080 if (theNameAccess
->hasByName(sUserLocaleKey
))
1081 theNameAccess
->getByName(sUserLocaleKey
) >>= m_sUserLocaleValue
;
1082 // select the user specified locale in the listbox
1083 if (!m_sUserLocaleValue
.isEmpty())
1086 for (sal_uInt16 i
=0; i
< aUserInterfaceLB
.GetEntryCount(); i
++)
1088 d
= (sal_Int32
)(sal_IntPtr
)aUserInterfaceLB
.GetEntryData(i
);
1089 if ( d
> 0 && seqInstalledLanguages
.getLength() > d
-1 && seqInstalledLanguages
[d
-1].equals(m_sUserLocaleValue
))
1090 aUserInterfaceLB
.SelectEntryPos(i
);
1095 catch (const Exception
&e
)
1097 // we'll just leave the box in it's default setting and won't
1098 // even give it event handler...
1099 OString aMsg
= OUStringToOString(e
.Message
, RTL_TEXTENCODING_ASCII_US
);
1100 OSL_FAIL(aMsg
.getStr());
1103 aWesternLanguageLB
.SetLanguageList( LANG_LIST_WESTERN
| LANG_LIST_ONLY_KNOWN
, sal_True
, sal_False
, sal_True
);
1104 aWesternLanguageLB
.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN
);
1105 aAsianLanguageLB
.SetLanguageList( LANG_LIST_CJK
| LANG_LIST_ONLY_KNOWN
, sal_True
, sal_False
, sal_True
);
1106 aAsianLanguageLB
.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN
);
1107 aComplexLanguageLB
.SetLanguageList( LANG_LIST_CTL
| LANG_LIST_ONLY_KNOWN
, sal_True
, sal_False
, sal_True
);
1108 aComplexLanguageLB
.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX
);
1110 aLocaleSettingLB
.SetLanguageList( LANG_LIST_ALL
| LANG_LIST_ONLY_KNOWN
, sal_False
, sal_False
, sal_False
);
1111 aLocaleSettingLB
.InsertSystemLanguage( );
1113 const NfCurrencyTable
& rCurrTab
= SvNumberFormatter::GetTheCurrencyTable();
1114 const NfCurrencyEntry
& rCurr
= SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM
);
1115 // insert SYSTEM entry
1116 OUString aDefaultCurr
= aStr
+ " - " + rCurr
.GetBankSymbol();
1117 aCurrencyLB
.InsertEntry( aDefaultCurr
);
1119 OUString
aTwoSpace( " " );
1120 sal_uInt16 nCurrCount
= rCurrTab
.size();
1121 // first entry is SYSTEM, skip it
1122 for ( sal_uInt16 j
=1; j
< nCurrCount
; ++j
)
1124 const NfCurrencyEntry
* pCurr
= &rCurrTab
[j
];
1125 OUString aStr_
= pCurr
->GetBankSymbol() +
1128 aStr_
= ApplyLreOrRleEmbedding( aStr_
) +
1130 ApplyLreOrRleEmbedding( pLanguageTable
->GetString( pCurr
->GetLanguage() ) );
1131 sal_uInt16 nPos
= aCurrencyLB
.InsertEntry( aStr_
);
1132 aCurrencyLB
.SetEntryData( nPos
, (void*) pCurr
);
1134 delete pLanguageTable
;
1136 aLocaleSettingLB
.SetSelectHdl( LINK( this, OfaLanguagesTabPage
, LocaleSettingHdl
) );
1137 aDatePatternsED
.SetModifyHdl( LINK( this, OfaLanguagesTabPage
, DatePatternsHdl
) );
1139 Link
aLink( LINK( this, OfaLanguagesTabPage
, SupportHdl
) );
1140 aAsianSupportCB
.SetClickHdl( aLink
);
1141 aCTLSupportCB
.SetClickHdl( aLink
);
1143 aAsianSupportCB
.Check( m_bOldAsian
= pLangConfig
->aLanguageOptions
.IsAnyEnabled() );
1144 aAsianSupportCB
.SaveValue();
1145 sal_Bool bReadonly
= pLangConfig
->aLanguageOptions
.IsReadOnly(SvtLanguageOptions::E_ALLCJK
);
1146 aAsianSupportCB
.Enable(!bReadonly
);
1147 aAsianSupportFI
.Show(bReadonly
);
1148 SupportHdl( &aAsianSupportCB
);
1150 aCTLSupportCB
.Check( m_bOldCtl
= pLangConfig
->aLanguageOptions
.IsCTLFontEnabled() );
1151 aCTLSupportCB
.SaveValue();
1152 bReadonly
= pLangConfig
->aLanguageOptions
.IsReadOnly(SvtLanguageOptions::E_CTLFONT
);
1153 aCTLSupportCB
.Enable(!bReadonly
);
1154 aCTLSupportFI
.Show(bReadonly
);
1155 SupportHdl( &aCTLSupportCB
);
1157 aIgnoreLanguageChangeCB
.Check( pLangConfig
->aSysLocaleOptions
.IsIgnoreLanguageChange() );
1160 OfaLanguagesTabPage::~OfaLanguagesTabPage()
1165 SfxTabPage
* OfaLanguagesTabPage::Create( Window
* pParent
, const SfxItemSet
& rAttrSet
)
1167 return new OfaLanguagesTabPage(pParent
, rAttrSet
);
1170 static LanguageType
lcl_LangStringToLangType(const OUString
& rLang
)
1173 sal_Int32 nSep
= rLang
.indexOf('-');
1175 aLocale
.Language
= rLang
;
1178 aLocale
.Language
= rLang
.copy(0, nSep
);
1179 if (nSep
< rLang
.getLength())
1180 aLocale
.Country
= rLang
.copy(nSep
+1, rLang
.getLength() - (nSep
+1));
1182 LanguageType eLangType
= LanguageTag( aLocale
).getLanguageType();
1186 static void lcl_UpdateAndDelete(SfxVoidItem
* pInvalidItems
[], SfxBoolItem
* pBoolItems
[], sal_uInt16 nCount
)
1188 SfxViewFrame
* pCurrentFrm
= SfxViewFrame::Current();
1189 SfxViewFrame
* pViewFrm
= SfxViewFrame::GetFirst();
1192 SfxBindings
& rBind
= pViewFrm
->GetBindings();
1193 for(sal_Int16 i
= 0; i
< nCount
; i
++)
1195 if(pCurrentFrm
== pViewFrm
)
1196 rBind
.InvalidateAll(sal_False
);
1197 rBind
.SetState( *pInvalidItems
[i
] );
1198 rBind
.SetState( *pBoolItems
[i
] );
1200 pViewFrm
= SfxViewFrame::GetNext(*pViewFrm
);
1202 for(sal_Int16 i
= 0; i
< nCount
; i
++)
1204 delete pInvalidItems
[i
];
1205 delete pBoolItems
[i
] ;
1209 sal_Bool
OfaLanguagesTabPage::FillItemSet( SfxItemSet
& rSet
)
1211 // lock configuration broadcasters so that we can coordinate the notifications
1212 pLangConfig
->aSysLocaleOptions
.BlockBroadcasts( sal_True
);
1213 pLangConfig
->aLanguageOptions
.BlockBroadcasts( sal_True
);
1214 pLangConfig
->aLinguConfig
.BlockBroadcasts( sal_True
);
1217 * Sequence checking only matters when CTL support is enabled.
1219 * So we only need to check for sequence checking if
1220 * a) previously it was unchecked and is now checked or
1221 * b) it was already checked but the CTL language has changed
1224 aCTLSupportCB
.IsChecked() &&
1225 (aCTLSupportCB
.GetSavedValue() != STATE_CHECK
||
1226 aComplexLanguageLB
.GetSavedValue() != aComplexLanguageLB
.GetSelectEntryPos())
1229 //sequence checking has to be switched on depending on the selected CTL language
1230 LanguageType eCTLLang
= aComplexLanguageLB
.GetSelectLanguage();
1231 sal_Bool bOn
= MsLangId::needsSequenceChecking( eCTLLang
);
1232 pLangConfig
->aLanguageOptions
.SetCTLSequenceCheckingRestricted(bOn
);
1233 pLangConfig
->aLanguageOptions
.SetCTLSequenceChecking(bOn
);
1234 pLangConfig
->aLanguageOptions
.SetCTLSequenceCheckingTypeAndReplace(bOn
);
1238 // handle settings for UI Language
1239 // a change of setting needs to bring up a warning message
1240 OUString aLangString
;
1241 sal_Int32 d
= (sal_Int32
)(sal_IntPtr
)aUserInterfaceLB
.GetEntryData(aUserInterfaceLB
.GetSelectEntryPos());
1242 if( d
> 0 && seqInstalledLanguages
.getLength() > d
-1)
1243 aLangString
= seqInstalledLanguages
[d
-1];
1246 if( aUserInterfaceLB.GetSelectEntryPos() > 0)
1247 aLangString = ConvertLanguageToIsoString(aUserInterfaceLB.GetSelectLanguage());
1249 Reference
< XMultiServiceFactory
> theConfigProvider(
1250 com::sun::star::configuration::theDefaultProvider::get(
1251 comphelper::getProcessComponentContext()));
1252 Sequence
< Any
> theArgs(1);
1253 theArgs
[0] = makeAny(NamedValue(OUString("nodepath"), makeAny(sUserLocalePath
)));
1254 Reference
< XPropertySet
>xProp(
1255 theConfigProvider
->createInstanceWithArguments(sAccessUpdSrvc
, theArgs
), UNO_QUERY_THROW
);
1256 if ( !m_sUserLocaleValue
.equals(aLangString
))
1258 // OSL_FAIL("UserInterface language was changed, restart.");
1260 xProp
->setPropertyValue(sUserLocaleKey
, makeAny(aLangString
));
1261 Reference
< XChangesBatch
>(xProp
, UNO_QUERY_THROW
)->commitChanges();
1263 InfoBox
aBox(this, CUI_RES(RID_SVX_MSGBOX_LANGUAGE_RESTART
));
1266 // tell quickstarter to stop being a veto listener
1268 Reference
< XMultiServiceFactory
> theMSF(
1269 comphelper::getProcessServiceFactory());
1270 Reference
< XInitialization
> xInit(theMSF
->createInstance(
1271 OUString("com.sun.star.office.Quickstart")), UNO_QUERY
);
1274 Sequence
< Any
> args(3);
1275 args
[0] = makeAny(sal_False
); // will be ignored
1276 args
[1] = makeAny(sal_False
); // will be ignored
1277 args
[2] = makeAny(sal_False
); // disable veto
1278 xInit
->initialize(args
);
1282 catch (const Exception
& e
)
1284 // we'll just leave the box in it's default setting and won't
1285 // even give it event handler...
1286 OString aMsg
= OUStringToOString(e
.Message
, RTL_TEXTENCODING_ASCII_US
);
1287 OSL_FAIL(aMsg
.getStr());
1290 OUString sLang
= pLangConfig
->aSysLocaleOptions
.GetLocaleConfigString();
1291 LanguageType eOldLocale
= (!sLang
.isEmpty() ?
1292 lcl_LangStringToLangType( sLang
) : LANGUAGE_SYSTEM
);
1293 LanguageType eNewLocale
= aLocaleSettingLB
.GetSelectLanguage();
1294 if ( eOldLocale
!= eNewLocale
)
1296 // an empty string denotes SYSTEM locale
1298 if ( eNewLocale
!= LANGUAGE_SYSTEM
)
1299 sNewLang
= LanguageTag( eNewLocale
).getBcp47();
1301 // locale nowadays get to AppSettings via notification
1302 // this will happen after releasing the lock on the ConfigurationBroadcaster at
1303 // the end of this method
1304 pLangConfig
->aSysLocaleOptions
.SetLocaleConfigString( sNewLang
);
1305 rSet
.Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED
, sal_True
) );
1307 sal_uInt16 nNewType
= SvtLanguageOptions::GetScriptTypeOfLanguage( eNewLocale
);
1308 bool bNewCJK
= ( nNewType
& SCRIPTTYPE_ASIAN
) != 0;
1309 SvtCompatibilityOptions aCompatOpts
;
1310 aCompatOpts
.SetDefault( COMPATIBILITY_PROPERTYNAME_EXPANDWORDSPACE
, !bNewCJK
);
1313 if(aDecimalSeparatorCB
.GetSavedValue() != aDecimalSeparatorCB
.IsChecked())
1314 pLangConfig
->aSysLocaleOptions
.SetDecimalSeparatorAsLocale(aDecimalSeparatorCB
.IsChecked());
1316 if(aIgnoreLanguageChangeCB
.GetSavedValue() != aIgnoreLanguageChangeCB
.IsChecked())
1317 pLangConfig
->aSysLocaleOptions
.SetIgnoreLanguageChange(aIgnoreLanguageChangeCB
.IsChecked());
1319 // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
1320 OUString sOldCurr
= pLangConfig
->aSysLocaleOptions
.GetCurrencyConfigString();
1321 sal_uInt16 nCurrPos
= aCurrencyLB
.GetSelectEntryPos();
1322 const NfCurrencyEntry
* pCurr
= (const NfCurrencyEntry
*)
1323 aCurrencyLB
.GetEntryData( nCurrPos
);
1326 sNewCurr
= SvtSysLocaleOptions::CreateCurrencyConfigString(
1327 pCurr
->GetBankSymbol(), pCurr
->GetLanguage() );
1328 if ( sOldCurr
!= sNewCurr
)
1329 pLangConfig
->aSysLocaleOptions
.SetCurrencyConfigString( sNewCurr
);
1331 // Configured date acceptance patterns, for example Y-M-D;M-D or empty for
1333 if (aDatePatternsED
.GetText() != aDatePatternsED
.GetSavedValue())
1334 pLangConfig
->aSysLocaleOptions
.SetDatePatternsConfigString( aDatePatternsED
.GetText());
1336 SfxObjectShell
* pCurrentDocShell
= SfxObjectShell::Current();
1337 Reference
< css::linguistic2::XLinguProperties
> xLinguProp
= LinguMgr::GetLinguPropertySet();
1338 sal_Bool bCurrentDocCBChecked
= aCurrentDocCB
.IsChecked();
1339 if(aCurrentDocCB
.IsEnabled())
1340 bLanguageCurrentDoc_Impl
= bCurrentDocCBChecked
;
1341 sal_Bool bCurrentDocCBChanged
= bCurrentDocCBChecked
!= aCurrentDocCB
.GetSavedValue();
1343 sal_Bool bValChanged
= aWesternLanguageLB
.GetSavedValue() != aWesternLanguageLB
.GetSelectEntryPos();
1344 if( (bCurrentDocCBChanged
&& !bCurrentDocCBChecked
) || bValChanged
)
1346 LanguageType eSelectLang
= aWesternLanguageLB
.GetSelectLanguage();
1347 if(!bCurrentDocCBChecked
)
1350 Locale aLocale
= LanguageTag( eSelectLang
).getLocale( false );
1352 OUString
aPropName( "DefaultLocale" );
1353 pLangConfig
->aLinguConfig
.SetProperty( aPropName
, aValue
);
1354 if (xLinguProp
.is())
1355 xLinguProp
->setDefaultLocale( aLocale
);
1357 if(pCurrentDocShell
)
1359 rSet
.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang
, ::com::sun::star::i18n::ScriptType::LATIN
),
1360 SID_ATTR_LANGUAGE
));
1363 bValChanged
= aAsianLanguageLB
.GetSavedValue() != aAsianLanguageLB
.GetSelectEntryPos();
1364 if( (bCurrentDocCBChanged
&& !bCurrentDocCBChecked
) || bValChanged
)
1366 LanguageType eSelectLang
= aAsianLanguageLB
.GetSelectLanguage();
1367 if(!bCurrentDocCBChecked
)
1370 Locale aLocale
= LanguageTag( eSelectLang
).getLocale( false );
1372 OUString
aPropName( "DefaultLocale_CJK" );
1373 pLangConfig
->aLinguConfig
.SetProperty( aPropName
, aValue
);
1374 if (xLinguProp
.is())
1375 xLinguProp
->setDefaultLocale_CJK( aLocale
);
1377 if(pCurrentDocShell
)
1379 rSet
.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang
, ::com::sun::star::i18n::ScriptType::ASIAN
),
1380 SID_ATTR_CHAR_CJK_LANGUAGE
));
1383 bValChanged
= aComplexLanguageLB
.GetSavedValue() != aComplexLanguageLB
.GetSelectEntryPos();
1384 if( (bCurrentDocCBChanged
&& !bCurrentDocCBChecked
) || bValChanged
)
1386 LanguageType eSelectLang
= aComplexLanguageLB
.GetSelectLanguage();
1387 if(!bCurrentDocCBChecked
)
1390 Locale aLocale
= LanguageTag( eSelectLang
).getLocale( false );
1392 OUString
aPropName( "DefaultLocale_CTL" );
1393 pLangConfig
->aLinguConfig
.SetProperty( aPropName
, aValue
);
1394 if (xLinguProp
.is())
1395 xLinguProp
->setDefaultLocale_CTL( aLocale
);
1397 if(pCurrentDocShell
)
1399 rSet
.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang
, ::com::sun::star::i18n::ScriptType::COMPLEX
),
1400 SID_ATTR_CHAR_CTL_LANGUAGE
));
1404 if(aAsianSupportCB
.GetSavedValue() != aAsianSupportCB
.IsChecked() )
1406 sal_Bool bChecked
= aAsianSupportCB
.IsChecked();
1407 pLangConfig
->aLanguageOptions
.SetAll(bChecked
);
1409 //iterate over all bindings to invalidate vertical text direction
1410 const sal_uInt16 STATE_COUNT
= 2;
1412 SfxBoolItem
* pBoolItems
[STATE_COUNT
];
1413 pBoolItems
[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE
, sal_False
);
1414 pBoolItems
[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL
, sal_False
);
1416 SfxVoidItem
* pInvalidItems
[STATE_COUNT
];
1417 pInvalidItems
[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE
);
1418 pInvalidItems
[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL
);
1420 lcl_UpdateAndDelete(pInvalidItems
, pBoolItems
, STATE_COUNT
);
1423 if ( aCTLSupportCB
.GetSavedValue() != aCTLSupportCB
.IsChecked() )
1425 pLangConfig
->aLanguageOptions
.SetCTLFontEnabled( aCTLSupportCB
.IsChecked() );
1427 const sal_uInt16 STATE_COUNT
= 1;
1428 SfxBoolItem
* pBoolItems
[STATE_COUNT
];
1429 pBoolItems
[0] = new SfxBoolItem(SID_CTLFONT_STATE
, sal_False
);
1430 SfxVoidItem
* pInvalidItems
[STATE_COUNT
];
1431 pInvalidItems
[0] = new SfxVoidItem(SID_CTLFONT_STATE
);
1432 lcl_UpdateAndDelete(pInvalidItems
, pBoolItems
, STATE_COUNT
);
1435 if ( pLangConfig
->aSysLocaleOptions
.IsModified() )
1436 pLangConfig
->aSysLocaleOptions
.Commit();
1438 // first release the lock on the ConfigurationBroadcaster for Locale changes
1439 // it seems that our code relies on the fact that before other changes like e.g. currency
1440 // are broadcasted locale changes have been done
1441 pLangConfig
->aSysLocaleOptions
.BlockBroadcasts( sal_False
);
1442 pLangConfig
->aLanguageOptions
.BlockBroadcasts( sal_False
);
1443 pLangConfig
->aLinguConfig
.BlockBroadcasts( sal_False
);
1447 //-----------------------------------------------------------------------------
1448 void OfaLanguagesTabPage::Reset( const SfxItemSet
& rSet
)
1450 OUString sLang
= pLangConfig
->aSysLocaleOptions
.GetLocaleConfigString();
1451 if ( !sLang
.isEmpty() )
1452 aLocaleSettingLB
.SelectLanguage(lcl_LangStringToLangType(sLang
));
1454 aLocaleSettingLB
.SelectLanguage( LANGUAGE_USER_SYSTEM_CONFIG
);
1455 sal_Bool bReadonly
= pLangConfig
->aSysLocaleOptions
.IsReadOnly(SvtSysLocaleOptions::E_LOCALE
);
1456 aLocaleSettingLB
.Enable(!bReadonly
);
1457 aLocaleSettingFT
.Enable(!bReadonly
);
1458 aLocaleSettingFI
.Show(bReadonly
);
1461 aDecimalSeparatorCB
.Check( pLangConfig
->aSysLocaleOptions
.IsDecimalSeparatorAsLocale());
1462 aDecimalSeparatorCB
.SaveValue();
1464 aIgnoreLanguageChangeCB
.Check( pLangConfig
->aSysLocaleOptions
.IsIgnoreLanguageChange());
1465 aIgnoreLanguageChangeCB
.SaveValue();
1467 // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
1468 // #i15812# must be done *before* the configured currency is set
1469 // and update the decimal separator used for the given locale
1470 LocaleSettingHdl(&aLocaleSettingLB
);
1472 // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
1475 const NfCurrencyEntry
* pCurr
= NULL
;
1476 sLang
= pLangConfig
->aSysLocaleOptions
.GetCurrencyConfigString();
1477 if ( !sLang
.isEmpty() )
1479 SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev
, eLang
, sLang
);
1480 pCurr
= SvNumberFormatter::GetCurrencyEntry( aAbbrev
, eLang
);
1482 // if pCurr==NULL the SYSTEM entry is selected
1483 sal_uInt16 nPos
= aCurrencyLB
.GetEntryPos( (void*) pCurr
);
1484 aCurrencyLB
.SelectEntryPos( nPos
);
1485 bReadonly
= pLangConfig
->aSysLocaleOptions
.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY
);
1486 aCurrencyLB
.Enable(!bReadonly
);
1487 aCurrencyFT
.Enable(!bReadonly
);
1488 aCurrencyFI
.Show(bReadonly
);
1490 // date acceptance patterns
1491 OUString aDatePatternsString
= pLangConfig
->aSysLocaleOptions
.GetDatePatternsConfigString();
1492 if (aDatePatternsString
.isEmpty())
1494 const LocaleDataWrapper
& rLocaleWrapper( Application::GetSettings().GetLocaleDataWrapper() );
1495 aDatePatternsString
= lcl_getDatePatternsConfigString( rLocaleWrapper
);
1497 aDatePatternsED
.SetText( aDatePatternsString
);
1498 bReadonly
= pLangConfig
->aSysLocaleOptions
.IsReadOnly(SvtSysLocaleOptions::E_DATEPATTERNS
);
1499 aDatePatternsED
.Enable(!bReadonly
);
1500 aDatePatternsFT
.Enable(!bReadonly
);
1501 aDatePatternsFI
.Show(bReadonly
);
1502 aDatePatternsED
.SaveValue();
1504 //western/CJK/CLK language
1505 LanguageType eCurLang
= LANGUAGE_NONE
;
1506 LanguageType eCurLangCJK
= LANGUAGE_NONE
;
1507 LanguageType eCurLangCTL
= LANGUAGE_NONE
;
1508 SfxObjectShell
* pCurrentDocShell
= SfxObjectShell::Current();
1509 //collect the configuration values first
1510 aCurrentDocCB
.Enable(sal_False
);
1517 aWestLang
= pLangConfig
->aLinguConfig
.GetProperty("DefaultLocale");
1519 aWestLang
>>= aLocale
;
1521 eCurLang
= LanguageTag( aLocale
).getLanguageType( false);
1523 aCJKLang
= pLangConfig
->aLinguConfig
.GetProperty("DefaultLocale_CJK");
1525 aCJKLang
>>= aLocale
;
1526 eCurLangCJK
= LanguageTag( aLocale
).getLanguageType( false);
1528 aCTLLang
= pLangConfig
->aLinguConfig
.GetProperty("DefaultLocale_CTL");
1530 aCTLLang
>>= aLocale
;
1531 eCurLangCTL
= LanguageTag( aLocale
).getLanguageType( false);
1533 catch (const Exception
&)
1536 //overwrite them by the values provided by the DocShell
1537 if(pCurrentDocShell
)
1539 aCurrentDocCB
.Enable(sal_True
);
1540 aCurrentDocCB
.Check(bLanguageCurrentDoc_Impl
);
1541 const SfxPoolItem
* pLang
;
1542 if( SFX_ITEM_SET
== rSet
.GetItemState(SID_ATTR_LANGUAGE
, sal_False
, &pLang
))
1544 LanguageType eTempCurLang
= ((const SvxLanguageItem
*)pLang
)->GetValue();
1545 if (MsLangId::resolveSystemLanguageByScriptType(eCurLang
, ::com::sun::star::i18n::ScriptType::LATIN
) != eTempCurLang
)
1546 eCurLang
= eTempCurLang
;
1549 if( SFX_ITEM_SET
== rSet
.GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE
, sal_False
, &pLang
))
1551 LanguageType eTempCurLang
= ((const SvxLanguageItem
*)pLang
)->GetValue();
1552 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK
, ::com::sun::star::i18n::ScriptType::ASIAN
) != eTempCurLang
)
1553 eCurLangCJK
= eTempCurLang
;
1556 if( SFX_ITEM_SET
== rSet
.GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE
, sal_False
, &pLang
))
1558 LanguageType eTempCurLang
= ((const SvxLanguageItem
*)pLang
)->GetValue();
1559 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL
, ::com::sun::star::i18n::ScriptType::COMPLEX
) != eTempCurLang
)
1560 eCurLangCTL
= eTempCurLang
;
1563 if(LANGUAGE_NONE
== eCurLang
|| LANGUAGE_DONTKNOW
== eCurLang
)
1564 aWesternLanguageLB
.SelectLanguage(LANGUAGE_NONE
);
1566 aWesternLanguageLB
.SelectLanguage(eCurLang
);
1568 if(LANGUAGE_NONE
== eCurLangCJK
|| LANGUAGE_DONTKNOW
== eCurLangCJK
)
1569 aAsianLanguageLB
.SelectLanguage(LANGUAGE_NONE
);
1571 aAsianLanguageLB
.SelectLanguage(eCurLangCJK
);
1573 if(LANGUAGE_NONE
== eCurLangCTL
|| LANGUAGE_DONTKNOW
== eCurLangCTL
)
1574 aComplexLanguageLB
.SelectLanguage(LANGUAGE_NONE
);
1576 aComplexLanguageLB
.SelectLanguage(eCurLangCTL
);
1578 aWesternLanguageLB
.SaveValue();
1579 aAsianLanguageLB
.SaveValue();
1580 aComplexLanguageLB
.SaveValue();
1581 aIgnoreLanguageChangeCB
.SaveValue();
1582 aCurrentDocCB
.SaveValue();
1584 sal_Bool bEnable
= !pLangConfig
->aLinguConfig
.IsReadOnly( "DefaultLocale" );
1585 aWesternLanguageFT
.Enable( bEnable
);
1586 aWesternLanguageLB
.Enable( bEnable
);
1589 aWesternLanguageFI
.Show(!bEnable
);
1591 // #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
1593 bEnable
= ( !pLangConfig
->aLinguConfig
.IsReadOnly( "DefaultLocale_CJK" ) && aAsianSupportCB
.IsChecked() );
1594 aAsianLanguageFT
.Enable( bEnable
);
1595 aAsianLanguageLB
.Enable( bEnable
);
1597 bEnable
= ( !pLangConfig
->aLinguConfig
.IsReadOnly( "DefaultLocale_CTL" ) && aCTLSupportCB
.IsChecked() );
1598 aComplexLanguageFT
.Enable( bEnable
);
1599 aComplexLanguageLB
.Enable( bEnable
);
1601 // check the box "For the current document only"
1602 // set the focus to the Western Language box
1603 const SfxPoolItem
* pLang
= 0;
1604 if ( SFX_ITEM_SET
== rSet
.GetItemState(SID_SET_DOCUMENT_LANGUAGE
, sal_False
, &pLang
) &&( (const SfxBoolItem
*)pLang
)->GetValue() == sal_True
)
1606 aWesternLanguageLB
.GrabFocus();
1607 aCurrentDocCB
.Enable(sal_True
);
1608 aCurrentDocCB
.Check(sal_True
);
1612 IMPL_LINK( OfaLanguagesTabPage
, SupportHdl
, CheckBox
*, pBox
)
1614 DBG_ASSERT( pBox
, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
1616 sal_Bool bCheck
= pBox
->IsChecked();
1617 if ( &aAsianSupportCB
== pBox
)
1619 sal_Bool bReadonly
= pLangConfig
->aLinguConfig
.IsReadOnly("DefaultLocale_CJK");
1620 bCheck
= ( bCheck
&& !bReadonly
);
1621 aAsianLanguageFT
.Enable( bCheck
);
1622 aAsianLanguageLB
.Enable( bCheck
);
1623 aAsianLanguageFI
.Show(bReadonly
);
1624 if( pBox
->IsEnabled() )
1625 m_bOldAsian
= bCheck
;
1627 else if ( &aCTLSupportCB
== pBox
)
1629 sal_Bool bReadonly
= pLangConfig
->aLinguConfig
.IsReadOnly("DefaultLocale_CTL");
1630 bCheck
= ( bCheck
&& !bReadonly
);
1631 aComplexLanguageFT
.Enable( bCheck
);
1632 aComplexLanguageLB
.Enable( bCheck
);
1633 aComplexLanguageFI
.Show(bReadonly
);
1634 if( pBox
->IsEnabled() )
1638 SAL_WARN( "cui.options", "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
1645 void lcl_checkLanguageCheckBox(CheckBox
& _rCB
,sal_Bool _bNewValue
,sal_Bool _bOldValue
)
1648 _rCB
.Check(sal_True
);
1650 _rCB
.Check( _bOldValue
);
1651 // #i15082# do not call SaveValue() in running dialog...
1652 // _rCB.SaveValue();
1653 _rCB
.Enable( !_bNewValue
);
1657 IMPL_LINK( OfaLanguagesTabPage
, LocaleSettingHdl
, SvxLanguageBox
*, pBox
)
1659 LanguageType eLang
= pBox
->GetSelectLanguage();
1660 sal_uInt16 nType
= SvtLanguageOptions::GetScriptTypeOfLanguage(eLang
);
1661 // first check if CTL must be enabled
1662 // #103299# - if CTL font setting is not readonly
1663 if(!pLangConfig
->aLanguageOptions
.IsReadOnly(SvtLanguageOptions::E_CTLFONT
))
1665 bool bIsCTLFixed
= (nType
& SCRIPTTYPE_COMPLEX
) != 0;
1666 lcl_checkLanguageCheckBox(aCTLSupportCB
, bIsCTLFixed
, m_bOldCtl
);
1667 SupportHdl( &aCTLSupportCB
);
1669 // second check if CJK must be enabled
1670 // #103299# - if CJK support is not readonly
1671 if(!pLangConfig
->aLanguageOptions
.IsReadOnly(SvtLanguageOptions::E_ALLCJK
))
1673 bool bIsCJKFixed
= (nType
& SCRIPTTYPE_ASIAN
) != 0;
1674 lcl_checkLanguageCheckBox(aAsianSupportCB
, bIsCJKFixed
, m_bOldAsian
);
1675 SupportHdl( &aAsianSupportCB
);
1679 if ( eLang
== LANGUAGE_USER_SYSTEM_CONFIG
)
1680 nPos
= aCurrencyLB
.GetEntryPos( (void*) NULL
);
1683 const NfCurrencyEntry
* pCurr
= &SvNumberFormatter::GetCurrencyEntry( eLang
);
1684 nPos
= aCurrencyLB
.GetEntryPos( (void*) pCurr
);
1686 aCurrencyLB
.SelectEntryPos( nPos
);
1688 // obtain corresponding locale data
1689 LanguageTag
aLanguageTag( eLang
);
1690 LocaleDataWrapper
aLocaleWrapper( aLanguageTag
);
1692 // update the decimal separator key of the related CheckBox
1693 OUString
sTempLabel(sDecimalSeparatorLabel
);
1694 sTempLabel
= sTempLabel
.replaceFirst("%1", aLocaleWrapper
.getNumDecimalSep() );
1695 aDecimalSeparatorCB
.SetText(sTempLabel
);
1697 // update the date acceptance patterns
1698 OUString aDatePatternsString
= lcl_getDatePatternsConfigString( aLocaleWrapper
);
1699 aDatePatternsED
.SetText( aDatePatternsString
);
1704 IMPL_LINK( OfaLanguagesTabPage
, DatePatternsHdl
, Edit
*, pEd
)
1706 OUString
aPatterns( pEd
->GetText());
1708 if (!aPatterns
.isEmpty())
1710 for (sal_Int32 nIndex
=0; nIndex
>= 0 && bValid
; /*nop*/)
1712 OUString
aPat( aPatterns
.getToken( 0, ';', nIndex
));
1713 if (aPat
.isEmpty() && nIndex
< 0)
1715 // Indicating failure when about to append a pattern is too
1716 // confusing. Empty patterns are ignored anyway when sequencing
1720 else if (aPat
.getLength() < 2)
1725 bY
= bM
= bD
= false;
1727 for (sal_Int32 i
= 0; i
< aPat
.getLength() && bValid
; /*nop*/)
1729 sal_uInt32 c
= aPat
.iterateCodePoints( &i
);
1730 // Only one Y,M,D per pattern, separated by any character(s).
1755 // At least one of Y,M,D
1756 bValid
&= (bY
|| bM
|| bD
);
1762 pEd
->SetControlForeground();
1763 pEd
->SetControlBackground();
1767 // color to use as background for an invalid pattern
1768 #define INVALID_PATTERN_BACKGROUND_COLOR Color(0xff6563)
1770 // color to use as foreground for an invalid pattern
1771 #define INVALID_PATTERN_FOREGROUND_COLOR Color(COL_WHITE)
1772 //! Gives white on white!?!
1773 pEd
->SetControlBackground( INVALID_PATTERN_BACKGROUND_COLOR
);
1774 pEd
->SetControlForeground( INVALID_PATTERN_FOREGROUND_COLOR
);
1776 pEd
->SetControlForeground( INVALID_PATTERN_BACKGROUND_COLOR
);
1782 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */