masterfix DEV300: #i10000# build fix
[LibreOffice.git] / cui / source / options / optgdlg.cxx
blob8b6c0beda7aef30d5ede06945fd2119b9bb4f561
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_cui.hxx"
30 #include <svl/zforlist.hxx>
31 #include <svtools/grfmgr.hxx>
32 #include <svl/flagitem.hxx>
33 #include <sfx2/dispatch.hxx>
34 #include <unotools/lingucfg.hxx>
35 #include <svl/szitem.hxx>
36 #include <sfx2/viewsh.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/imgmgr.hxx>
39 #include <vcl/configsettings.hxx>
40 #include <vcl/msgbox.hxx>
41 #include <vcl/mnemonic.hxx>
42 #include <i18npool/mslangid.hxx>
43 #include <unotools/useroptions.hxx>
44 #include <unotools/cacheoptions.hxx>
45 #include <unotools/fontoptions.hxx>
46 #include <svtools/menuoptions.hxx>
47 #include <unotools/startoptions.hxx>
48 #include <svl/languageoptions.hxx>
49 #include <svtools/miscopt.hxx>
50 #include <unotools/printwarningoptions.hxx>
51 #include <unotools/syslocaleoptions.hxx>
52 #include <svtools/helpopt.hxx>
53 #include <svtools/accessibilityoptions.hxx>
54 #include <unotools/configitem.hxx>
55 #include <sfx2/objsh.hxx>
56 #include <comphelper/types.hxx>
57 #include <svl/ctloptions.hxx>
58 #include <svtools/langtab.hxx>
59 #include <unotools/localfilehelper.hxx>
60 #include <unotools/configmgr.hxx>
61 #include "cuioptgenrl.hxx"
62 #include "optpath.hxx"
63 #include "optsave.hxx"
64 #include "optlingu.hxx"
65 #include <svx/xpool.hxx>
66 #include <svx/dlgutil.hxx>
67 #include "cuitabarea.hxx"
68 #include <cuires.hrc>
69 #include <editeng/unolingu.hxx>
70 #include <editeng/langitem.hxx>
71 #include <comphelper/processfactory.hxx>
72 #include <rtl/ustrbuf.hxx>
73 #include <editeng/editids.hrc>
74 #include <svx/svxids.hrc>
75 #include <svl/intitem.hxx>
76 #include <dialmgr.hxx>
77 #include <svtools/helpopt.hxx>
78 #include <unotools/saveopt.hxx>
80 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
81 #include <com/sun/star/container/XNameAccess.hpp>
82 #include <com/sun/star/container/XNameReplace.hpp>
83 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
84 #include <com/sun/star/lang/XComponent.hpp>
85 #include <com/sun/star/lang/XInitialization.hpp>
86 #include <com/sun/star/beans/NamedValue.hpp>
87 #include <com/sun/star/beans/XPropertySet.hpp>
88 #include <com/sun/star/util/XChangesBatch.hpp>
89 #include <com/sun/star/uno/Any.hxx>
90 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
91 #include <com/sun/star/container/XSet.hpp>
92 #include <com/sun/star/i18n/ScriptType.hpp>
94 #include <vcl/svapp.hxx>
96 #include "optgdlg.hrc"
97 #include "optgdlg.hxx"
98 #include <svx/ofaitem.hxx>
99 #include <svtools/apearcfg.hxx>
100 #include <svtools/optionsdrawinglayer.hxx>
102 #define CONFIG_LANGUAGES "OfficeLanguages"
104 using namespace ::com::sun::star::uno;
105 using namespace ::com::sun::star::lang;
106 using namespace ::com::sun::star::beans;
107 using namespace ::com::sun::star::container;
108 using namespace ::com::sun::star::util;
109 using namespace ::utl;
110 using ::rtl::OString;
111 using ::rtl::OUString;
113 #define C2U(cChar) OUString::createFromAscii(cChar)
115 #define MAX_PROGRAM_ENTRIES 3
117 // class OfaMiscTabPage --------------------------------------------------
119 int OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
121 if ( pSet_ )
122 FillItemSet( *pSet_ );
123 return LEAVE_PAGE;
126 namespace
128 ::rtl::OUString impl_SystemFileOpenServiceName()
130 const ::rtl::OUString &rDesktopEnvironment =
131 Application::GetDesktopEnvironment();
133 if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) )
135 #ifdef ENABLE_GTK
136 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.GtkFilePicker" );
137 #else
138 return rtl::OUString();
139 #endif
141 else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde4" ) )
143 #ifdef ENABLE_KDE4
144 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.KDE4FilePicker" );
145 #else
146 return rtl::OUString();
147 #endif
149 else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde" ) )
151 #ifdef ENABLE_KDE
152 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.KDEFilePicker" );
153 #else
154 return rtl::OUString();
155 #endif
157 #if defined WNT
158 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.SystemFilePicker" );
159 #elif (defined MACOSX && defined QUARTZ)
160 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.AquaFilePicker" );
161 #else
162 return rtl::OUString();
163 #endif
166 sal_Bool lcl_HasSystemFilePicker()
168 Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
169 sal_Bool bRet = sal_False;
171 Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
172 Reference< XSet > xSet( xFactory, UNO_QUERY );
174 if ( ! xEnumAccess.is() || ! xSet.is() )
175 return bRet;
179 ::rtl::OUString aFileService = impl_SystemFileOpenServiceName();
180 Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
181 if ( xEnum.is() && xEnum->hasMoreElements() )
182 bRet = sal_True;
185 catch( IllegalArgumentException ) {}
186 catch( ElementExistException ) {}
187 return bRet;
191 // -----------------------------------------------------------------------
193 OfaMiscTabPage::OfaMiscTabPage(Window* pParent, const SfxItemSet& rSet ) :
195 SfxTabPage( pParent, CUI_RES( OFA_TP_MISC ), rSet ),
197 aHelpFL ( this, CUI_RES( FL_HELP ) ),
198 aToolTipsCB ( this, CUI_RES( CB_TOOLTIP ) ),
199 aExtHelpCB ( this, CUI_RES( CB_EXTHELP ) ),
200 aHelpAgentCB ( this, CUI_RES( CB_HELPAGENT ) ),
201 aHelpAgentResetBtn ( this, CUI_RES( PB_HELPAGENT_RESET ) ),
202 aHelpFormatFT ( this, CUI_RES( FT_HELPFORMAT ) ),
203 aHelpFormatLB ( this, CUI_RES( LB_HELPFORMAT ) ),
204 aFileDlgFL ( this, CUI_RES( FL_FILEDLG ) ),
205 aFileDlgROImage ( this, CUI_RES( FI_FILEDLG_RO ) ),
206 aFileDlgCB ( this, CUI_RES( CB_FILEDLG ) ),
207 aPrintDlgFL ( this, CUI_RES( FL_PRINTDLG ) ),
208 aPrintDlgCB ( this, CUI_RES( CB_PRINTDLG ) ),
209 aDocStatusFL ( this, CUI_RES( FL_DOCSTATUS ) ),
210 aDocStatusCB ( this, CUI_RES( CB_DOCSTATUS ) ),
211 aTwoFigureFL ( this, CUI_RES( FL_TWOFIGURE ) ),
212 aInterpretFT ( this, CUI_RES( FT_INTERPRET ) ),
213 aYearValueField ( this, CUI_RES( NF_YEARVALUE ) ),
214 aToYearFT ( this, CUI_RES( FT_TOYEAR ) )
217 FreeResource();
219 if (!lcl_HasSystemFilePicker())
221 aFileDlgFL.Hide();
222 aFileDlgCB.Hide();
225 #if ! defined(QUARTZ)
226 aPrintDlgFL.Hide();
227 aPrintDlgCB.Hide();
228 #endif
230 if ( !aFileDlgCB.IsVisible() )
232 // rearrange the following controls
233 Point aNewPos = aDocStatusFL.GetPosPixel();
234 long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
236 Window* pWins[] =
238 &aPrintDlgFL, &aPrintDlgCB, &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
239 &aInterpretFT, &aYearValueField, &aToYearFT
241 Window** pCurrent = pWins;
242 const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
243 for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
245 aNewPos = (*pCurrent)->GetPosPixel();
246 aNewPos.Y() -= nDelta;
247 (*pCurrent)->SetPosPixel( aNewPos );
250 else if ( SvtMiscOptions().IsUseSystemFileDialogReadOnly() )
252 aFileDlgROImage.Show();
253 aFileDlgCB.Disable();
256 if ( aPrintDlgCB.IsVisible() )
258 // rearrange the following controls
259 Point aNewPos = aDocStatusFL.GetPosPixel();
260 long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
262 Window* pWins[] =
264 &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
265 &aInterpretFT, &aYearValueField, &aToYearFT
267 Window** pCurrent = pWins;
268 const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
269 for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
271 aNewPos = (*pCurrent)->GetPosPixel();
272 aNewPos.Y() += nDelta;
273 (*pCurrent)->SetPosPixel( aNewPos );
277 // at least the button is as wide as its text
278 long nTxtWidth = aHelpAgentResetBtn.GetTextWidth( aHelpAgentResetBtn.GetText() );
279 Size aBtnSz = aHelpAgentResetBtn.GetSizePixel();
280 if ( aBtnSz.Width() < nTxtWidth )
282 aBtnSz.Width() = nTxtWidth;
283 aHelpAgentResetBtn.SetSizePixel( aBtnSz );
286 aStrDateInfo = aToYearFT.GetText();
287 aYearValueField.SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
288 Link aLink = LINK( this, OfaMiscTabPage, TwoFigureConfigHdl );
289 aYearValueField.SetDownHdl( aLink );
290 aYearValueField.SetUpHdl( aLink );
291 aYearValueField.SetLoseFocusHdl( aLink );
292 aYearValueField.SetFirstHdl( aLink );
293 TwoFigureConfigHdl( &aYearValueField );
295 SetExchangeSupport();
297 aLink = LINK( this, OfaMiscTabPage, HelpCheckHdl_Impl );
298 aToolTipsCB.SetClickHdl( aLink );
299 aHelpAgentCB.SetClickHdl( aLink );
300 aHelpAgentResetBtn.SetClickHdl( LINK( this, OfaMiscTabPage, HelpAgentResetHdl_Impl ) );
302 //fill default names as user data
303 static const char* aHelpFormatNames[] =
305 "Default",
306 "HighContrast1",
307 "HighContrast2",
308 "HighContrastBlack",
309 "HighContrastWhite"
312 for ( sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); i++ )
314 String* pData = new String( String::CreateFromAscii( aHelpFormatNames[i] ) );
315 aHelpFormatLB.SetEntryData( i, pData );
319 // -----------------------------------------------------------------------
321 OfaMiscTabPage::~OfaMiscTabPage()
323 for(sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); i++)
325 delete static_cast< String* >( aHelpFormatLB.GetEntryData(i) );
329 // -----------------------------------------------------------------------
331 SfxTabPage* OfaMiscTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
333 return new OfaMiscTabPage( pParent, rAttrSet );
336 // -----------------------------------------------------------------------
338 sal_Bool OfaMiscTabPage::FillItemSet( SfxItemSet& rSet )
340 sal_Bool bModified = sal_False;
342 SvtHelpOptions aHelpOptions;
343 sal_Bool bChecked = aToolTipsCB.IsChecked();
344 if ( bChecked != aToolTipsCB.GetSavedValue() )
345 aHelpOptions.SetHelpTips( bChecked );
346 bChecked = ( aExtHelpCB.IsChecked() && aToolTipsCB.IsChecked() );
347 if ( bChecked != aExtHelpCB.GetSavedValue() )
348 aHelpOptions.SetExtendedHelp( bChecked );
349 bChecked = aHelpAgentCB.IsChecked();
350 if ( bChecked != aHelpAgentCB.GetSavedValue() )
351 aHelpOptions.SetHelpAgentAutoStartMode( bChecked );
352 sal_uInt16 nHelpFormatPos = aHelpFormatLB.GetSelectEntryPos();
353 if ( nHelpFormatPos != LISTBOX_ENTRY_NOTFOUND &&
354 nHelpFormatPos != aHelpFormatLB.GetSavedValue() )
356 aHelpOptions.SetHelpStyleSheet( *static_cast< String* >( aHelpFormatLB.GetEntryData( nHelpFormatPos ) ) );
359 if ( aFileDlgCB.IsChecked() != aFileDlgCB.GetSavedValue() )
361 SvtMiscOptions aMiscOpt;
362 aMiscOpt.SetUseSystemFileDialog( !aFileDlgCB.IsChecked() );
363 bModified = sal_True;
366 if ( aPrintDlgCB.IsChecked() != aPrintDlgCB.GetSavedValue() )
368 SvtMiscOptions aMiscOpt;
369 aMiscOpt.SetUseSystemPrintDialog( !aPrintDlgCB.IsChecked() );
370 bModified = sal_True;
373 if ( aDocStatusCB.IsChecked() != aDocStatusCB.GetSavedValue() )
375 SvtPrintWarningOptions aPrintOptions;
376 aPrintOptions.SetModifyDocumentOnPrintingAllowed( aDocStatusCB.IsChecked() );
377 bModified = sal_True;
380 const SfxUInt16Item* pUInt16Item =
381 PTR_CAST( SfxUInt16Item, GetOldItem( rSet, SID_ATTR_YEAR2000 ) );
382 sal_uInt16 nNum = (sal_uInt16)aYearValueField.GetText().ToInt32();
383 if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
385 bModified = sal_True;
386 rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
389 return bModified;
392 // -----------------------------------------------------------------------
394 void OfaMiscTabPage::Reset( const SfxItemSet& rSet )
396 SvtHelpOptions aHelpOptions;
397 aToolTipsCB.Check( aHelpOptions.IsHelpTips() );
398 aExtHelpCB.Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
399 aHelpAgentCB.Check( aHelpOptions.IsHelpAgentAutoStartMode() );
400 String sStyleSheet = aHelpOptions.GetHelpStyleSheet();
401 for ( sal_uInt16 i = 0; i < aHelpFormatLB.GetEntryCount(); ++i )
403 if ( *static_cast< String* >( aHelpFormatLB.GetEntryData(i) ) == sStyleSheet )
405 aHelpFormatLB.SelectEntryPos(i);
406 break;
410 aToolTipsCB.SaveValue();
411 aExtHelpCB.SaveValue();
412 aHelpAgentCB.SaveValue();
413 aHelpFormatLB.SaveValue();
414 HelpCheckHdl_Impl( &aHelpAgentCB );
416 SvtMiscOptions aMiscOpt;
417 aFileDlgCB.Check( !aMiscOpt.UseSystemFileDialog() );
418 aFileDlgCB.SaveValue();
419 aPrintDlgCB.Check( !aMiscOpt.UseSystemPrintDialog() );
420 aPrintDlgCB.SaveValue();
422 SvtPrintWarningOptions aPrintOptions;
423 aDocStatusCB.Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
424 aDocStatusCB.SaveValue();
426 const SfxPoolItem* pItem = NULL;
427 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, sal_False, &pItem ) )
429 aYearValueField.SetValue( ((SfxUInt16Item*)pItem)->GetValue() );
430 TwoFigureConfigHdl( &aYearValueField );
432 else
434 aYearValueField.Enable(sal_False);
435 aTwoFigureFL.Enable(sal_False);
436 aInterpretFT.Enable(sal_False);
437 aToYearFT.Enable(sal_False);
441 // -----------------------------------------------------------------------
443 IMPL_LINK( OfaMiscTabPage, TwoFigureHdl, NumericField*, pEd )
445 (void)pEd;
447 String aOutput( aStrDateInfo );
448 String aStr( aYearValueField.GetText() );
449 String sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
450 xub_StrLen nIndex = 0;
451 while ((nIndex = aStr.Search( sSep, nIndex)) != STRING_NOTFOUND)
452 aStr.Erase( nIndex, sSep.Len());
453 long nNum = aStr.ToInt32();
454 if ( aStr.Len() != 4 || nNum < aYearValueField.GetMin() || nNum > aYearValueField.GetMax() )
455 aOutput.AppendAscii("????");
456 else
458 nNum += 99;
459 aOutput += String::CreateFromInt32( nNum );
461 aToYearFT.SetText( aOutput );
462 return 0;
465 // -----------------------------------------------------------------------
467 IMPL_LINK( OfaMiscTabPage, TwoFigureConfigHdl, NumericField*, pEd )
469 sal_Int64 nNum = aYearValueField.GetValue();
470 String aOutput( String::CreateFromInt64( nNum ) );
471 aYearValueField.SetText( aOutput );
472 aYearValueField.SetSelection( Selection( 0, aOutput.Len() ) );
473 TwoFigureHdl( pEd );
474 return 0;
477 // -----------------------------------------------------------------------
479 IMPL_LINK( OfaMiscTabPage, HelpCheckHdl_Impl, CheckBox*, EMPTYARG )
481 aExtHelpCB.Enable( aToolTipsCB.IsChecked() );
482 aHelpAgentResetBtn.Enable( aHelpAgentCB.IsChecked() );
483 return 0;
486 // -----------------------------------------------------------------------
488 IMPL_LINK( OfaMiscTabPage, HelpAgentResetHdl_Impl, PushButton*, EMPTYARG )
490 SvtHelpOptions().resetAgentIgnoreURLCounter();
491 return 0;
494 // -----------------------------------------------------------------------
496 // -------------------------------------------------------------------
497 class CanvasSettings
499 public:
500 CanvasSettings();
502 sal_Bool IsHardwareAccelerationEnabled() const;
503 sal_Bool IsHardwareAccelerationAvailable() const;
504 void EnabledHardwareAcceleration( sal_Bool _bEnabled ) const;
506 private:
507 typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
509 Reference<XNameAccess> mxForceFlagNameAccess;
510 ServiceVector maAvailableImplementations;
511 mutable sal_Bool mbHWAccelAvailable;
512 mutable sal_Bool mbHWAccelChecked;
515 // -------------------------------------------------------------------
516 CanvasSettings::CanvasSettings() :
517 mxForceFlagNameAccess(),
518 mbHWAccelAvailable(sal_False),
519 mbHWAccelChecked(sal_False)
523 Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
524 Reference<XMultiServiceFactory> xConfigProvider(
525 xFactory->createInstance(
526 OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
527 UNO_QUERY_THROW );
529 Any propValue(
530 makeAny( PropertyValue(
531 OUString::createFromAscii("nodepath"), -1,
532 makeAny( OUString::createFromAscii("/org.openoffice.Office.Canvas") ),
533 PropertyState_DIRECT_VALUE ) ) );
535 mxForceFlagNameAccess.set(
536 xConfigProvider->createInstanceWithArguments(
537 OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
538 Sequence<Any>( &propValue, 1 ) ),
539 UNO_QUERY_THROW );
541 propValue = makeAny(
542 PropertyValue(
543 OUString::createFromAscii("nodepath"), -1,
544 makeAny( OUString::createFromAscii("/org.openoffice.Office.Canvas/CanvasServiceList") ),
545 PropertyState_DIRECT_VALUE ) );
547 Reference<XNameAccess> xNameAccess(
548 xConfigProvider->createInstanceWithArguments(
549 OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"),
550 Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
551 Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
552 xNameAccess, UNO_QUERY_THROW);
554 Sequence<OUString> serviceNames = xNameAccess->getElementNames();
555 const OUString* pCurr = serviceNames.getConstArray();
556 const OUString* const pEnd = pCurr + serviceNames.getLength();
557 while( pCurr != pEnd )
559 Reference<XNameAccess> xEntryNameAccess(
560 xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
561 UNO_QUERY );
563 if( xEntryNameAccess.is() )
565 Sequence<OUString> preferredImplementations;
566 if( (xEntryNameAccess->getByName( OUString::createFromAscii("PreferredImplementations") ) >>= preferredImplementations) )
567 maAvailableImplementations.push_back( std::make_pair(*pCurr,preferredImplementations) );
570 ++pCurr;
573 catch( Exception& )
578 // -------------------------------------------------------------------
579 sal_Bool CanvasSettings::IsHardwareAccelerationAvailable() const
581 if( !mbHWAccelChecked )
583 mbHWAccelChecked = true;
585 Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
587 // check whether any of the service lists has an
588 // implementation that presents the "HardwareAcceleration" property
589 ServiceVector::const_iterator aCurr=maAvailableImplementations.begin();
590 const ServiceVector::const_iterator aEnd=maAvailableImplementations.end();
591 while( aCurr != aEnd )
593 const OUString* pCurrImpl = aCurr->second.getConstArray();
594 const OUString* const pEndImpl = pCurrImpl + aCurr->second.getLength();
596 while( pCurrImpl != pEndImpl )
600 Reference<XPropertySet> xPropSet( xFactory->createInstance(
601 pCurrImpl->trim() ),
602 UNO_QUERY_THROW );
603 bool bHasAccel(false);
604 if( (xPropSet->getPropertyValue(OUString::createFromAscii("HardwareAcceleration")) >>= bHasAccel) )
605 if( bHasAccel )
607 mbHWAccelAvailable = true;
608 return mbHWAccelAvailable;
611 catch (Exception &)
614 ++pCurrImpl;
617 ++aCurr;
621 return mbHWAccelAvailable;
624 // -------------------------------------------------------------------
625 sal_Bool CanvasSettings::IsHardwareAccelerationEnabled() const
627 bool bForceLastEntry(false);
628 if( !mxForceFlagNameAccess.is() )
629 return true;
631 if( !(mxForceFlagNameAccess->getByName( OUString::createFromAscii("ForceSafeServiceImpl") ) >>= bForceLastEntry) )
632 return true;
634 return !bForceLastEntry;
637 // -------------------------------------------------------------------
638 void CanvasSettings::EnabledHardwareAcceleration( sal_Bool _bEnabled ) const
640 Reference< XNameReplace > xNameReplace(
641 mxForceFlagNameAccess, UNO_QUERY );
643 if( !xNameReplace.is() )
644 return;
646 xNameReplace->replaceByName( OUString::createFromAscii("ForceSafeServiceImpl"),
647 makeAny(!_bEnabled) );
649 Reference< XChangesBatch > xChangesBatch(
650 mxForceFlagNameAccess, UNO_QUERY );
652 if( !xChangesBatch.is() )
653 return;
655 xChangesBatch->commitChanges();
658 // class OfaViewTabPage --------------------------------------------------
660 OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) :
662 SfxTabPage( pParent, CUI_RES( OFA_TP_VIEW ), rSet ),
664 aUserInterfaceFL ( this, CUI_RES( FL_USERINTERFACE ) ),
665 aWindowSizeFT ( this, CUI_RES( FT_WINDOWSIZE ) ),
666 aWindowSizeMF ( this, CUI_RES( MF_WINDOWSIZE ) ),
667 aIconSizeStyleFT ( this, CUI_RES( FT_ICONSIZESTYLE ) ),
668 aIconSizeLB ( this, CUI_RES( LB_ICONSIZE ) ),
669 aIconStyleLB ( this, CUI_RES( LB_ICONSTYLE ) ),
670 m_aSystemFont (this, CUI_RES( CB_SYSTEM_FONT ) ),
671 #if defined( UNX )
672 aFontAntiAliasing ( this, CUI_RES( CB_FONTANTIALIASING )),
673 aAAPointLimitLabel ( this, CUI_RES( FT_POINTLIMIT_LABEL )),
674 aAAPointLimit ( this, CUI_RES( NF_AA_POINTLIMIT )),
675 aAAPointLimitUnits ( this, CUI_RES( FT_POINTLIMIT_UNIT )),
676 #endif
677 aMenuFL ( this, CUI_RES( FL_MENU ) ),
678 aMenuIconsFT ( this, CUI_RES( FT_MENU_ICONS )),
679 aMenuIconsLB ( this, CUI_RES( LB_MENU_ICONS )),
680 aFontListsFL ( this, CUI_RES( FL_FONTLISTS) ),
681 aFontShowCB ( this, CUI_RES( CB_FONT_SHOW ) ),
682 aFontHistoryCB ( this, CUI_RES( CB_FONT_HISTORY ) ),
683 aRenderingFL ( this, CUI_RES( FL_RENDERING ) ),
684 aUseHardwareAccell ( this, CUI_RES( CB_USE_HARDACCELL ) ),
685 aUseAntiAliase ( this, CUI_RES( CB_USE_ANTIALIASE ) ),
686 aMouseFL ( this, CUI_RES( FL_MOUSE ) ),
687 aMousePosFT ( this, CUI_RES( FT_MOUSEPOS ) ),
688 aMousePosLB ( this, CUI_RES( LB_MOUSEPOS ) ),
689 aMouseMiddleFT ( this, CUI_RES( FT_MOUSEMIDDLE ) ),
690 aMouseMiddleLB ( this, CUI_RES( LB_MOUSEMIDDLE ) ),
692 // #i97672#
693 maSelectionFL(this, CUI_RES(FL_SELECTION)),
694 maSelectionCB(this, CUI_RES(CB_SELECTION)),
695 maSelectionMF(this, CUI_RES(MF_SELECTION)),
697 nSizeLB_InitialSelection(0),
698 nStyleLB_InitialSelection(0),
699 pAppearanceCfg(new SvtTabAppearanceCfg),
700 pCanvasSettings(new CanvasSettings),
701 mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
703 #if defined( UNX )
704 aFontAntiAliasing.SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
706 // depending on the size of the text in aAAPointLimitLabel, we slightly re-arrange aAAPointLimit and aAAPointLimitUnits
707 //#110391# if the label has no mnemonic and we are in a CJK version the mnemonic "(X)" will be added which
708 // influences the width calculation
709 MnemonicGenerator aMnemonicGenerator;
710 String sLabel(aAAPointLimitLabel.GetText());
711 aMnemonicGenerator.RegisterMnemonic( sLabel );
712 aMnemonicGenerator.CreateMnemonic( sLabel );
713 sLabel.EraseAllChars('~');
715 sal_Int32 nLabelWidth = aAAPointLimitLabel.GetTextWidth( sLabel );
716 nLabelWidth += 3; // small gap
717 // pixels to move both controls to the left
718 Size aSize = aAAPointLimitLabel.GetSizePixel();
719 sal_Int32 nMoveLeft = aSize.Width() - nLabelWidth;
720 // resize the first label
721 aSize.Width() = nLabelWidth;
722 aAAPointLimitLabel.SetSizePixel( aSize );
724 // move the numeric field
725 Point aPos( aAAPointLimit.GetPosPixel() );
726 aPos.X() -= nMoveLeft;
727 aAAPointLimit.SetPosPixel( aPos );
729 // move (and resize) the units FixedText
730 aPos = ( aAAPointLimitUnits.GetPosPixel() );
731 aPos.X() -= nMoveLeft;
732 aSize = aAAPointLimitUnits.GetSizePixel();
733 aSize.Width() += nMoveLeft;
734 aAAPointLimitUnits.SetPosSizePixel( aPos, aSize );
735 #else
736 // on this platform, we do not have the anti aliasing options - move the other checkboxes accordingly
737 // (in the resource, the coordinates are calculated for the AA options beeing present)
738 Control* pMiscOptions[] =
740 &aMenuFL, &aMenuIconsFT, &aMenuIconsLB,
741 &aFontListsFL, &aFontShowCB, &aFontHistoryCB
744 // temporaryly create the checkbox for the anti aliasing (we need to to determine it's pos)
745 CheckBox* pFontAntiAliasing = new CheckBox( this, CUI_RES( CB_FONTANTIALIASING ) );
746 sal_Int32 nMoveUp = aMenuFL.GetPosPixel().Y() - pFontAntiAliasing->GetPosPixel().Y();
747 DELETEZ( pFontAntiAliasing );
749 Point aPos;
750 for ( sal_Int32 i = 0; i < sizeof( pMiscOptions ) / sizeof( pMiscOptions[0] ); ++i )
752 aPos = pMiscOptions[i]->GetPosPixel( );
753 aPos.Y() -= nMoveUp;
754 pMiscOptions[i]->SetPosPixel( aPos );
757 #endif
759 // #i97672#
760 maSelectionCB.SetToggleHdl( LINK( this, OfaViewTabPage, OnSelectionToggled ) );
762 FreeResource();
764 if( ! Application::ValidateSystemFont() )
766 m_aSystemFont.Check( sal_False );
767 m_aSystemFont.Enable( sal_False );
770 const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
772 // remove non-installed icon themes
773 if( aIconStyleLB.GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX )
775 // do not check 0th item == auto; it is not a real theme
776 aIconStyleItemId[0] = 0;
777 sal_uLong nItem = 1;
778 for ( sal_uLong n=0; ++n < STYLE_SYMBOLS_THEMES_MAX; )
780 if ( aStyleSettings.CheckSymbolStyle( n ) )
782 // existing style => save the item id
783 aIconStyleItemId[n] = nItem++;
785 else
787 // non-existing style => remove item;
788 aIconStyleLB.RemoveEntry( nItem );
789 aIconStyleItemId[n] = 0;
794 // add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
795 if( aIconStyleLB.GetEntryCount() > 1 )
797 ::rtl::OUString aAutoStr( aIconStyleLB.GetEntry( 0 ) );
799 aAutoStr += ::rtl::OUString::createFromAscii( " (" );
801 sal_uLong nAutoStyle = aStyleSettings.GetAutoSymbolsStyle();
802 if ( aIconStyleItemId[nAutoStyle] )
803 aAutoStr += aIconStyleLB.GetEntry( aIconStyleItemId[nAutoStyle] );
805 aIconStyleLB.RemoveEntry( 0 );
806 aIconStyleLB.InsertEntry( aAutoStr += ::rtl::OUString::createFromAscii( ")" ), 0 );
807 // separate auto and other icon themes
808 aIconStyleLB.SetSeparatorPos( 0 );
812 OfaViewTabPage::~OfaViewTabPage()
814 delete mpDrawinglayerOpt;
815 delete pCanvasSettings;
816 delete pAppearanceCfg;
819 #if defined( UNX )
820 //--- 20.08.01 10:16:12 ---------------------------------------------------
821 IMPL_LINK( OfaViewTabPage, OnAntialiasingToggled, void*, NOTINTERESTEDIN )
823 (void)NOTINTERESTEDIN;
825 sal_Bool bAAEnabled = aFontAntiAliasing.IsChecked();
827 aAAPointLimitLabel.Enable( bAAEnabled );
828 aAAPointLimit.Enable( bAAEnabled );
829 aAAPointLimitUnits.Enable( bAAEnabled );
831 return 0L;
833 #endif
835 // #i97672#
836 IMPL_LINK( OfaViewTabPage, OnSelectionToggled, void*, NOTINTERESTEDIN )
838 (void)NOTINTERESTEDIN;
839 const bool bSelectionEnabled(maSelectionCB.IsChecked());
840 maSelectionMF.Enable(bSelectionEnabled);
841 return 0;
844 /*-----------------06.12.96 11.50-------------------
846 --------------------------------------------------*/
848 SfxTabPage* OfaViewTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
850 return new OfaViewTabPage(pParent, rAttrSet);
853 /*-----------------06.12.96 11.50-------------------
855 --------------------------------------------------*/
857 sal_Bool OfaViewTabPage::FillItemSet( SfxItemSet& )
859 SvtFontOptions aFontOpt;
860 SvtMenuOptions aMenuOpt;
861 SvtStartOptions aStartOpt;
863 sal_Bool bModified = sal_False;
864 sal_Bool bMenuOptModified = sal_False;
865 bool bRepaintWindows(false);
867 SvtMiscOptions aMiscOptions;
868 sal_uInt16 nSizeLB_NewSelection = aIconSizeLB.GetSelectEntryPos();
869 if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
871 // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
872 sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
873 switch( nSizeLB_NewSelection )
875 case 0: eSet = SFX_SYMBOLS_SIZE_AUTO; break;
876 case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
877 case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
878 default:
879 DBG_ERROR( "OfaViewTabPage::FillItemSet(): This state of aIconSizeLB should not be possible!" );
881 aMiscOptions.SetSymbolsSize( eSet );
884 sal_uInt16 nStyleLB_NewSelection = aIconStyleLB.GetSelectEntryPos();
885 if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
887 // find the style name in the aIconStyleItemId table
888 // items from the non-installed icon themes were removed
889 for ( sal_uLong n=0; n < STYLE_SYMBOLS_THEMES_MAX; n++ )
891 if ( aIconStyleItemId[n] == nStyleLB_NewSelection )
893 aMiscOptions.SetSymbolsStyle( n );
894 n = STYLE_SYMBOLS_THEMES_MAX;
899 sal_Bool bAppearanceChanged = sal_False;
902 // Screen Scaling
903 sal_uInt16 nOldScale = pAppearanceCfg->GetScaleFactor();
904 sal_uInt16 nNewScale = (sal_uInt16)aWindowSizeMF.GetValue();
906 if ( nNewScale != nOldScale )
908 pAppearanceCfg->SetScaleFactor(nNewScale);
909 bAppearanceChanged = sal_True;
912 // Mouse Snap Mode
913 short eOldSnap = pAppearanceCfg->GetSnapMode();
914 short eNewSnap = aMousePosLB.GetSelectEntryPos();
915 if(eNewSnap > 2)
916 eNewSnap = 2;
918 if ( eNewSnap != eOldSnap )
920 pAppearanceCfg->SetSnapMode(eNewSnap );
921 bAppearanceChanged = sal_True;
924 // Middle Mouse Button
925 short eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
926 short eNewMiddleMouse = aMouseMiddleLB.GetSelectEntryPos();
927 if(eNewMiddleMouse > 2)
928 eNewMiddleMouse = 2;
930 if ( eNewMiddleMouse != eOldMiddleMouse )
932 pAppearanceCfg->SetMiddleMouseButton( eNewMiddleMouse );
933 bAppearanceChanged = sal_True;
936 #if defined( UNX )
937 if ( aFontAntiAliasing.IsChecked() != aFontAntiAliasing.GetSavedValue() )
939 pAppearanceCfg->SetFontAntiAliasing( aFontAntiAliasing.IsChecked() );
940 bAppearanceChanged = sal_True;
943 if ( aAAPointLimit.GetValue() != aAAPointLimit.GetSavedValue().ToInt32() )
945 pAppearanceCfg->SetFontAntialiasingMinPixelHeight( aAAPointLimit.GetValue() );
946 bAppearanceChanged = sal_True;
948 #endif
950 if ( aFontShowCB.IsChecked() != aFontShowCB.GetSavedValue() )
952 aFontOpt.EnableFontWYSIWYG( aFontShowCB.IsChecked() );
953 bModified = sal_True;
956 if(aMenuIconsLB.GetSelectEntryPos() != aMenuIconsLB.GetSavedValue())
958 aMenuOpt.SetMenuIconsState( aMenuIconsLB.GetSelectEntryPos() == 0 ? 2 : aMenuIconsLB.GetSelectEntryPos() - 1);
959 bModified = sal_True;
960 bMenuOptModified = sal_True;
961 bAppearanceChanged = sal_True;
964 if ( aFontHistoryCB.IsChecked() != aFontHistoryCB.GetSavedValue() )
966 aFontOpt.EnableFontHistory( aFontHistoryCB.IsChecked() );
967 bModified = sal_True;
970 // #i95644# if disabled, do not use value, see in ::Reset()
971 if(aUseHardwareAccell.IsEnabled())
973 if(aUseHardwareAccell.IsChecked() != aUseHardwareAccell.GetSavedValue())
975 pCanvasSettings->EnabledHardwareAcceleration(aUseHardwareAccell.IsChecked());
976 bModified = sal_True;
980 // #i95644# if disabled, do not use value, see in ::Reset()
981 if(aUseAntiAliase.IsEnabled())
983 if(aUseAntiAliase.IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
985 mpDrawinglayerOpt->SetAntiAliasing(aUseAntiAliase.IsChecked());
986 bModified = sal_True;
987 bRepaintWindows = true;
991 // #i97672#
992 if(maSelectionCB.IsEnabled())
994 const bool bNewSelection(maSelectionCB.IsChecked());
995 const sal_uInt16 nNewTransparence((sal_uInt16)maSelectionMF.GetValue());
997 if(bNewSelection != (bool)mpDrawinglayerOpt->IsTransparentSelection())
999 mpDrawinglayerOpt->SetTransparentSelection(maSelectionCB.IsChecked());
1000 bModified = sal_True;
1001 bRepaintWindows = true;
1004 // #i104150# even read the value when maSelectionMF is disabled; it may have been
1005 // modified by enabling-modify-disabling by the user
1006 if(nNewTransparence != mpDrawinglayerOpt->GetTransparentSelectionPercent())
1008 mpDrawinglayerOpt->SetTransparentSelectionPercent(nNewTransparence);
1009 bModified = sal_True;
1010 bRepaintWindows = true;
1014 SvtAccessibilityOptions aAccessibilityOptions;
1015 if( aAccessibilityOptions.GetIsSystemFont() != m_aSystemFont.IsChecked() &&
1016 m_aSystemFont.IsEnabled() )
1018 aAccessibilityOptions.SetIsSystemFont( m_aSystemFont.IsChecked() );
1019 bModified = sal_True;
1020 bMenuOptModified = sal_True;
1023 if( bMenuOptModified )
1025 // Set changed settings to the application instance
1026 AllSettings aAllSettings = Application::GetSettings();
1027 StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
1028 if( m_aSystemFont.IsEnabled() )
1029 aStyleSettings.SetUseSystemUIFonts( m_aSystemFont.IsChecked() );
1030 aAllSettings.SetStyleSettings(aStyleSettings);
1031 Application::MergeSystemSettings( aAllSettings );
1032 Application::SetSettings(aAllSettings);
1035 if ( bAppearanceChanged )
1037 pAppearanceCfg->Commit();
1038 pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
1041 if(bRepaintWindows)
1043 Window* pAppWindow = Application::GetFirstTopLevelWindow();
1045 while(pAppWindow)
1047 pAppWindow->Invalidate();
1048 pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
1052 return bModified;
1055 /*-----------------06.12.96 11.50-------------------
1057 --------------------------------------------------*/
1058 void OfaViewTabPage::Reset( const SfxItemSet& )
1060 SvtMiscOptions aMiscOptions;
1062 if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO )
1063 nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
1064 aIconSizeLB.SelectEntryPos( nSizeLB_InitialSelection );
1065 aIconSizeLB.SaveValue();
1067 if( aMiscOptions.GetSymbolsStyle() != STYLE_SYMBOLS_AUTO )
1068 nStyleLB_InitialSelection = aIconStyleItemId[aMiscOptions.GetCurrentSymbolsStyle()];
1070 aIconStyleLB.SelectEntryPos( nStyleLB_InitialSelection );
1071 aIconStyleLB.SaveValue();
1073 if( m_aSystemFont.IsEnabled() )
1075 SvtAccessibilityOptions aAccessibilityOptions;
1076 m_aSystemFont.Check( aAccessibilityOptions.GetIsSystemFont() );
1079 // Screen Scaling
1080 aWindowSizeMF.SetValue ( pAppearanceCfg->GetScaleFactor() );
1081 // Mouse Snap
1082 aMousePosLB.SelectEntryPos(pAppearanceCfg->GetSnapMode());
1083 aMousePosLB.SaveValue();
1085 // Mouse Snap
1086 aMouseMiddleLB.SelectEntryPos(pAppearanceCfg->GetMiddleMouseButton());
1087 aMouseMiddleLB.SaveValue();
1089 #if defined( UNX )
1090 aFontAntiAliasing.Check( pAppearanceCfg->IsFontAntiAliasing() );
1091 aAAPointLimit.SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
1092 #endif
1094 // WorkingSet
1095 SvtFontOptions aFontOpt;
1096 aFontShowCB.Check( aFontOpt.IsFontWYSIWYGEnabled() );
1097 SvtMenuOptions aMenuOpt;
1098 aMenuIconsLB.SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
1099 aMenuIconsLB.SaveValue();
1100 aFontHistoryCB.Check( aFontOpt.IsFontHistoryEnabled() );
1102 { // #i95644# HW accel (unified to disable mechanism)
1103 if(pCanvasSettings->IsHardwareAccelerationAvailable())
1105 aUseHardwareAccell.Check(pCanvasSettings->IsHardwareAccelerationEnabled());
1107 else
1109 aUseHardwareAccell.Check(false);
1110 aUseHardwareAccell.Disable();
1113 aUseHardwareAccell.SaveValue();
1116 { // #i95644# AntiAliasing
1117 if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
1119 aUseAntiAliase.Check(mpDrawinglayerOpt->IsAntiAliasing());
1121 else
1123 aUseAntiAliase.Check(false);
1124 aUseAntiAliase.Disable();
1127 aUseAntiAliase.SaveValue();
1131 // #i97672# Selection
1132 // check if transparent selection is possible on this system
1133 const bool bTransparentSelectionPossible(
1134 !GetSettings().GetStyleSettings().GetHighContrastMode()
1135 && supportsOperation(OutDevSupport_TransparentRect));
1137 // enter values
1138 if(bTransparentSelectionPossible)
1140 maSelectionCB.Check(mpDrawinglayerOpt->IsTransparentSelection());
1142 else
1144 maSelectionCB.Enable(false);
1147 maSelectionMF.SetValue(mpDrawinglayerOpt->GetTransparentSelectionPercent());
1148 maSelectionMF.Enable(mpDrawinglayerOpt->IsTransparentSelection() && bTransparentSelectionPossible);
1151 #if defined( UNX )
1152 aFontAntiAliasing.SaveValue();
1153 aAAPointLimit.SaveValue();
1154 #endif
1155 aFontShowCB.SaveValue();
1156 aFontHistoryCB.SaveValue();
1158 #if defined( UNX )
1159 LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL );
1160 #endif
1162 /* -----------------22.07.2003 10:33-----------------
1164 --------------------------------------------------*/
1165 struct LanguageConfig_Impl
1167 SvtLanguageOptions aLanguageOptions;
1168 SvtSysLocaleOptions aSysLocaleOptions;
1169 SvtLinguConfig aLinguConfig;
1171 /* -----------------------------23.11.00 13:06--------------------------------
1173 ---------------------------------------------------------------------------*/
1174 static sal_Bool bLanguageCurrentDoc_Impl = sal_False;
1176 // some things we'll need...
1177 static const OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider");
1178 static const OUString sAccessSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess");
1179 static const OUString sAccessUpdSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess");
1180 static const OUString sInstalledLocalesPath = OUString::createFromAscii("org.openoffice.Setup/Office/InstalledLocales");
1181 static OUString sUserLocalePath = OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
1182 //static const OUString sUserLocalePath = OUString::createFromAscii("org.openoffice.Office/Linguistic");
1183 static const OUString sUserLocaleKey = OUString::createFromAscii("UILocale");
1184 static const OUString sSystemLocalePath = OUString::createFromAscii("org.openoffice.System/L10N");
1185 static const OUString sSystemLocaleKey = OUString::createFromAscii("UILocale");
1186 static const OUString sOfficeLocalePath = OUString::createFromAscii("org.openoffice.Office/L10N");
1187 static const OUString sOfficeLocaleKey = OUString::createFromAscii("ooLocale");
1188 static Sequence< OUString > seqInstalledLanguages;
1190 OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSet ) :
1191 SfxTabPage( pParent, CUI_RES( OFA_TP_LANGUAGES ), rSet ),
1192 aUILanguageGB(this, CUI_RES(FL_UI_LANG )),
1193 aLocaleSettingFI(this, CUI_RES(FI_LOCALESETTING)),
1194 aUserInterfaceFT(this, CUI_RES(FT_USERINTERFACE)),
1195 aUserInterfaceLB(this, CUI_RES(LB_USERINTERFACE)),
1196 aLocaleSettingFT(this, CUI_RES(FT_LOCALESETTING)),
1197 aLocaleSettingLB(this, CUI_RES(LB_LOCALESETTING)),
1198 aCurrencyFI( this, CUI_RES(FI_CURRENCY )),
1199 aDecimalSeparatorFT(this, CUI_RES(FT_DECIMALSEPARATOR)),
1200 aDecimalSeparatorCB(this, CUI_RES(CB_DECIMALSEPARATOR)),
1201 aCurrencyFT( this, CUI_RES(FT_CURRENCY )),
1202 aCurrencyLB( this, CUI_RES(LB_CURRENCY )),
1203 aLinguLanguageGB(this, CUI_RES(FL_LINGU_LANG )),
1204 aWesternLanguageFI(this, CUI_RES(FI_WEST_LANG )),
1205 aWesternLanguageFT(this, CUI_RES(FT_WEST_LANG )),
1206 aWesternLanguageLB(this, CUI_RES(LB_WEST_LANG )),
1207 aAsianLanguageFI(this, CUI_RES(FI_ASIAN_LANG )),
1208 aAsianLanguageFT(this, CUI_RES(FT_ASIAN_LANG )),
1209 aAsianLanguageLB(this, CUI_RES(LB_ASIAN_LANG )),
1210 aComplexLanguageFI(this, CUI_RES(FI_COMPLEX_LANG )),
1211 aComplexLanguageFT(this, CUI_RES(FT_COMPLEX_LANG )),
1212 aComplexLanguageLB(this, CUI_RES(LB_COMPLEX_LANG )),
1213 aCurrentDocCB(this, CUI_RES(CB_CURRENT_DOC )),
1214 aEnhancedFL(this, CUI_RES(FL_ENHANCED )),
1215 aAsianSupportFI(this, CUI_RES(FI_ASIANSUPPORT )),
1216 aAsianSupportCB(this, CUI_RES(CB_ASIANSUPPORT )),
1217 aCTLSupportFI(this, CUI_RES(FI_CTLSUPPORT )),
1218 aCTLSupportCB(this, CUI_RES(CB_CTLSUPPORT )),
1219 sDecimalSeparatorLabel(aDecimalSeparatorCB.GetText()),
1220 pLangConfig(new LanguageConfig_Impl)
1222 FreeResource();
1224 // initialize user interface language selection
1225 SvtLanguageTable* pLanguageTable = new SvtLanguageTable;
1226 const String aStr( pLanguageTable->GetString( LANGUAGE_SYSTEM ) );
1228 String aUILang(aStr);
1229 aUILang += String::CreateFromAscii(" - ");
1230 aUILang += pLanguageTable->GetString( Application::GetSettings().GetUILanguage() );
1232 aUserInterfaceLB.InsertEntry(aUILang);
1233 aUserInterfaceLB.SetEntryData(0, 0);
1234 aUserInterfaceLB.SelectEntryPos(0);
1237 OUString sOfficeLocaleValue;
1238 OUString sSystemLocaleValue;
1240 Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
1241 Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
1242 theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
1243 Sequence< Any > theArgs(2);
1244 Reference< XNameAccess > theNameAccess;
1246 // find out which locales are currently installed and add them to the listbox
1247 theArgs[0] = makeAny(NamedValue(OUString::createFromAscii("NodePath"), makeAny(sInstalledLocalesPath)));
1248 theArgs[1] = makeAny(NamedValue(OUString::createFromAscii("reload"), makeAny(sal_True)));
1249 theNameAccess = Reference< XNameAccess > (
1250 theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
1251 seqInstalledLanguages = theNameAccess->getElementNames();
1252 LanguageType aLang = LANGUAGE_DONTKNOW;
1253 for (sal_Int32 i=0; i<seqInstalledLanguages.getLength(); i++)
1255 aLang = MsLangId::convertIsoStringToLanguage(seqInstalledLanguages[i]);
1256 if (aLang != LANGUAGE_DONTKNOW)
1258 //sal_uInt16 p = aUserInterfaceLB.InsertLanguage(aLang);
1259 String aLangStr( pLanguageTable->GetString( aLang ) );
1260 sal_uInt16 p = aUserInterfaceLB.InsertEntry(aLangStr);
1261 aUserInterfaceLB.SetEntryData(p, (void*)(i+1));
1265 // find out whether the user has a specific locale specified
1266 Sequence< Any > theArgs2(1);
1267 theArgs2[0] = makeAny(NamedValue(OUString::createFromAscii("NodePath"), makeAny(sUserLocalePath)));
1268 theNameAccess = Reference< XNameAccess > (
1269 theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
1270 if (theNameAccess->hasByName(sUserLocaleKey))
1271 theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
1272 // select the user specified locale in the listbox
1273 if (m_sUserLocaleValue.getLength() > 0)
1275 sal_Int32 d = 0;
1276 for (sal_uInt16 i=0; i < aUserInterfaceLB.GetEntryCount(); i++)
1278 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(i);
1279 if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1].equals(m_sUserLocaleValue))
1280 aUserInterfaceLB.SelectEntryPos(i);
1285 catch (Exception &e)
1287 // we'll just leave the box in it's default setting and won't
1288 // even give it event handler...
1289 OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
1290 OSL_ENSURE(sal_False, aMsg.getStr());
1293 aWesternLanguageLB.SetLanguageList( LANG_LIST_WESTERN | LANG_LIST_ONLY_KNOWN, sal_True, sal_False, sal_True );
1294 aWesternLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN );
1295 aAsianLanguageLB.SetLanguageList( LANG_LIST_CJK | LANG_LIST_ONLY_KNOWN, sal_True, sal_False, sal_True );
1296 aAsianLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN );
1297 aComplexLanguageLB.SetLanguageList( LANG_LIST_CTL | LANG_LIST_ONLY_KNOWN, sal_True, sal_False, sal_True );
1298 aComplexLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX );
1300 aLocaleSettingLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, sal_False, sal_False, sal_False);
1301 aLocaleSettingLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::WEAK );
1303 const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
1304 const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
1305 // insert SYSTEM entry
1306 String aDefaultCurr(aStr);
1307 aDefaultCurr += String::CreateFromAscii(" - ");
1308 aDefaultCurr += rCurr.GetBankSymbol();
1309 aCurrencyLB.InsertEntry( aDefaultCurr );
1310 // all currencies
1311 String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " " ) );
1312 sal_uInt16 nCurrCount = rCurrTab.Count();
1313 // first entry is SYSTEM, skip it
1314 for ( sal_uInt16 j=1; j < nCurrCount; ++j )
1316 const NfCurrencyEntry* pCurr = rCurrTab[j];
1317 String aStr_( pCurr->GetBankSymbol() );
1318 aStr_ += aTwoSpace;
1319 aStr_ += pCurr->GetSymbol();
1320 aStr_ = ApplyLreOrRleEmbedding( aStr_ );
1321 aStr_ += aTwoSpace;
1322 aStr_ += ApplyLreOrRleEmbedding( pLanguageTable->GetString( pCurr->GetLanguage() ) );
1323 sal_uInt16 nPos = aCurrencyLB.InsertEntry( aStr_ );
1324 aCurrencyLB.SetEntryData( nPos, (void*) pCurr );
1326 delete pLanguageTable;
1328 aLocaleSettingLB.SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
1329 Link aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
1330 aAsianSupportCB.SetClickHdl( aLink );
1331 aCTLSupportCB.SetClickHdl( aLink );
1333 aAsianSupportCB.Check( m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled() );
1334 aAsianSupportCB.SaveValue();
1335 sal_Bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
1336 aAsianSupportCB.Enable(!bReadonly);
1337 aAsianSupportFI.Show(bReadonly);
1338 SupportHdl( &aAsianSupportCB );
1340 aCTLSupportCB.Check( m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled() );
1341 aCTLSupportCB.SaveValue();
1342 bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
1343 aCTLSupportCB.Enable(!bReadonly);
1344 aCTLSupportFI.Show(bReadonly);
1345 SupportHdl( &aCTLSupportCB );
1347 /*-- 23.11.00 13:06:40---------------------------------------------------
1349 -----------------------------------------------------------------------*/
1350 OfaLanguagesTabPage::~OfaLanguagesTabPage()
1352 delete pLangConfig;
1354 /*-- 23.11.00 13:06:40---------------------------------------------------
1356 -----------------------------------------------------------------------*/
1357 SfxTabPage* OfaLanguagesTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1359 return new OfaLanguagesTabPage(pParent, rAttrSet);
1361 /*-- 23.11.00 13:06:41---------------------------------------------------
1363 -----------------------------------------------------------------------*/
1364 LanguageType lcl_LangStringToLangType(const OUString& rLang)
1366 Locale aLocale;
1367 sal_Int32 nSep = rLang.indexOf('-');
1368 if (nSep < 0)
1369 aLocale.Language = rLang;
1370 else
1372 aLocale.Language = rLang.copy(0, nSep);
1373 if (nSep < rLang.getLength())
1374 aLocale.Country = rLang.copy(nSep+1, rLang.getLength() - (nSep+1));
1376 LanguageType eLangType = SvxLocaleToLanguage( aLocale );
1377 return eLangType;
1380 /*-- 23.11.00 13:06:40---------------------------------------------------
1382 -----------------------------------------------------------------------*/
1383 void lcl_UpdateAndDelete(SfxVoidItem* pInvalidItems[], SfxBoolItem* pBoolItems[], sal_uInt16 nCount)
1385 SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
1386 SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
1387 while(pViewFrm)
1389 SfxBindings& rBind = pViewFrm->GetBindings();
1390 for(sal_Int16 i = 0; i < nCount; i++)
1392 if(pCurrentFrm == pViewFrm)
1393 rBind.InvalidateAll(sal_False);
1394 rBind.SetState( *pInvalidItems[i] );
1395 rBind.SetState( *pBoolItems[i] );
1397 pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
1399 for(sal_Int16 i = 0; i < nCount; i++)
1401 delete pInvalidItems[i];
1402 delete pBoolItems[i] ;
1406 sal_Bool OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet )
1408 // lock configuration broadcasters so that we can coordinate the notifications
1409 pLangConfig->aSysLocaleOptions.BlockBroadcasts( sal_True );
1410 pLangConfig->aLanguageOptions.BlockBroadcasts( sal_True );
1411 pLangConfig->aLinguConfig.BlockBroadcasts( sal_True );
1413 if(aCTLSupportCB.IsChecked() &&
1414 (aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked()) ||
1415 (aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos()))
1417 //sequence checking has to be switched on depending on the selected CTL language
1418 LanguageType eCTLLang = aComplexLanguageLB.GetSelectLanguage();
1419 sal_Bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
1420 pLangConfig->aLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
1421 pLangConfig->aLanguageOptions.SetCTLSequenceChecking(bOn);
1422 pLangConfig->aLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
1426 // handle settings for UI Language
1427 // a change of setting needs to bring up a warning message
1428 OUString aLangString;
1429 sal_Int32 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(aUserInterfaceLB.GetSelectEntryPos());
1430 if( d > 0 && seqInstalledLanguages.getLength() > d-1)
1431 aLangString = seqInstalledLanguages[d-1];
1434 if( aUserInterfaceLB.GetSelectEntryPos() > 0)
1435 aLangString = ConvertLanguageToIsoString(aUserInterfaceLB.GetSelectLanguage());
1437 Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
1438 Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
1439 theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
1440 Sequence< Any > theArgs(1);
1441 theArgs[0] = makeAny(sUserLocalePath);
1442 Reference< XPropertySet >xProp(
1443 theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
1444 if ( !m_sUserLocaleValue.equals(aLangString))
1446 // OSL_ENSURE(sal_False, "UserInterface language was changed, restart.");
1447 // write new value
1448 xProp->setPropertyValue(sUserLocaleKey, makeAny(aLangString));
1449 Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
1450 // display info
1451 InfoBox aBox(this, CUI_RES(RID_SVX_MSGBOX_LANGUAGE_RESTART));
1452 aBox.Execute();
1454 // tell quickstarter to stop being a veto listener
1456 Reference< XInitialization > xInit(theMSF->createInstance(
1457 OUString::createFromAscii("com.sun.star.office.Quickstart")), UNO_QUERY);
1458 if (xInit.is())
1460 Sequence< Any > args(3);
1461 args[0] = makeAny(sal_False); // will be ignored
1462 args[1] = makeAny(sal_False); // will be ignored
1463 args[2] = makeAny(sal_False); // disable veto
1464 xInit->initialize(args);
1468 catch (Exception& e)
1470 // we'll just leave the box in it's default setting and won't
1471 // even give it event handler...
1472 OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
1473 OSL_ENSURE(sal_False, aMsg.getStr());
1476 OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1477 LanguageType eOldLocale = (sLang.getLength() ?
1478 lcl_LangStringToLangType( sLang ) : LANGUAGE_SYSTEM);
1479 LanguageType eNewLocale = aLocaleSettingLB.GetSelectLanguage();
1480 if ( eOldLocale != eNewLocale )
1482 // an empty string denotes SYSTEM locale
1483 OUString sNewLang;
1484 if ( eNewLocale != LANGUAGE_SYSTEM )
1486 Locale aLocale;
1487 SvxLanguageToLocale( aLocale, eNewLocale );
1488 sNewLang = aLocale.Language;
1489 if ( aLocale.Country.getLength() > 0 )
1491 sNewLang += C2U("-");
1492 sNewLang += aLocale.Country;
1496 // locale nowadays get to AppSettings via notification
1497 // this will happen after releasing the lock on the ConfigurationBroadcaster at
1498 // the end of this method
1499 pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
1500 rSet.Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, sal_True ) );
1503 if(aDecimalSeparatorCB.GetSavedValue() != aDecimalSeparatorCB.IsChecked())
1504 pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(aDecimalSeparatorCB.IsChecked());
1506 // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default.
1507 OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1508 sal_uInt16 nCurrPos = aCurrencyLB.GetSelectEntryPos();
1509 const NfCurrencyEntry* pCurr = (const NfCurrencyEntry*)
1510 aCurrencyLB.GetEntryData( nCurrPos );
1511 OUString sNewCurr;
1512 if ( pCurr )
1513 sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
1514 pCurr->GetBankSymbol(), pCurr->GetLanguage() );
1515 if ( sOldCurr != sNewCurr )
1516 pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
1518 sal_Bool bRet = sal_False;
1519 SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1520 Reference< XPropertySet > xLinguProp( LinguMgr::GetLinguPropertySet(), UNO_QUERY );
1521 sal_Bool bCurrentDocCBChecked = aCurrentDocCB.IsChecked();
1522 if(aCurrentDocCB.IsEnabled())
1523 bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
1524 sal_Bool bCurrentDocCBChanged = bCurrentDocCBChecked != aCurrentDocCB.GetSavedValue();
1526 sal_Bool bValChanged = aWesternLanguageLB.GetSavedValue() != aWesternLanguageLB.GetSelectEntryPos();
1527 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1529 LanguageType eSelectLang = aWesternLanguageLB.GetSelectLanguage();
1530 if(!bCurrentDocCBChecked)
1532 Any aValue;
1533 Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1534 aValue <<= aLocale;
1535 OUString aPropName( C2U("DefaultLocale") );
1536 pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1537 if (xLinguProp.is())
1538 xLinguProp->setPropertyValue( aPropName, aValue );
1540 if(pCurrentDocShell)
1542 rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN),
1543 SID_ATTR_LANGUAGE));
1544 bRet = sal_True;
1547 bValChanged = aAsianLanguageLB.GetSavedValue() != aAsianLanguageLB.GetSelectEntryPos();
1548 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1550 LanguageType eSelectLang = aAsianLanguageLB.GetSelectLanguage();
1551 if(!bCurrentDocCBChecked)
1553 Any aValue;
1554 Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1555 aValue <<= aLocale;
1556 OUString aPropName( C2U("DefaultLocale_CJK") );
1557 pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1558 if (xLinguProp.is())
1559 xLinguProp->setPropertyValue( aPropName, aValue );
1561 if(pCurrentDocShell)
1563 rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN),
1564 SID_ATTR_CHAR_CJK_LANGUAGE));
1565 bRet = sal_True;
1568 bValChanged = aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos();
1569 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1571 LanguageType eSelectLang = aComplexLanguageLB.GetSelectLanguage();
1572 if(!bCurrentDocCBChecked)
1574 Any aValue;
1575 Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1576 aValue <<= aLocale;
1577 OUString aPropName( C2U("DefaultLocale_CTL") );
1578 pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1579 if (xLinguProp.is())
1580 xLinguProp->setPropertyValue( aPropName, aValue );
1582 if(pCurrentDocShell)
1584 rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX),
1585 SID_ATTR_CHAR_CTL_LANGUAGE));
1586 bRet = sal_True;
1590 if(aAsianSupportCB.GetSavedValue() != aAsianSupportCB.IsChecked() )
1592 sal_Bool bChecked = aAsianSupportCB.IsChecked();
1593 pLangConfig->aLanguageOptions.SetAll(bChecked);
1595 //iterate over all bindings to invalidate vertical text direction
1596 const sal_uInt16 STATE_COUNT = 2;
1598 SfxBoolItem* pBoolItems[STATE_COUNT];
1599 pBoolItems[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE, sal_False);
1600 pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, sal_False);
1602 SfxVoidItem* pInvalidItems[STATE_COUNT];
1603 pInvalidItems[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE);
1604 pInvalidItems[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL);
1606 lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1609 if ( aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked() )
1611 pLangConfig->aLanguageOptions.SetCTLFontEnabled( aCTLSupportCB.IsChecked() );
1613 const sal_uInt16 STATE_COUNT = 1;
1614 SfxBoolItem* pBoolItems[STATE_COUNT];
1615 pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, sal_False);
1616 SfxVoidItem* pInvalidItems[STATE_COUNT];
1617 pInvalidItems[0] = new SfxVoidItem(SID_CTLFONT_STATE);
1618 lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1621 if ( pLangConfig->aSysLocaleOptions.IsModified() )
1622 pLangConfig->aSysLocaleOptions.Commit();
1624 // first release the lock on the ConfigurationBroadcaster for Locale changes
1625 // it seems that our code relies on the fact that before other changes like e.g. currency
1626 // are broadcasted locale changes have been done
1627 pLangConfig->aSysLocaleOptions.BlockBroadcasts( sal_False );
1628 pLangConfig->aLanguageOptions.BlockBroadcasts( sal_False );
1629 pLangConfig->aLinguConfig.BlockBroadcasts( sal_False );
1631 return sal_False;
1633 //-----------------------------------------------------------------------------
1634 void OfaLanguagesTabPage::Reset( const SfxItemSet& rSet )
1636 OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1637 if ( sLang.getLength() )
1638 aLocaleSettingLB.SelectLanguage(lcl_LangStringToLangType(sLang));
1639 else
1640 aLocaleSettingLB.SelectLanguage( LANGUAGE_SYSTEM );
1641 sal_Bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_LOCALE);
1642 aLocaleSettingLB.Enable(!bReadonly);
1643 aLocaleSettingFT.Enable(!bReadonly);
1644 aLocaleSettingFI.Show(bReadonly);
1647 aDecimalSeparatorCB.Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
1648 aDecimalSeparatorCB.SaveValue();
1650 // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
1651 // #i15812# must be done *before* the configured currency is set
1652 // and update the decimal separator used for the given locale
1653 LocaleSettingHdl(&aLocaleSettingLB);
1655 // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
1656 String aAbbrev;
1657 LanguageType eLang;
1658 const NfCurrencyEntry* pCurr = NULL;
1659 sLang = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1660 if ( sLang.getLength() )
1662 SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sLang );
1663 pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
1665 // if pCurr==NULL the SYSTEM entry is selected
1666 sal_uInt16 nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
1667 aCurrencyLB.SelectEntryPos( nPos );
1668 bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY);
1669 aCurrencyLB.Enable(!bReadonly);
1670 aCurrencyFT.Enable(!bReadonly);
1671 aCurrencyFI.Show(bReadonly);
1673 //western/CJK/CLK language
1674 LanguageType eCurLang = LANGUAGE_NONE;
1675 LanguageType eCurLangCJK = LANGUAGE_NONE;
1676 LanguageType eCurLangCTL = LANGUAGE_NONE;
1677 SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1678 //collect the configuration values first
1679 aCurrentDocCB.Enable(sal_False);
1681 Any aWestLang;
1682 Any aCJKLang;
1683 Any aCTLLang;
1686 aWestLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale"));
1687 Locale aLocale;
1688 aWestLang >>= aLocale;
1690 eCurLang = MsLangId::convertLocaleToLanguage( aLocale );
1692 aCJKLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CJK"));
1693 aLocale = Locale();
1694 aCJKLang >>= aLocale;
1695 eCurLangCJK = MsLangId::convertLocaleToLanguage( aLocale );
1697 aCTLLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CTL"));
1698 aLocale = Locale();
1699 aCTLLang >>= aLocale;
1700 eCurLangCTL = MsLangId::convertLocaleToLanguage( aLocale );
1702 catch(Exception&)
1705 //overwrite them by the values provided by the DocShell
1706 if(pCurrentDocShell)
1708 aCurrentDocCB.Enable(sal_True);
1709 aCurrentDocCB.Check(bLanguageCurrentDoc_Impl);
1710 const SfxPoolItem* pLang;
1711 if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_LANGUAGE, sal_False, &pLang))
1713 LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1714 if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang)
1715 eCurLang = eTempCurLang;
1718 if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, sal_False, &pLang))
1720 LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1721 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang)
1722 eCurLangCJK = eTempCurLang;
1725 if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, sal_False, &pLang))
1727 LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1728 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang)
1729 eCurLangCTL = eTempCurLang;
1732 if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
1733 aWesternLanguageLB.SelectLanguage(LANGUAGE_NONE);
1734 else
1735 aWesternLanguageLB.SelectLanguage(eCurLang);
1737 if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
1738 aAsianLanguageLB.SelectLanguage(LANGUAGE_NONE);
1739 else
1740 aAsianLanguageLB.SelectLanguage(eCurLangCJK);
1742 if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
1743 aComplexLanguageLB.SelectLanguage(LANGUAGE_NONE);
1744 else
1745 aComplexLanguageLB.SelectLanguage(eCurLangCTL);
1747 aWesternLanguageLB.SaveValue();
1748 aAsianLanguageLB.SaveValue();
1749 aComplexLanguageLB.SaveValue();
1750 aCurrentDocCB.SaveValue();
1752 sal_Bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale") );
1753 aWesternLanguageFT.Enable( bEnable );
1754 aWesternLanguageLB.Enable( bEnable );
1757 aWesternLanguageFI.Show(!bEnable);
1759 // #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
1760 #if 0
1761 bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK") ) && aAsianSupportCB.IsChecked() );
1762 aAsianLanguageFT.Enable( bEnable );
1763 aAsianLanguageLB.Enable( bEnable );
1765 bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL") ) && aCTLSupportCB.IsChecked() );
1766 aComplexLanguageFT.Enable( bEnable );
1767 aComplexLanguageLB.Enable( bEnable );
1768 #endif
1769 /*---------------------07-05-07--------------------------
1770 check the box "For the current document only"
1771 set the focus to the Western Language box
1772 --------------------------------------------------------*/
1773 const SfxPoolItem* pLang = 0;
1774 if ( SFX_ITEM_SET == rSet.GetItemState(SID_SET_DOCUMENT_LANGUAGE, sal_False, &pLang ) &&( (const SfxBoolItem*)pLang)->GetValue() == sal_True )
1776 aWesternLanguageLB.GrabFocus();
1777 aCurrentDocCB.Enable(sal_True);
1778 aCurrentDocCB.Check(sal_True);
1781 /* -----------------------------20.04.01 15:09--------------------------------
1783 ---------------------------------------------------------------------------*/
1784 IMPL_LINK( OfaLanguagesTabPage, SupportHdl, CheckBox*, pBox )
1786 DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
1788 sal_Bool bCheck = pBox->IsChecked();
1789 if ( &aAsianSupportCB == pBox )
1791 sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK"));
1792 bCheck = ( bCheck && !bReadonly );
1793 aAsianLanguageFT.Enable( bCheck );
1794 aAsianLanguageLB.Enable( bCheck );
1795 aAsianLanguageFI.Show(bReadonly);
1796 if( pBox->IsEnabled() )
1797 m_bOldAsian = bCheck;
1799 else if ( &aCTLSupportCB == pBox )
1801 sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL"));
1802 bCheck = ( bCheck && !bReadonly );
1803 aComplexLanguageFT.Enable( bCheck );
1804 aComplexLanguageLB.Enable( bCheck );
1805 aComplexLanguageFI.Show(bReadonly);
1806 if( pBox->IsEnabled() )
1807 m_bOldCtl = bCheck;
1809 else
1811 DBG_ERRORFILE( "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
1814 return 0;
1817 namespace
1819 void lcl_checkLanguageCheckBox(CheckBox& _rCB,sal_Bool _bNewValue,sal_Bool _bOldValue)
1821 if ( _bNewValue )
1822 _rCB.Check(sal_True);
1823 else
1824 _rCB.Check( _bOldValue );
1825 // #i15082# do not call SaveValue() in running dialog...
1826 // _rCB.SaveValue();
1827 _rCB.Enable( !_bNewValue );
1830 /* -----------------08.06.01 17:56-------------------
1832 --------------------------------------------------*/
1833 IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
1835 LanguageType eLang = pBox->GetSelectLanguage();
1836 sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(eLang);
1837 // first check if CTL must be enabled
1838 // #103299# - if CTL font setting is not readonly
1839 if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT))
1841 bool bIsCTLFixed = (nType & SCRIPTTYPE_COMPLEX) != 0;
1842 lcl_checkLanguageCheckBox(aCTLSupportCB, bIsCTLFixed, m_bOldCtl);
1843 SupportHdl( &aCTLSupportCB );
1845 // second check if CJK must be enabled
1846 // #103299# - if CJK support is not readonly
1847 if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
1849 bool bIsCJKFixed = (nType & SCRIPTTYPE_ASIAN) != 0;
1850 lcl_checkLanguageCheckBox(aAsianSupportCB, bIsCJKFixed, m_bOldAsian);
1851 SupportHdl( &aAsianSupportCB );
1854 sal_uInt16 nPos;
1855 if ( eLang == LANGUAGE_SYSTEM )
1856 nPos = aCurrencyLB.GetEntryPos( (void*) NULL );
1857 else
1859 const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry( eLang );
1860 nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
1862 aCurrencyLB.SelectEntryPos( nPos );
1864 //update the decimal separator key of the related CheckBox
1865 Locale aTempLocale;
1866 SvxLanguageToLocale( aTempLocale, eLang );
1867 LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), aTempLocale );
1868 String sTempLabel(sDecimalSeparatorLabel);
1869 sTempLabel.SearchAndReplaceAscii("%1", aLocaleWrapper.getNumDecimalSep() );
1870 aDecimalSeparatorCB.SetText(sTempLabel);
1872 return 0;