Update ooo320-m1
[ooovba.git] / svx / source / cui / optgdlg.cxx
blobde0e90c9e8fe5acbc85a309e49b37ad8d6fe0d78
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: optgdlg.cxx,v $
10 * $Revision: 1.53.20.2 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
33 #ifdef SVX_DLLIMPLEMENTATION
34 #undef SVX_DLLIMPLEMENTATION
35 #endif
36 #include <svtools/zforlist.hxx>
37 #include <goodies/grfmgr.hxx>
38 #include <svtools/flagitem.hxx>
39 #include <sfx2/dispatch.hxx>
40 #include <svtools/lingucfg.hxx>
41 #include <svtools/szitem.hxx>
42 #include <sfx2/viewsh.hxx>
43 #include <sfx2/viewfrm.hxx>
44 #include <sfx2/imgmgr.hxx>
45 #include <vcl/configsettings.hxx>
46 #include <vcl/msgbox.hxx>
47 #include <vcl/mnemonic.hxx>
48 #include <i18npool/mslangid.hxx>
49 #include <svtools/useroptions.hxx>
50 #include <svtools/cacheoptions.hxx>
51 #include <svtools/fontoptions.hxx>
52 #include <svtools/menuoptions.hxx>
53 #include <svtools/startoptions.hxx>
54 #include <svtools/languageoptions.hxx>
55 #include <svtools/miscopt.hxx>
56 #include <svtools/printwarningoptions.hxx>
57 #include <svtools/syslocaleoptions.hxx>
58 #include <svtools/helpopt.hxx>
59 #include <svtools/accessibilityoptions.hxx>
60 #include <unotools/configitem.hxx>
61 #include <sfx2/objsh.hxx>
62 #include <comphelper/types.hxx>
63 #include <svtools/ctloptions.hxx>
64 #include <svtools/langtab.hxx>
65 #include <unotools/localfilehelper.hxx>
66 #include <unotools/configmgr.hxx>
67 #include "cuioptgenrl.hxx"
68 #include "optpath.hxx"
69 #include "optsave.hxx"
70 #include <svx/optlingu.hxx>
71 #include <svx/xpool.hxx>
72 #include "dlgutil.hxx"
73 #ifndef _SVX_TAB_AREA_HXX
74 #include "cuitabarea.hxx"
75 #endif
76 #ifndef _SVX_DIALOGS_HRC
77 #include <svx/dialogs.hrc>
78 #endif
79 #include "unolingu.hxx"
80 #ifndef _SVX_SVXIDS_HRC
81 #include <svx/svxids.hrc>
82 #endif
83 #include <svx/langitem.hxx>
84 #ifndef _UNOTOOLS_PROCESSFACTORY_HXX
85 #include <comphelper/processfactory.hxx>
86 #endif
87 #include <rtl/ustrbuf.hxx>
90 #include <svx/dialmgr.hxx>
91 #include <svtools/helpopt.hxx>
92 #include <svtools/saveopt.hxx>
94 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
95 #include <com/sun/star/container/XNameAccess.hpp>
96 #include <com/sun/star/container/XNameReplace.hpp>
97 #include <com/sun/star/container/XHierarchicalNameAccess.hpp>
98 #include <com/sun/star/lang/XComponent.hpp>
99 #include <com/sun/star/lang/XInitialization.hpp>
100 #include <com/sun/star/beans/NamedValue.hpp>
101 #include <com/sun/star/beans/XPropertySet.hpp>
102 #include <com/sun/star/util/XChangesBatch.hpp>
103 #include <com/sun/star/uno/Any.hxx>
104 #include <com/sun/star/container/XContentEnumerationAccess.hpp>
105 #include <com/sun/star/container/XSet.hpp>
106 #include <com/sun/star/i18n/ScriptType.hpp>
108 #include <vcl/svapp.hxx>
110 #include "optgdlg.hrc"
111 #include "optgdlg.hxx"
112 #include "ofaitem.hxx"
113 #include <svtools/apearcfg.hxx>
114 #include <svtools/optionsdrawinglayer.hxx>
116 #define CONFIG_LANGUAGES "OfficeLanguages"
118 using namespace ::com::sun::star::uno;
119 using namespace ::com::sun::star::lang;
120 using namespace ::com::sun::star::beans;
121 using namespace ::com::sun::star::container;
122 using namespace ::com::sun::star::util;
123 using namespace ::utl;
124 using ::rtl::OString;
125 using ::rtl::OUString;
127 #define C2U(cChar) OUString::createFromAscii(cChar)
129 #define MAX_PROGRAM_ENTRIES 3
131 // class OfaMiscTabPage --------------------------------------------------
133 int OfaMiscTabPage::DeactivatePage( SfxItemSet* pSet_ )
135 if ( pSet_ )
136 FillItemSet( *pSet_ );
137 return LEAVE_PAGE;
140 namespace
142 ::rtl::OUString impl_SystemFileOpenServiceName()
144 const ::rtl::OUString &rDesktopEnvironment =
145 Application::GetDesktopEnvironment();
147 if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "gnome" ) )
149 #ifdef ENABLE_GTK
150 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.GtkFilePicker" );
151 #else
152 return rtl::OUString();
153 #endif
155 else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde4" ) )
157 #ifdef ENABLE_KDE4
158 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.KDE4FilePicker" );
159 #else
160 return rtl::OUString();
161 #endif
163 else if ( rDesktopEnvironment.equalsIgnoreAsciiCaseAscii( "kde" ) )
165 #ifdef ENABLE_KDE
166 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.KDEFilePicker" );
167 #else
168 return rtl::OUString();
169 #endif
171 #if defined WNT
172 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.SystemFilePicker" );
173 #elif (defined MACOSX && defined QUARTZ)
174 return ::rtl::OUString::createFromAscii( "com.sun.star.ui.dialogs.AquaFilePicker" );
175 #else
176 return rtl::OUString();
177 #endif
180 sal_Bool lcl_HasSystemFilePicker()
182 Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
183 sal_Bool bRet = sal_False;
185 Reference< XContentEnumerationAccess > xEnumAccess( xFactory, UNO_QUERY );
186 Reference< XSet > xSet( xFactory, UNO_QUERY );
188 if ( ! xEnumAccess.is() || ! xSet.is() )
189 return bRet;
193 ::rtl::OUString aFileService = impl_SystemFileOpenServiceName();
194 Reference< XEnumeration > xEnum = xEnumAccess->createContentEnumeration( aFileService );
195 if ( xEnum.is() && xEnum->hasMoreElements() )
196 bRet = sal_True;
199 catch( IllegalArgumentException ) {}
200 catch( ElementExistException ) {}
201 return bRet;
205 // -----------------------------------------------------------------------
207 OfaMiscTabPage::OfaMiscTabPage(Window* pParent, const SfxItemSet& rSet ) :
209 SfxTabPage( pParent, SVX_RES( OFA_TP_MISC ), rSet ),
211 aHelpFL ( this, SVX_RES( FL_HELP ) ),
212 aToolTipsCB ( this, SVX_RES( CB_TOOLTIP ) ),
213 aExtHelpCB ( this, SVX_RES( CB_EXTHELP ) ),
214 aHelpAgentCB ( this, SVX_RES( CB_HELPAGENT ) ),
215 aHelpAgentResetBtn ( this, SVX_RES( PB_HELPAGENT_RESET ) ),
216 aHelpFormatFT ( this, SVX_RES( FT_HELPFORMAT ) ),
217 aHelpFormatLB ( this, SVX_RES( LB_HELPFORMAT ) ),
218 aFileDlgFL ( this, SVX_RES( FL_FILEDLG ) ),
219 aFileDlgROImage ( this, SVX_RES( FI_FILEDLG_RO ) ),
220 aFileDlgCB ( this, SVX_RES( CB_FILEDLG ) ),
221 aODMADlgCB ( this, SVX_RES( CB_ODMADLG ) ),
222 aPrintDlgFL ( this, SVX_RES( FL_PRINTDLG ) ),
223 aPrintDlgCB ( this, SVX_RES( CB_PRINTDLG ) ),
224 aDocStatusFL ( this, SVX_RES( FL_DOCSTATUS ) ),
225 aDocStatusCB ( this, SVX_RES( CB_DOCSTATUS ) ),
226 aTwoFigureFL ( this, SVX_RES( FL_TWOFIGURE ) ),
227 aInterpretFT ( this, SVX_RES( FT_INTERPRET ) ),
228 aYearValueField ( this, SVX_RES( NF_YEARVALUE ) ),
229 aToYearFT ( this, SVX_RES( FT_TOYEAR ) )
232 FreeResource();
234 if (!lcl_HasSystemFilePicker())
236 aFileDlgFL.Hide();
237 aFileDlgCB.Hide();
240 #if ! defined(QUARTZ)
241 aPrintDlgFL.Hide();
242 aPrintDlgCB.Hide();
243 #endif
245 #ifdef WNT
246 aFileDlgCB.SetToggleHdl( LINK( this, OfaMiscTabPage, OnFileDlgToggled ) );
247 #else
249 aODMADlgCB.Hide();
250 // rearrange the following controls
251 Point aNewPos = aDocStatusFL.GetPosPixel();
252 long nDelta = aNewPos.Y() - aODMADlgCB.GetPosPixel().Y();
254 Window* pWins[] =
256 &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
257 &aInterpretFT, &aYearValueField, &aToYearFT
259 Window** pCurrent = pWins;
260 const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
261 for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
263 aNewPos = (*pCurrent)->GetPosPixel();
264 aNewPos.Y() -= nDelta;
265 (*pCurrent)->SetPosPixel( aNewPos );
268 #endif
270 if ( !aFileDlgCB.IsVisible() )
272 // rearrange the following controls
273 Point aNewPos = aDocStatusFL.GetPosPixel();
274 long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
276 Window* pWins[] =
278 &aPrintDlgFL, &aPrintDlgCB, &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
279 &aInterpretFT, &aYearValueField, &aToYearFT
281 Window** pCurrent = pWins;
282 const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
283 for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
285 aNewPos = (*pCurrent)->GetPosPixel();
286 aNewPos.Y() -= nDelta;
287 (*pCurrent)->SetPosPixel( aNewPos );
290 else if ( SvtMiscOptions().IsUseSystemFileDialogReadOnly() )
292 aFileDlgROImage.Show();
293 aFileDlgCB.Disable();
296 if ( aPrintDlgCB.IsVisible() )
298 // rearrange the following controls
299 Point aNewPos = aDocStatusFL.GetPosPixel();
300 long nDelta = aNewPos.Y() - aFileDlgFL.GetPosPixel().Y();
302 Window* pWins[] =
304 &aDocStatusFL, &aDocStatusCB, &aTwoFigureFL,
305 &aInterpretFT, &aYearValueField, &aToYearFT
307 Window** pCurrent = pWins;
308 const sal_Int32 nCount = sizeof( pWins ) / sizeof( pWins[ 0 ] );
309 for ( sal_Int32 i = 0; i < nCount; ++i, ++pCurrent )
311 aNewPos = (*pCurrent)->GetPosPixel();
312 aNewPos.Y() += nDelta;
313 (*pCurrent)->SetPosPixel( aNewPos );
317 // at least the button is as wide as its text
318 long nTxtWidth = aHelpAgentResetBtn.GetTextWidth( aHelpAgentResetBtn.GetText() );
319 Size aBtnSz = aHelpAgentResetBtn.GetSizePixel();
320 if ( aBtnSz.Width() < nTxtWidth )
322 aBtnSz.Width() = nTxtWidth;
323 aHelpAgentResetBtn.SetSizePixel( aBtnSz );
326 aStrDateInfo = aToYearFT.GetText();
327 aYearValueField.SetModifyHdl( LINK( this, OfaMiscTabPage, TwoFigureHdl ) );
328 Link aLink = LINK( this, OfaMiscTabPage, TwoFigureConfigHdl );
329 aYearValueField.SetDownHdl( aLink );
330 aYearValueField.SetUpHdl( aLink );
331 aYearValueField.SetLoseFocusHdl( aLink );
332 aYearValueField.SetFirstHdl( aLink );
333 TwoFigureConfigHdl( &aYearValueField );
335 SetExchangeSupport();
337 aLink = LINK( this, OfaMiscTabPage, HelpCheckHdl_Impl );
338 aToolTipsCB.SetClickHdl( aLink );
339 aHelpAgentCB.SetClickHdl( aLink );
340 aHelpAgentResetBtn.SetClickHdl( LINK( this, OfaMiscTabPage, HelpAgentResetHdl_Impl ) );
342 //fill default names as user data
343 static const char* aHelpFormatNames[] =
345 "Default",
346 "HighContrast1",
347 "HighContrast2",
348 "HighContrastBlack",
349 "HighContrastWhite"
352 for ( USHORT i = 0; i < aHelpFormatLB.GetEntryCount(); i++ )
354 String* pData = new String( String::CreateFromAscii( aHelpFormatNames[i] ) );
355 aHelpFormatLB.SetEntryData( i, pData );
359 #ifdef WNT
360 IMPL_LINK( OfaMiscTabPage, OnFileDlgToggled, CheckBox*, EMPTYARG )
362 aODMADlgCB.Enable( !aFileDlgCB.IsChecked() );
363 return 0;
365 #endif
367 // -----------------------------------------------------------------------
369 OfaMiscTabPage::~OfaMiscTabPage()
371 for(USHORT i = 0; i < aHelpFormatLB.GetEntryCount(); i++)
373 delete static_cast< String* >( aHelpFormatLB.GetEntryData(i) );
377 // -----------------------------------------------------------------------
379 SfxTabPage* OfaMiscTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
381 return new OfaMiscTabPage( pParent, rAttrSet );
384 // -----------------------------------------------------------------------
386 BOOL OfaMiscTabPage::FillItemSet( SfxItemSet& rSet )
388 BOOL bModified = FALSE;
390 SvtHelpOptions aHelpOptions;
391 BOOL bChecked = aToolTipsCB.IsChecked();
392 if ( bChecked != aToolTipsCB.GetSavedValue() )
393 aHelpOptions.SetHelpTips( bChecked );
394 bChecked = ( aExtHelpCB.IsChecked() && aToolTipsCB.IsChecked() );
395 if ( bChecked != aExtHelpCB.GetSavedValue() )
396 aHelpOptions.SetExtendedHelp( bChecked );
397 bChecked = aHelpAgentCB.IsChecked();
398 if ( bChecked != aHelpAgentCB.GetSavedValue() )
399 aHelpOptions.SetHelpAgentAutoStartMode( bChecked );
400 USHORT nHelpFormatPos = aHelpFormatLB.GetSelectEntryPos();
401 if ( nHelpFormatPos != LISTBOX_ENTRY_NOTFOUND &&
402 nHelpFormatPos != aHelpFormatLB.GetSavedValue() )
404 aHelpOptions.SetHelpStyleSheet( *static_cast< String* >( aHelpFormatLB.GetEntryData( nHelpFormatPos ) ) );
407 if ( aFileDlgCB.IsChecked() != aFileDlgCB.GetSavedValue() )
409 SvtMiscOptions aMiscOpt;
410 aMiscOpt.SetUseSystemFileDialog( !aFileDlgCB.IsChecked() );
411 bModified = TRUE;
414 if ( aPrintDlgCB.IsChecked() != aPrintDlgCB.GetSavedValue() )
416 SvtMiscOptions aMiscOpt;
417 aMiscOpt.SetUseSystemPrintDialog( !aPrintDlgCB.IsChecked() );
418 bModified = TRUE;
421 if ( aODMADlgCB.IsChecked() != aODMADlgCB.GetSavedValue() )
423 SvtMiscOptions aMiscOpt;
424 aMiscOpt.SetTryODMADialog( aODMADlgCB.IsChecked() );
425 bModified = TRUE;
428 if ( aDocStatusCB.IsChecked() != aDocStatusCB.GetSavedValue() )
430 SvtPrintWarningOptions aPrintOptions;
431 aPrintOptions.SetModifyDocumentOnPrintingAllowed( aDocStatusCB.IsChecked() );
432 bModified = TRUE;
435 const SfxUInt16Item* pUInt16Item =
436 PTR_CAST( SfxUInt16Item, GetOldItem( rSet, SID_ATTR_YEAR2000 ) );
437 USHORT nNum = (USHORT)aYearValueField.GetText().ToInt32();
438 if ( pUInt16Item && pUInt16Item->GetValue() != nNum )
440 bModified = TRUE;
441 rSet.Put( SfxUInt16Item( SID_ATTR_YEAR2000, nNum ) );
444 return bModified;
447 // -----------------------------------------------------------------------
449 void OfaMiscTabPage::Reset( const SfxItemSet& rSet )
451 SvtHelpOptions aHelpOptions;
452 aToolTipsCB.Check( aHelpOptions.IsHelpTips() );
453 aExtHelpCB.Check( aHelpOptions.IsHelpTips() && aHelpOptions.IsExtendedHelp() );
454 aHelpAgentCB.Check( aHelpOptions.IsHelpAgentAutoStartMode() );
455 String sStyleSheet = aHelpOptions.GetHelpStyleSheet();
456 for ( USHORT i = 0; i < aHelpFormatLB.GetEntryCount(); ++i )
458 if ( *static_cast< String* >( aHelpFormatLB.GetEntryData(i) ) == sStyleSheet )
460 aHelpFormatLB.SelectEntryPos(i);
461 break;
465 aToolTipsCB.SaveValue();
466 aExtHelpCB.SaveValue();
467 aHelpAgentCB.SaveValue();
468 aHelpFormatLB.SaveValue();
469 HelpCheckHdl_Impl( &aHelpAgentCB );
471 SvtMiscOptions aMiscOpt;
472 aFileDlgCB.Check( !aMiscOpt.UseSystemFileDialog() );
473 aFileDlgCB.SaveValue();
474 aPrintDlgCB.Check( !aMiscOpt.UseSystemPrintDialog() );
475 aPrintDlgCB.SaveValue();
477 aODMADlgCB.Check( aMiscOpt.TryODMADialog() );
478 aODMADlgCB.SaveValue();
480 SvtPrintWarningOptions aPrintOptions;
481 aDocStatusCB.Check(aPrintOptions.IsModifyDocumentOnPrintingAllowed());
482 aDocStatusCB.SaveValue();
484 const SfxPoolItem* pItem = NULL;
485 if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_YEAR2000, FALSE, &pItem ) )
487 aYearValueField.SetValue( ((SfxUInt16Item*)pItem)->GetValue() );
488 TwoFigureConfigHdl( &aYearValueField );
490 else
492 aYearValueField.Enable(FALSE);
493 aTwoFigureFL.Enable(FALSE);
494 aInterpretFT.Enable(FALSE);
495 aToYearFT.Enable(FALSE);
499 // -----------------------------------------------------------------------
501 IMPL_LINK( OfaMiscTabPage, TwoFigureHdl, NumericField*, pEd )
503 (void)pEd;
505 String aOutput( aStrDateInfo );
506 String aStr( aYearValueField.GetText() );
507 String sSep( SvtSysLocale().GetLocaleData().getNumThousandSep() );
508 xub_StrLen nIndex = 0;
509 while ((nIndex = aStr.Search( sSep, nIndex)) != STRING_NOTFOUND)
510 aStr.Erase( nIndex, sSep.Len());
511 long nNum = aStr.ToInt32();
512 if ( aStr.Len() != 4 || nNum < aYearValueField.GetMin() || nNum > aYearValueField.GetMax() )
513 aOutput.AppendAscii("????");
514 else
516 nNum += 99;
517 aOutput += String::CreateFromInt32( nNum );
519 aToYearFT.SetText( aOutput );
520 return 0;
523 // -----------------------------------------------------------------------
525 IMPL_LINK( OfaMiscTabPage, TwoFigureConfigHdl, NumericField*, pEd )
527 sal_Int64 nNum = aYearValueField.GetValue();
528 String aOutput( String::CreateFromInt64( nNum ) );
529 aYearValueField.SetText( aOutput );
530 aYearValueField.SetSelection( Selection( 0, aOutput.Len() ) );
531 TwoFigureHdl( pEd );
532 return 0;
535 // -----------------------------------------------------------------------
537 IMPL_LINK( OfaMiscTabPage, HelpCheckHdl_Impl, CheckBox*, EMPTYARG )
539 aExtHelpCB.Enable( aToolTipsCB.IsChecked() );
540 aHelpAgentResetBtn.Enable( aHelpAgentCB.IsChecked() );
541 return 0;
544 // -----------------------------------------------------------------------
546 IMPL_LINK( OfaMiscTabPage, HelpAgentResetHdl_Impl, PushButton*, EMPTYARG )
548 SvtHelpOptions().resetAgentIgnoreURLCounter();
549 return 0;
552 // -----------------------------------------------------------------------
554 // -------------------------------------------------------------------
555 class CanvasSettings
557 public:
558 CanvasSettings();
560 BOOL IsHardwareAccelerationEnabled() const;
561 BOOL IsHardwareAccelerationAvailable() const;
562 void EnabledHardwareAcceleration( BOOL _bEnabled ) const;
564 private:
565 typedef std::vector< std::pair<OUString,Sequence<OUString> > > ServiceVector;
567 Reference<XNameAccess> mxForceFlagNameAccess;
568 ServiceVector maAvailableImplementations;
569 mutable BOOL mbHWAccelAvailable;
570 mutable BOOL mbHWAccelChecked;
573 // -------------------------------------------------------------------
574 CanvasSettings::CanvasSettings() :
575 mxForceFlagNameAccess(),
576 mbHWAccelAvailable(FALSE),
577 mbHWAccelChecked(FALSE)
581 Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
582 Reference<XMultiServiceFactory> xConfigProvider(
583 xFactory->createInstance(
584 OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider")),
585 UNO_QUERY_THROW );
587 Any propValue(
588 makeAny( PropertyValue(
589 OUString::createFromAscii("nodepath"), -1,
590 makeAny( OUString::createFromAscii("/org.openoffice.Office.Canvas") ),
591 PropertyState_DIRECT_VALUE ) ) );
593 mxForceFlagNameAccess.set(
594 xConfigProvider->createInstanceWithArguments(
595 OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess"),
596 Sequence<Any>( &propValue, 1 ) ),
597 UNO_QUERY_THROW );
599 propValue = makeAny(
600 PropertyValue(
601 OUString::createFromAscii("nodepath"), -1,
602 makeAny( OUString::createFromAscii("/org.openoffice.Office.Canvas/CanvasServiceList") ),
603 PropertyState_DIRECT_VALUE ) );
605 Reference<XNameAccess> xNameAccess(
606 xConfigProvider->createInstanceWithArguments(
607 OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess"),
608 Sequence<Any>( &propValue, 1 ) ), UNO_QUERY_THROW );
609 Reference<XHierarchicalNameAccess> xHierarchicalNameAccess(
610 xNameAccess, UNO_QUERY_THROW);
612 Sequence<OUString> serviceNames = xNameAccess->getElementNames();
613 const OUString* pCurr = serviceNames.getConstArray();
614 const OUString* const pEnd = pCurr + serviceNames.getLength();
615 while( pCurr != pEnd )
617 Reference<XNameAccess> xEntryNameAccess(
618 xHierarchicalNameAccess->getByHierarchicalName(*pCurr),
619 UNO_QUERY );
621 if( xEntryNameAccess.is() )
623 Sequence<OUString> preferredImplementations;
624 if( (xEntryNameAccess->getByName( OUString::createFromAscii("PreferredImplementations") ) >>= preferredImplementations) )
625 maAvailableImplementations.push_back( std::make_pair(*pCurr,preferredImplementations) );
628 ++pCurr;
631 catch( Exception& )
636 // -------------------------------------------------------------------
637 BOOL CanvasSettings::IsHardwareAccelerationAvailable() const
639 if( !mbHWAccelChecked )
641 mbHWAccelChecked = true;
643 Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory();
645 // check whether any of the service lists has an
646 // implementation that presents the "HardwareAcceleration" property
647 ServiceVector::const_iterator aCurr=maAvailableImplementations.begin();
648 const ServiceVector::const_iterator aEnd=maAvailableImplementations.end();
649 while( aCurr != aEnd )
651 const OUString* pCurrImpl = aCurr->second.getConstArray();
652 const OUString* const pEndImpl = pCurrImpl + aCurr->second.getLength();
654 while( pCurrImpl != pEndImpl )
656 try
658 Reference<XPropertySet> xPropSet( xFactory->createInstance(
659 pCurrImpl->trim() ),
660 UNO_QUERY_THROW );
661 bool bHasAccel(false);
662 if( (xPropSet->getPropertyValue(OUString::createFromAscii("HardwareAcceleration")) >>= bHasAccel) )
663 if( bHasAccel )
665 mbHWAccelAvailable = true;
666 return mbHWAccelAvailable;
669 catch (Exception &)
672 ++pCurrImpl;
675 ++aCurr;
679 return mbHWAccelAvailable;
682 // -------------------------------------------------------------------
683 BOOL CanvasSettings::IsHardwareAccelerationEnabled() const
685 bool bForceLastEntry(false);
686 if( !mxForceFlagNameAccess.is() )
687 return true;
689 if( !(mxForceFlagNameAccess->getByName( OUString::createFromAscii("ForceSafeServiceImpl") ) >>= bForceLastEntry) )
690 return true;
692 return !bForceLastEntry;
695 // -------------------------------------------------------------------
696 void CanvasSettings::EnabledHardwareAcceleration( BOOL _bEnabled ) const
698 Reference< XNameReplace > xNameReplace(
699 mxForceFlagNameAccess, UNO_QUERY );
701 if( !xNameReplace.is() )
702 return;
704 xNameReplace->replaceByName( OUString::createFromAscii("ForceSafeServiceImpl"),
705 makeAny(!_bEnabled) );
707 Reference< XChangesBatch > xChangesBatch(
708 mxForceFlagNameAccess, UNO_QUERY );
710 if( !xChangesBatch.is() )
711 return;
713 xChangesBatch->commitChanges();
716 // class OfaViewTabPage --------------------------------------------------
718 OfaViewTabPage::OfaViewTabPage(Window* pParent, const SfxItemSet& rSet ) :
720 SfxTabPage( pParent, SVX_RES( OFA_TP_VIEW ), rSet ),
722 aUserInterfaceFL ( this, SVX_RES( FL_USERINTERFACE ) ),
723 aWindowSizeFT ( this, SVX_RES( FT_WINDOWSIZE ) ),
724 aWindowSizeMF ( this, SVX_RES( MF_WINDOWSIZE ) ),
725 aIconSizeStyleFT ( this, SVX_RES( FT_ICONSIZESTYLE ) ),
726 aIconSizeLB ( this, SVX_RES( LB_ICONSIZE ) ),
727 aIconStyleLB ( this, SVX_RES( LB_ICONSTYLE ) ),
728 m_aSystemFont (this, SVX_RES( CB_SYSTEM_FONT ) ),
729 #if defined( UNX )
730 aFontAntiAliasing ( this, SVX_RES( CB_FONTANTIALIASING )),
731 aAAPointLimitLabel ( this, SVX_RES( FT_POINTLIMIT_LABEL )),
732 aAAPointLimit ( this, SVX_RES( NF_AA_POINTLIMIT )),
733 aAAPointLimitUnits ( this, SVX_RES( FT_POINTLIMIT_UNIT )),
734 #endif
735 aMenuFL ( this, SVX_RES( FL_MENU ) ),
736 aMenuIconsFT ( this, SVX_RES( FT_MENU_ICONS )),
737 aMenuIconsLB ( this, SVX_RES( LB_MENU_ICONS )),
738 aFontListsFL ( this, SVX_RES( FL_FONTLISTS) ),
739 aFontShowCB ( this, SVX_RES( CB_FONT_SHOW ) ),
740 aFontHistoryCB ( this, SVX_RES( CB_FONT_HISTORY ) ),
741 aRenderingFL ( this, SVX_RES( FL_RENDERING ) ),
742 aUseHardwareAccell ( this, SVX_RES( CB_USE_HARDACCELL ) ),
743 aUseAntiAliase ( this, SVX_RES( CB_USE_ANTIALIASE ) ),
744 aMouseFL ( this, SVX_RES( FL_MOUSE ) ),
745 aMousePosFT ( this, SVX_RES( FT_MOUSEPOS ) ),
746 aMousePosLB ( this, SVX_RES( LB_MOUSEPOS ) ),
747 aMouseMiddleFT ( this, SVX_RES( FT_MOUSEMIDDLE ) ),
748 aMouseMiddleLB ( this, SVX_RES( LB_MOUSEMIDDLE ) ),
750 // #i97672#
751 maSelectionFL(this, SVX_RES(FL_SELECTION)),
752 maSelectionCB(this, SVX_RES(CB_SELECTION)),
753 maSelectionMF(this, SVX_RES(MF_SELECTION)),
755 nSizeLB_InitialSelection(0),
756 nStyleLB_InitialSelection(0),
757 pAppearanceCfg(new SvtTabAppearanceCfg),
758 pCanvasSettings(new CanvasSettings),
759 mpDrawinglayerOpt(new SvtOptionsDrawinglayer)
761 #if defined( UNX )
762 aFontAntiAliasing.SetToggleHdl( LINK( this, OfaViewTabPage, OnAntialiasingToggled ) );
764 // depending on the size of the text in aAAPointLimitLabel, we slightly re-arrange aAAPointLimit and aAAPointLimitUnits
765 //#110391# if the label has no mnemonic and we are in a CJK version the mnemonic "(X)" will be added which
766 // influences the width calculation
767 MnemonicGenerator aMnemonicGenerator;
768 String sLabel(aAAPointLimitLabel.GetText());
769 aMnemonicGenerator.RegisterMnemonic( sLabel );
770 aMnemonicGenerator.CreateMnemonic( sLabel );
771 sLabel.EraseAllChars('~');
773 sal_Int32 nLabelWidth = aAAPointLimitLabel.GetTextWidth( sLabel );
774 nLabelWidth += 3; // small gap
775 // pixels to move both controls to the left
776 Size aSize = aAAPointLimitLabel.GetSizePixel();
777 sal_Int32 nMoveLeft = aSize.Width() - nLabelWidth;
778 // resize the first label
779 aSize.Width() = nLabelWidth;
780 aAAPointLimitLabel.SetSizePixel( aSize );
782 // move the numeric field
783 Point aPos( aAAPointLimit.GetPosPixel() );
784 aPos.X() -= nMoveLeft;
785 aAAPointLimit.SetPosPixel( aPos );
787 // move (and resize) the units FixedText
788 aPos = ( aAAPointLimitUnits.GetPosPixel() );
789 aPos.X() -= nMoveLeft;
790 aSize = aAAPointLimitUnits.GetSizePixel();
791 aSize.Width() += nMoveLeft;
792 aAAPointLimitUnits.SetPosSizePixel( aPos, aSize );
793 #else
794 // on this platform, we do not have the anti aliasing options - move the other checkboxes accordingly
795 // (in the resource, the coordinates are calculated for the AA options beeing present)
796 Control* pMiscOptions[] =
798 &aMenuFL, &aMenuIconsFT, &aMenuIconsLB,
799 &aFontListsFL, &aFontShowCB, &aFontHistoryCB
802 // temporaryly create the checkbox for the anti aliasing (we need to to determine it's pos)
803 CheckBox* pFontAntiAliasing = new CheckBox( this, SVX_RES( CB_FONTANTIALIASING ) );
804 sal_Int32 nMoveUp = aMenuFL.GetPosPixel().Y() - pFontAntiAliasing->GetPosPixel().Y();
805 DELETEZ( pFontAntiAliasing );
807 Point aPos;
808 for ( sal_Int32 i = 0; i < sizeof( pMiscOptions ) / sizeof( pMiscOptions[0] ); ++i )
810 aPos = pMiscOptions[i]->GetPosPixel( );
811 aPos.Y() -= nMoveUp;
812 pMiscOptions[i]->SetPosPixel( aPos );
815 #endif
817 // #i97672#
818 maSelectionCB.SetToggleHdl( LINK( this, OfaViewTabPage, OnSelectionToggled ) );
820 FreeResource();
822 if( ! Application::ValidateSystemFont() )
824 m_aSystemFont.Check( FALSE );
825 m_aSystemFont.Enable( FALSE );
828 const StyleSettings& aStyleSettings = Application::GetSettings().GetStyleSettings();
830 // remove non-installed icon themes
831 if( aIconStyleLB.GetEntryCount() == STYLE_SYMBOLS_THEMES_MAX )
833 // do not check 0th item == auto; it is not a real theme
834 aIconStyleItemId[0] = 0;
835 ULONG nItem = 1;
836 for ( ULONG n=0; ++n < STYLE_SYMBOLS_THEMES_MAX; )
838 if ( aStyleSettings.CheckSymbolStyle( n ) )
840 // existing style => save the item id
841 aIconStyleItemId[n] = nItem++;
843 else
845 // non-existing style => remove item;
846 aIconStyleLB.RemoveEntry( nItem );
847 aIconStyleItemId[n] = 0;
853 // add real theme name to 'auto' theme, e.g. 'auto' => 'auto (classic)'
854 if( aIconStyleLB.GetEntryCount() > 1 )
856 ::rtl::OUString aAutoStr( aIconStyleLB.GetEntry( 0 ) );
858 aAutoStr += ::rtl::OUString::createFromAscii( " (" );
860 ULONG nAutoStyle = aStyleSettings.GetAutoSymbolsStyle();
861 if ( aIconStyleItemId[nAutoStyle] )
862 aAutoStr += aIconStyleLB.GetEntry( aIconStyleItemId[nAutoStyle] );
864 aIconStyleLB.RemoveEntry( 0 );
865 aIconStyleLB.InsertEntry( aAutoStr += ::rtl::OUString::createFromAscii( ")" ), 0 );
866 // separate auto and other icon themes
867 aIconStyleLB.SetSeparatorPos( 0 );
871 OfaViewTabPage::~OfaViewTabPage()
873 delete mpDrawinglayerOpt;
874 delete pCanvasSettings;
875 delete pAppearanceCfg;
878 #if defined( UNX )
879 //--- 20.08.01 10:16:12 ---------------------------------------------------
880 IMPL_LINK( OfaViewTabPage, OnAntialiasingToggled, void*, NOTINTERESTEDIN )
882 (void)NOTINTERESTEDIN;
884 sal_Bool bAAEnabled = aFontAntiAliasing.IsChecked();
886 aAAPointLimitLabel.Enable( bAAEnabled );
887 aAAPointLimit.Enable( bAAEnabled );
888 aAAPointLimitUnits.Enable( bAAEnabled );
890 return 0L;
892 #endif
894 // #i97672#
895 IMPL_LINK( OfaViewTabPage, OnSelectionToggled, void*, NOTINTERESTEDIN )
897 (void)NOTINTERESTEDIN;
898 const bool bSelectionEnabled(maSelectionCB.IsChecked());
899 maSelectionMF.Enable(bSelectionEnabled);
900 return 0;
903 /*-----------------06.12.96 11.50-------------------
905 --------------------------------------------------*/
907 SfxTabPage* OfaViewTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
909 return new OfaViewTabPage(pParent, rAttrSet);
912 /*-----------------06.12.96 11.50-------------------
914 --------------------------------------------------*/
916 BOOL OfaViewTabPage::FillItemSet( SfxItemSet& )
918 SvtFontOptions aFontOpt;
919 SvtMenuOptions aMenuOpt;
920 SvtStartOptions aStartOpt;
922 BOOL bModified = FALSE;
923 BOOL bMenuOptModified = FALSE;
924 bool bRepaintWindows(false);
926 SvtMiscOptions aMiscOptions;
927 UINT16 nSizeLB_NewSelection = aIconSizeLB.GetSelectEntryPos();
928 if( nSizeLB_InitialSelection != nSizeLB_NewSelection )
930 // from now on it's modified, even if via auto setting the same size was set as now selected in the LB
931 sal_Int16 eSet = SFX_SYMBOLS_SIZE_AUTO;
932 switch( nSizeLB_NewSelection )
934 case 0: eSet = SFX_SYMBOLS_SIZE_AUTO; break;
935 case 1: eSet = SFX_SYMBOLS_SIZE_SMALL; break;
936 case 2: eSet = SFX_SYMBOLS_SIZE_LARGE; break;
937 default:
938 DBG_ERROR( "OfaViewTabPage::FillItemSet(): This state of aIconSizeLB should not be possible!" );
940 aMiscOptions.SetSymbolsSize( eSet );
943 UINT16 nStyleLB_NewSelection = aIconStyleLB.GetSelectEntryPos();
944 if( nStyleLB_InitialSelection != nStyleLB_NewSelection )
946 // find the style name in the aIconStyleItemId table
947 // items from the non-installed icon themes were removed
948 for ( ULONG n=0; n < STYLE_SYMBOLS_THEMES_MAX; n++ )
949 if ( aIconStyleItemId[n] == nStyleLB_NewSelection )
951 aMiscOptions.SetSymbolsStyle( n );
952 n = STYLE_SYMBOLS_THEMES_MAX;
956 BOOL bAppearanceChanged = FALSE;
958 // Screen Scaling
959 UINT16 nOldScale = pAppearanceCfg->GetScaleFactor();
960 UINT16 nNewScale = (UINT16)aWindowSizeMF.GetValue();
962 if ( nNewScale != nOldScale )
964 pAppearanceCfg->SetScaleFactor(nNewScale);
965 bAppearanceChanged = TRUE;
968 // Mouse Snap Mode
969 short eOldSnap = pAppearanceCfg->GetSnapMode();
970 short eNewSnap = aMousePosLB.GetSelectEntryPos();
971 if(eNewSnap > 2)
972 eNewSnap = 2;
974 if ( eNewSnap != eOldSnap )
976 pAppearanceCfg->SetSnapMode(eNewSnap );
977 bAppearanceChanged = TRUE;
980 // Middle Mouse Button
981 short eOldMiddleMouse = pAppearanceCfg->GetMiddleMouseButton();
982 short eNewMiddleMouse = aMouseMiddleLB.GetSelectEntryPos();
983 if(eNewMiddleMouse > 2)
984 eNewMiddleMouse = 2;
986 if ( eNewMiddleMouse != eOldMiddleMouse )
988 pAppearanceCfg->SetMiddleMouseButton( eNewMiddleMouse );
989 bAppearanceChanged = TRUE;
992 #if defined( UNX )
993 if ( aFontAntiAliasing.IsChecked() != aFontAntiAliasing.GetSavedValue() )
995 pAppearanceCfg->SetFontAntiAliasing( aFontAntiAliasing.IsChecked() );
996 bAppearanceChanged = TRUE;
999 if ( aAAPointLimit.GetValue() != aAAPointLimit.GetSavedValue().ToInt32() )
1001 pAppearanceCfg->SetFontAntialiasingMinPixelHeight( aAAPointLimit.GetValue() );
1002 bAppearanceChanged = TRUE;
1004 #endif
1006 if ( aFontShowCB.IsChecked() != aFontShowCB.GetSavedValue() )
1008 aFontOpt.EnableFontWYSIWYG( aFontShowCB.IsChecked() );
1009 bModified = TRUE;
1012 if(aMenuIconsLB.GetSelectEntryPos() != aMenuIconsLB.GetSavedValue())
1014 aMenuOpt.SetMenuIconsState( aMenuIconsLB.GetSelectEntryPos() == 0 ? 2 : aMenuIconsLB.GetSelectEntryPos() - 1);
1015 bModified = TRUE;
1016 bMenuOptModified = TRUE;
1017 bAppearanceChanged = TRUE;
1020 if ( aFontHistoryCB.IsChecked() != aFontHistoryCB.GetSavedValue() )
1022 aFontOpt.EnableFontHistory( aFontHistoryCB.IsChecked() );
1023 bModified = TRUE;
1026 // #i95644# if disabled, do not use value, see in ::Reset()
1027 if(aUseHardwareAccell.IsEnabled())
1029 if(aUseHardwareAccell.IsChecked() != aUseHardwareAccell.GetSavedValue())
1031 pCanvasSettings->EnabledHardwareAcceleration(aUseHardwareAccell.IsChecked());
1032 bModified = TRUE;
1036 // #i95644# if disabled, do not use value, see in ::Reset()
1037 if(aUseAntiAliase.IsEnabled())
1039 if(aUseAntiAliase.IsChecked() != mpDrawinglayerOpt->IsAntiAliasing())
1041 mpDrawinglayerOpt->SetAntiAliasing(aUseAntiAliase.IsChecked());
1042 bModified = TRUE;
1043 bRepaintWindows = true;
1047 // #i97672#
1048 if(maSelectionCB.IsEnabled())
1050 const bool bNewSelection(maSelectionCB.IsChecked());
1051 const sal_uInt16 nNewTransparence((sal_uInt16)maSelectionMF.GetValue());
1053 if(bNewSelection != (bool)mpDrawinglayerOpt->IsTransparentSelection())
1055 mpDrawinglayerOpt->SetTransparentSelection(maSelectionCB.IsChecked());
1056 bModified = TRUE;
1057 bRepaintWindows = true;
1060 // #i104150# even read the value when maSelectionMF is disabled; it may have been
1061 // modified by enabling-modify-disabling by the user
1062 if(nNewTransparence != mpDrawinglayerOpt->GetTransparentSelectionPercent())
1064 mpDrawinglayerOpt->SetTransparentSelectionPercent(nNewTransparence);
1065 bModified = TRUE;
1066 bRepaintWindows = true;
1070 SvtAccessibilityOptions aAccessibilityOptions;
1071 if( aAccessibilityOptions.GetIsSystemFont() != m_aSystemFont.IsChecked() &&
1072 m_aSystemFont.IsEnabled() )
1074 aAccessibilityOptions.SetIsSystemFont( m_aSystemFont.IsChecked() );
1075 bModified = TRUE;
1076 bMenuOptModified = TRUE;
1079 if( bMenuOptModified )
1081 // Set changed settings to the application instance
1082 AllSettings aAllSettings = Application::GetSettings();
1083 StyleSettings aStyleSettings = aAllSettings.GetStyleSettings();
1084 if( m_aSystemFont.IsEnabled() )
1085 aStyleSettings.SetUseSystemUIFonts( m_aSystemFont.IsChecked() );
1086 aAllSettings.SetStyleSettings(aStyleSettings);
1087 Application::MergeSystemSettings( aAllSettings );
1088 Application::SetSettings(aAllSettings);
1091 if ( bAppearanceChanged )
1093 pAppearanceCfg->Commit();
1094 pAppearanceCfg->SetApplicationDefaults ( GetpApp() );
1097 if(bRepaintWindows)
1099 Window* pAppWindow = Application::GetFirstTopLevelWindow();
1101 while(pAppWindow)
1103 pAppWindow->Invalidate();
1104 pAppWindow = Application::GetNextTopLevelWindow(pAppWindow);
1108 return bModified;
1111 /*-----------------06.12.96 11.50-------------------
1113 --------------------------------------------------*/
1114 void OfaViewTabPage::Reset( const SfxItemSet& )
1116 SvtMiscOptions aMiscOptions;
1118 if( aMiscOptions.GetSymbolsSize() != SFX_SYMBOLS_SIZE_AUTO )
1119 nSizeLB_InitialSelection = ( aMiscOptions.AreCurrentSymbolsLarge() )? 2 : 1;
1120 aIconSizeLB.SelectEntryPos( nSizeLB_InitialSelection );
1121 aIconSizeLB.SaveValue();
1123 if( aMiscOptions.GetSymbolsStyle() != SFX_SYMBOLS_STYLE_AUTO )
1124 nStyleLB_InitialSelection = aIconStyleItemId[aMiscOptions.GetCurrentSymbolsStyle()];
1125 aIconStyleLB.SelectEntryPos( nStyleLB_InitialSelection );
1126 aIconStyleLB.SaveValue();
1128 if( m_aSystemFont.IsEnabled() )
1130 SvtAccessibilityOptions aAccessibilityOptions;
1131 m_aSystemFont.Check( aAccessibilityOptions.GetIsSystemFont() );
1134 // Screen Scaling
1135 aWindowSizeMF.SetValue ( pAppearanceCfg->GetScaleFactor() );
1136 // Mouse Snap
1137 aMousePosLB.SelectEntryPos(pAppearanceCfg->GetSnapMode());
1138 aMousePosLB.SaveValue();
1140 // Mouse Snap
1141 aMouseMiddleLB.SelectEntryPos(pAppearanceCfg->GetMiddleMouseButton());
1142 aMouseMiddleLB.SaveValue();
1144 #if defined( UNX )
1145 aFontAntiAliasing.Check( pAppearanceCfg->IsFontAntiAliasing() );
1146 aAAPointLimit.SetValue( pAppearanceCfg->GetFontAntialiasingMinPixelHeight() );
1147 #endif
1149 // WorkingSet
1150 SvtFontOptions aFontOpt;
1151 aFontShowCB.Check( aFontOpt.IsFontWYSIWYGEnabled() );
1152 SvtMenuOptions aMenuOpt;
1153 aMenuIconsLB.SelectEntryPos(aMenuOpt.GetMenuIconsState() == 2 ? 0 : aMenuOpt.GetMenuIconsState() + 1);
1154 aMenuIconsLB.SaveValue();
1155 aFontHistoryCB.Check( aFontOpt.IsFontHistoryEnabled() );
1157 { // #i95644# HW accel (unified to disable mechanism)
1158 if(pCanvasSettings->IsHardwareAccelerationAvailable())
1160 aUseHardwareAccell.Check(pCanvasSettings->IsHardwareAccelerationEnabled());
1162 else
1164 aUseHardwareAccell.Check(false);
1165 aUseHardwareAccell.Disable();
1168 aUseHardwareAccell.SaveValue();
1171 { // #i95644# AntiAliasing
1172 if(mpDrawinglayerOpt->IsAAPossibleOnThisSystem())
1174 aUseAntiAliase.Check(mpDrawinglayerOpt->IsAntiAliasing());
1176 else
1178 aUseAntiAliase.Check(false);
1179 aUseAntiAliase.Disable();
1182 aUseAntiAliase.SaveValue();
1186 // #i97672# Selection
1187 // check if transparent selection is possible on this system
1188 const bool bTransparentSelectionPossible(
1189 !GetSettings().GetStyleSettings().GetHighContrastMode()
1190 && supportsOperation(OutDevSupport_TransparentRect));
1192 // enter values
1193 if(bTransparentSelectionPossible)
1195 maSelectionCB.Check(mpDrawinglayerOpt->IsTransparentSelection());
1197 else
1199 maSelectionCB.Enable(false);
1202 maSelectionMF.SetValue(mpDrawinglayerOpt->GetTransparentSelectionPercent());
1203 maSelectionMF.Enable(mpDrawinglayerOpt->IsTransparentSelection() && bTransparentSelectionPossible);
1206 #if defined( UNX )
1207 aFontAntiAliasing.SaveValue();
1208 aAAPointLimit.SaveValue();
1209 #endif
1210 aFontShowCB.SaveValue();
1211 aFontHistoryCB.SaveValue();
1213 #if defined( UNX )
1214 LINK( this, OfaViewTabPage, OnAntialiasingToggled ).Call( NULL );
1215 #endif
1217 /* -----------------------------23.11.00 14:55--------------------------------
1219 ---------------------------------------------------------------------------*/
1220 class LangConfigItem_Impl : public ConfigItem
1222 Any aValue;
1223 OUString aPropertyName;
1224 public:
1225 LangConfigItem_Impl(const OUString& rTree, const OUString& rProperty);
1226 ~LangConfigItem_Impl();
1228 virtual void Commit();
1230 const Any& GetValue() const {return aValue;}
1231 void SetValue(Any& rValue) {aValue = rValue; SetModified();}
1233 /* -----------------------------23.11.00 15:06--------------------------------
1235 ---------------------------------------------------------------------------*/
1236 LangConfigItem_Impl::LangConfigItem_Impl(
1237 const OUString& rTree, const OUString& rProperty) :
1238 ConfigItem(rTree),
1239 aPropertyName(rProperty)
1241 Sequence<OUString> aNames(1);
1242 aNames.getArray()[0] = aPropertyName;
1243 Sequence<Any> aValues = GetProperties(aNames);
1244 aValue = aValues.getConstArray()[0];
1246 /* -----------------------------23.11.00 15:06--------------------------------
1248 ---------------------------------------------------------------------------*/
1249 LangConfigItem_Impl::~LangConfigItem_Impl()
1251 /* -----------------------------23.11.00 15:10--------------------------------
1253 ---------------------------------------------------------------------------*/
1254 void LangConfigItem_Impl::Commit()
1256 Sequence<OUString> aNames(1);
1257 aNames.getArray()[0] = aPropertyName;
1258 Sequence<Any> aValues(1);
1259 aValues.getArray()[0] = aValue;
1260 PutProperties(aNames, aValues);
1262 /* -----------------22.07.2003 10:33-----------------
1264 --------------------------------------------------*/
1265 struct LanguageConfig_Impl
1267 SvtLanguageOptions aLanguageOptions;
1268 SvtSysLocaleOptions aSysLocaleOptions;
1269 SvtLinguConfig aLinguConfig;
1271 /* -----------------------------23.11.00 13:06--------------------------------
1273 ---------------------------------------------------------------------------*/
1274 static sal_Bool bLanguageCurrentDoc_Impl = sal_False;
1276 // some things we'll need...
1277 static const OUString sConfigSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationProvider");
1278 static const OUString sAccessSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationAccess");
1279 static const OUString sAccessUpdSrvc = OUString::createFromAscii("com.sun.star.configuration.ConfigurationUpdateAccess");
1280 static const OUString sInstalledLocalesPath = OUString::createFromAscii("org.openoffice.Setup/Office/InstalledLocales");
1281 static OUString sUserLocalePath = OUString::createFromAscii("org.openoffice.Office.Linguistic/General");
1282 //static const OUString sUserLocalePath = OUString::createFromAscii("org.openoffice.Office/Linguistic");
1283 static const OUString sUserLocaleKey = OUString::createFromAscii("UILocale");
1284 static const OUString sSystemLocalePath = OUString::createFromAscii("org.openoffice.System/L10N");
1285 static const OUString sSystemLocaleKey = OUString::createFromAscii("UILocale");
1286 static const OUString sOfficeLocalePath = OUString::createFromAscii("org.openoffice.Office/L10N");
1287 static const OUString sOfficeLocaleKey = OUString::createFromAscii("ooLocale");
1288 static Sequence< OUString > seqInstalledLanguages;
1290 OfaLanguagesTabPage::OfaLanguagesTabPage( Window* pParent, const SfxItemSet& rSet ) :
1291 SfxTabPage( pParent, SVX_RES( OFA_TP_LANGUAGES ), rSet ),
1292 aUILanguageGB(this, SVX_RES(FL_UI_LANG )),
1293 aLocaleSettingFI(this, SVX_RES(FI_LOCALESETTING)),
1294 aUserInterfaceFT(this, SVX_RES(FT_USERINTERFACE)),
1295 aUserInterfaceLB(this, SVX_RES(LB_USERINTERFACE)),
1296 aLocaleSettingFT(this, SVX_RES(FT_LOCALESETTING)),
1297 aLocaleSettingLB(this, SVX_RES(LB_LOCALESETTING)),
1298 aCurrencyFI( this, SVX_RES(FI_CURRENCY )),
1299 aDecimalSeparatorFT(this, SVX_RES(FT_DECIMALSEPARATOR)),
1300 aDecimalSeparatorCB(this, SVX_RES(CB_DECIMALSEPARATOR)),
1301 aCurrencyFT( this, SVX_RES(FT_CURRENCY )),
1302 aCurrencyLB( this, SVX_RES(LB_CURRENCY )),
1303 aLinguLanguageGB(this, SVX_RES(FL_LINGU_LANG )),
1304 aWesternLanguageFI(this, SVX_RES(FI_WEST_LANG )),
1305 aWesternLanguageFT(this, SVX_RES(FT_WEST_LANG )),
1306 aWesternLanguageLB(this, SVX_RES(LB_WEST_LANG )),
1307 aAsianLanguageFI(this, SVX_RES(FI_ASIAN_LANG )),
1308 aAsianLanguageFT(this, SVX_RES(FT_ASIAN_LANG )),
1309 aAsianLanguageLB(this, SVX_RES(LB_ASIAN_LANG )),
1310 aComplexLanguageFI(this, SVX_RES(FI_COMPLEX_LANG )),
1311 aComplexLanguageFT(this, SVX_RES(FT_COMPLEX_LANG )),
1312 aComplexLanguageLB(this, SVX_RES(LB_COMPLEX_LANG )),
1313 aCurrentDocCB(this, SVX_RES(CB_CURRENT_DOC )),
1314 aEnhancedFL(this, SVX_RES(FL_ENHANCED )),
1315 aAsianSupportFI(this, SVX_RES(FI_ASIANSUPPORT )),
1316 aAsianSupportCB(this, SVX_RES(CB_ASIANSUPPORT )),
1317 aCTLSupportFI(this, SVX_RES(FI_CTLSUPPORT )),
1318 aCTLSupportCB(this, SVX_RES(CB_CTLSUPPORT )),
1319 sDecimalSeparatorLabel(aDecimalSeparatorCB.GetText()),
1320 pLangConfig(new LanguageConfig_Impl)
1322 FreeResource();
1324 // initialize user interface language selection
1325 SvtLanguageTable* pLanguageTable = new SvtLanguageTable;
1326 const String aStr( pLanguageTable->GetString( LANGUAGE_SYSTEM ) );
1328 String aUILang(aStr);
1329 aUILang += String::CreateFromAscii(" - ");
1330 aUILang += pLanguageTable->GetString( Application::GetSettings().GetUILanguage() );
1332 aUserInterfaceLB.InsertEntry(aUILang);
1333 aUserInterfaceLB.SetEntryData(0, 0);
1334 aUserInterfaceLB.SelectEntryPos(0);
1337 OUString sOfficeLocaleValue;
1338 OUString sSystemLocaleValue;
1340 Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
1341 Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
1342 theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
1343 Sequence< Any > theArgs(2);
1344 Reference< XNameAccess > theNameAccess;
1346 // find out which locales are currently installed and add them to the listbox
1347 theArgs[0] = makeAny(NamedValue(OUString::createFromAscii("NodePath"), makeAny(sInstalledLocalesPath)));
1348 theArgs[1] = makeAny(NamedValue(OUString::createFromAscii("reload"), makeAny(sal_True)));
1349 theNameAccess = Reference< XNameAccess > (
1350 theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs ), UNO_QUERY_THROW );
1351 seqInstalledLanguages = theNameAccess->getElementNames();
1352 LanguageType aLang = LANGUAGE_DONTKNOW;
1353 for (sal_Int32 i=0; i<seqInstalledLanguages.getLength(); i++)
1355 aLang = MsLangId::convertIsoStringToLanguage(seqInstalledLanguages[i]);
1356 if (aLang != LANGUAGE_DONTKNOW)
1358 //USHORT p = aUserInterfaceLB.InsertLanguage(aLang);
1359 String aLangStr( pLanguageTable->GetString( aLang ) );
1360 USHORT p = aUserInterfaceLB.InsertEntry(aLangStr);
1361 aUserInterfaceLB.SetEntryData(p, (void*)(i+1));
1365 // find out whether the user has a specific locale specified
1366 Sequence< Any > theArgs2(1);
1367 theArgs2[0] = makeAny(NamedValue(OUString::createFromAscii("NodePath"), makeAny(sUserLocalePath)));
1368 theNameAccess = Reference< XNameAccess > (
1369 theConfigProvider->createInstanceWithArguments(sAccessSrvc, theArgs2 ), UNO_QUERY_THROW );
1370 if (theNameAccess->hasByName(sUserLocaleKey))
1371 theNameAccess->getByName(sUserLocaleKey) >>= m_sUserLocaleValue;
1372 // select the user specified locale in the listbox
1373 if (m_sUserLocaleValue.getLength() > 0)
1375 sal_Int32 d = 0;
1376 for (USHORT i=0; i < aUserInterfaceLB.GetEntryCount(); i++)
1378 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(i);
1379 if ( d > 0 && seqInstalledLanguages.getLength() > d-1 && seqInstalledLanguages[d-1].equals(m_sUserLocaleValue))
1380 aUserInterfaceLB.SelectEntryPos(i);
1385 catch (Exception &e)
1387 // we'll just leave the box in it's default setting and won't
1388 // even give it event handler...
1389 OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
1390 OSL_ENSURE(sal_False, aMsg.getStr());
1393 aWesternLanguageLB.SetLanguageList( LANG_LIST_WESTERN | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE );
1394 aWesternLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::LATIN );
1395 aAsianLanguageLB.SetLanguageList( LANG_LIST_CJK | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE );
1396 aAsianLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::ASIAN );
1397 aComplexLanguageLB.SetLanguageList( LANG_LIST_CTL | LANG_LIST_ONLY_KNOWN, TRUE, FALSE, TRUE );
1398 aComplexLanguageLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::COMPLEX );
1400 aLocaleSettingLB.SetLanguageList( LANG_LIST_ALL | LANG_LIST_ONLY_KNOWN, FALSE, FALSE, FALSE);
1401 aLocaleSettingLB.InsertDefaultLanguage( ::com::sun::star::i18n::ScriptType::WEAK );
1403 const NfCurrencyTable& rCurrTab = SvNumberFormatter::GetTheCurrencyTable();
1404 const NfCurrencyEntry& rCurr = SvNumberFormatter::GetCurrencyEntry( LANGUAGE_SYSTEM );
1405 // insert SYSTEM entry
1406 String aDefaultCurr(aStr);
1407 aDefaultCurr += String::CreateFromAscii(" - ");
1408 aDefaultCurr += rCurr.GetBankSymbol();
1409 aCurrencyLB.InsertEntry( aDefaultCurr );
1410 // all currencies
1411 String aTwoSpace( RTL_CONSTASCII_USTRINGPARAM( " " ) );
1412 USHORT nCurrCount = rCurrTab.Count();
1413 // first entry is SYSTEM, skip it
1414 for ( USHORT j=1; j < nCurrCount; ++j )
1416 const NfCurrencyEntry* pCurr = rCurrTab[j];
1417 String aStr_( pCurr->GetBankSymbol() );
1418 aStr_ += aTwoSpace;
1419 aStr_ += pCurr->GetSymbol();
1420 aStr_ = ApplyLreOrRleEmbedding( aStr_ );
1421 aStr_ += aTwoSpace;
1422 aStr_ += ApplyLreOrRleEmbedding( pLanguageTable->GetString( pCurr->GetLanguage() ) );
1423 USHORT nPos = aCurrencyLB.InsertEntry( aStr_ );
1424 aCurrencyLB.SetEntryData( nPos, (void*) pCurr );
1426 delete pLanguageTable;
1428 aLocaleSettingLB.SetSelectHdl( LINK( this, OfaLanguagesTabPage, LocaleSettingHdl ) );
1429 Link aLink( LINK( this, OfaLanguagesTabPage, SupportHdl ) );
1430 aAsianSupportCB.SetClickHdl( aLink );
1431 aCTLSupportCB.SetClickHdl( aLink );
1433 aAsianSupportCB.Check( m_bOldAsian = pLangConfig->aLanguageOptions.IsAnyEnabled() );
1434 aAsianSupportCB.SaveValue();
1435 sal_Bool bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK);
1436 aAsianSupportCB.Enable(!bReadonly);
1437 aAsianSupportFI.Show(bReadonly);
1438 SupportHdl( &aAsianSupportCB );
1440 aCTLSupportCB.Check( m_bOldCtl = pLangConfig->aLanguageOptions.IsCTLFontEnabled() );
1441 aCTLSupportCB.SaveValue();
1442 bReadonly = pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT);
1443 aCTLSupportCB.Enable(!bReadonly);
1444 aCTLSupportFI.Show(bReadonly);
1445 SupportHdl( &aCTLSupportCB );
1447 /*-- 23.11.00 13:06:40---------------------------------------------------
1449 -----------------------------------------------------------------------*/
1450 OfaLanguagesTabPage::~OfaLanguagesTabPage()
1452 delete pLangConfig;
1454 /*-- 23.11.00 13:06:40---------------------------------------------------
1456 -----------------------------------------------------------------------*/
1457 SfxTabPage* OfaLanguagesTabPage::Create( Window* pParent, const SfxItemSet& rAttrSet )
1459 return new OfaLanguagesTabPage(pParent, rAttrSet);
1461 /*-- 23.11.00 13:06:41---------------------------------------------------
1463 -----------------------------------------------------------------------*/
1464 LanguageType lcl_LangStringToLangType(const OUString& rLang)
1466 Locale aLocale;
1467 sal_Int32 nSep = rLang.indexOf('-');
1468 if (nSep < 0)
1469 aLocale.Language = rLang;
1470 else
1472 aLocale.Language = rLang.copy(0, nSep);
1473 if (nSep < rLang.getLength())
1474 aLocale.Country = rLang.copy(nSep+1, rLang.getLength() - (nSep+1));
1476 LanguageType eLangType = SvxLocaleToLanguage( aLocale );
1477 return eLangType;
1480 /*-- 23.11.00 13:06:40---------------------------------------------------
1482 -----------------------------------------------------------------------*/
1483 void lcl_UpdateAndDelete(SfxVoidItem* pInvalidItems[], SfxBoolItem* pBoolItems[], sal_uInt16 nCount)
1485 SfxViewFrame* pCurrentFrm = SfxViewFrame::Current();
1486 SfxViewFrame* pViewFrm = SfxViewFrame::GetFirst();
1487 while(pViewFrm)
1489 SfxBindings& rBind = pViewFrm->GetBindings();
1490 for(sal_Int16 i = 0; i < nCount; i++)
1492 if(pCurrentFrm == pViewFrm)
1493 rBind.InvalidateAll(sal_False);
1494 rBind.SetState( *pInvalidItems[i] );
1495 rBind.SetState( *pBoolItems[i] );
1497 pViewFrm = SfxViewFrame::GetNext(*pViewFrm);
1499 for(sal_Int16 i = 0; i < nCount; i++)
1501 delete pInvalidItems[i];
1502 delete pBoolItems[i] ;
1506 BOOL OfaLanguagesTabPage::FillItemSet( SfxItemSet& rSet )
1508 if(aCTLSupportCB.IsChecked() &&
1509 (aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked()) ||
1510 (aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos()))
1512 //sequence checking has to be switched on depending on the selected CTL language
1513 LanguageType eCTLLang = aComplexLanguageLB.GetSelectLanguage();
1514 sal_Bool bOn = MsLangId::needsSequenceChecking( eCTLLang);
1515 pLangConfig->aLanguageOptions.SetCTLSequenceCheckingRestricted(bOn);
1516 pLangConfig->aLanguageOptions.SetCTLSequenceChecking(bOn);
1517 pLangConfig->aLanguageOptions.SetCTLSequenceCheckingTypeAndReplace(bOn);
1521 // handle settings for UI Language
1522 // a change of setting needs to bring up a warning message
1523 OUString aLangString;
1524 sal_Int32 d = (sal_Int32)(sal_IntPtr)aUserInterfaceLB.GetEntryData(aUserInterfaceLB.GetSelectEntryPos());
1525 if( d > 0 && seqInstalledLanguages.getLength() > d-1)
1526 aLangString = seqInstalledLanguages[d-1];
1529 if( aUserInterfaceLB.GetSelectEntryPos() > 0)
1530 aLangString = ConvertLanguageToIsoString(aUserInterfaceLB.GetSelectLanguage());
1532 Reference< XMultiServiceFactory > theMSF = comphelper::getProcessServiceFactory();
1533 Reference< XMultiServiceFactory > theConfigProvider = Reference< XMultiServiceFactory > (
1534 theMSF->createInstance( sConfigSrvc ),UNO_QUERY_THROW);
1535 Sequence< Any > theArgs(1);
1536 theArgs[0] = makeAny(sUserLocalePath);
1537 Reference< XPropertySet >xProp(
1538 theConfigProvider->createInstanceWithArguments(sAccessUpdSrvc, theArgs ), UNO_QUERY_THROW );
1539 if ( !m_sUserLocaleValue.equals(aLangString))
1541 // OSL_ENSURE(sal_False, "UserInterface language was changed, restart.");
1542 // write new value
1543 xProp->setPropertyValue(sUserLocaleKey, makeAny(aLangString));
1544 Reference< XChangesBatch >(xProp, UNO_QUERY_THROW)->commitChanges();
1545 // display info
1546 InfoBox aBox(this, SVX_RES(RID_SVX_MSGBOX_LANGUAGE_RESTART));
1547 aBox.Execute();
1549 // tell quickstarter to stop being a veto listener
1551 Reference< XInitialization > xInit(theMSF->createInstance(
1552 OUString::createFromAscii("com.sun.star.office.Quickstart")), UNO_QUERY);
1553 if (xInit.is())
1555 Sequence< Any > args(3);
1556 args[0] = makeAny(sal_False); // will be ignored
1557 args[1] = makeAny(sal_False); // will be ignored
1558 args[2] = makeAny(sal_False); // disable veto
1559 xInit->initialize(args);
1563 catch (Exception& e)
1565 // we'll just leave the box in it's default setting and won't
1566 // even give it event handler...
1567 OString aMsg = OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US);
1568 OSL_ENSURE(sal_False, aMsg.getStr());
1571 pLangConfig->aSysLocaleOptions.BlockBroadcasts( TRUE );
1573 OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1574 LanguageType eOldLocale = (sLang.getLength() ?
1575 lcl_LangStringToLangType( sLang ) : LANGUAGE_SYSTEM);
1576 LanguageType eNewLocale = aLocaleSettingLB.GetSelectLanguage();
1577 if ( eOldLocale != eNewLocale )
1579 // an empty string denotes SYSTEM locale
1580 OUString sNewLang;
1581 if ( eNewLocale != LANGUAGE_SYSTEM )
1583 Locale aLocale;
1584 SvxLanguageToLocale( aLocale, eNewLocale );
1585 sNewLang = aLocale.Language;
1586 if ( aLocale.Country.getLength() > 0 )
1588 sNewLang += C2U("-");
1589 sNewLang += aLocale.Country;
1592 // Set application settings before options, so listeners at the
1593 // options will access the new locale.
1594 AllSettings aSettings( Application::GetSettings() );
1595 aSettings.SetLanguage( eNewLocale );
1596 Application::SetSettings( aSettings );
1597 pLangConfig->aSysLocaleOptions.SetLocaleConfigString( sNewLang );
1598 rSet.Put( SfxBoolItem( SID_OPT_LOCALE_CHANGED, TRUE ) );
1602 if(aDecimalSeparatorCB.GetSavedValue() != aDecimalSeparatorCB.IsChecked())
1603 pLangConfig->aSysLocaleOptions.SetDecimalSeparatorAsLocale(aDecimalSeparatorCB.IsChecked());
1605 // Configured currency, for example, USD-en-US or EUR-de-DE, or empty for
1606 // locale default. This must be set _after_ the locale above in order to
1607 // have a valid locale for broadcasting the currency change.
1608 OUString sOldCurr = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1609 USHORT nCurrPos = aCurrencyLB.GetSelectEntryPos();
1610 const NfCurrencyEntry* pCurr = (const NfCurrencyEntry*)
1611 aCurrencyLB.GetEntryData( nCurrPos );
1612 OUString sNewCurr;
1613 if ( pCurr )
1614 sNewCurr = SvtSysLocaleOptions::CreateCurrencyConfigString(
1615 pCurr->GetBankSymbol(), pCurr->GetLanguage() );
1616 if ( sOldCurr != sNewCurr )
1617 pLangConfig->aSysLocaleOptions.SetCurrencyConfigString( sNewCurr );
1619 BOOL bRet = FALSE;
1620 SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1621 Reference< XPropertySet > xLinguProp( LinguMgr::GetLinguPropertySet(), UNO_QUERY );
1622 BOOL bCurrentDocCBChecked = aCurrentDocCB.IsChecked();
1623 if(aCurrentDocCB.IsEnabled())
1624 bLanguageCurrentDoc_Impl = bCurrentDocCBChecked;
1625 BOOL bCurrentDocCBChanged = bCurrentDocCBChecked != aCurrentDocCB.GetSavedValue();
1627 BOOL bValChanged = aWesternLanguageLB.GetSavedValue() != aWesternLanguageLB.GetSelectEntryPos();
1628 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1630 LanguageType eSelectLang = aWesternLanguageLB.GetSelectLanguage();
1631 if(!bCurrentDocCBChecked)
1633 Any aValue;
1634 Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1635 aValue <<= aLocale;
1636 OUString aPropName( C2U("DefaultLocale") );
1637 pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1638 if (xLinguProp.is())
1639 xLinguProp->setPropertyValue( aPropName, aValue );
1641 if(pCurrentDocShell)
1643 rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::LATIN),
1644 SID_ATTR_LANGUAGE));
1645 bRet = TRUE;
1648 bValChanged = aAsianLanguageLB.GetSavedValue() != aAsianLanguageLB.GetSelectEntryPos();
1649 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1651 LanguageType eSelectLang = aAsianLanguageLB.GetSelectLanguage();
1652 if(!bCurrentDocCBChecked)
1654 Any aValue;
1655 Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1656 aValue <<= aLocale;
1657 OUString aPropName( C2U("DefaultLocale_CJK") );
1658 pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1659 if (xLinguProp.is())
1660 xLinguProp->setPropertyValue( aPropName, aValue );
1662 if(pCurrentDocShell)
1664 rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::ASIAN),
1665 SID_ATTR_CHAR_CJK_LANGUAGE));
1666 bRet = TRUE;
1669 bValChanged = aComplexLanguageLB.GetSavedValue() != aComplexLanguageLB.GetSelectEntryPos();
1670 if( (bCurrentDocCBChanged && !bCurrentDocCBChecked) || bValChanged)
1672 LanguageType eSelectLang = aComplexLanguageLB.GetSelectLanguage();
1673 if(!bCurrentDocCBChecked)
1675 Any aValue;
1676 Locale aLocale = MsLangId::convertLanguageToLocale( eSelectLang, false );
1677 aValue <<= aLocale;
1678 OUString aPropName( C2U("DefaultLocale_CTL") );
1679 pLangConfig->aLinguConfig.SetProperty( aPropName, aValue );
1680 if (xLinguProp.is())
1681 xLinguProp->setPropertyValue( aPropName, aValue );
1683 if(pCurrentDocShell)
1685 rSet.Put(SvxLanguageItem(MsLangId::resolveSystemLanguageByScriptType(eSelectLang, ::com::sun::star::i18n::ScriptType::COMPLEX),
1686 SID_ATTR_CHAR_CTL_LANGUAGE));
1687 bRet = TRUE;
1691 if(aAsianSupportCB.GetSavedValue() != aAsianSupportCB.IsChecked() )
1693 sal_Bool bChecked = aAsianSupportCB.IsChecked();
1694 pLangConfig->aLanguageOptions.SetAll(bChecked);
1695 //iterate over all bindings to invalidate vertical text direction
1697 const sal_uInt16 STATE_COUNT = 2;
1699 SfxBoolItem* pBoolItems[STATE_COUNT];
1700 pBoolItems[0] = new SfxBoolItem(SID_VERTICALTEXT_STATE, FALSE);
1701 pBoolItems[1] = new SfxBoolItem(SID_TEXT_FITTOSIZE_VERTICAL, FALSE);
1703 SfxVoidItem* pInvalidItems[STATE_COUNT];
1704 pInvalidItems[0] = new SfxVoidItem(SID_VERTICALTEXT_STATE);
1705 pInvalidItems[1] = new SfxVoidItem(SID_TEXT_FITTOSIZE_VERTICAL);
1707 lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1710 if ( aCTLSupportCB.GetSavedValue() != aCTLSupportCB.IsChecked() )
1712 pLangConfig->aLanguageOptions.SetCTLFontEnabled( aCTLSupportCB.IsChecked() );
1714 const sal_uInt16 STATE_COUNT = 1;
1715 SfxBoolItem* pBoolItems[STATE_COUNT];
1716 pBoolItems[0] = new SfxBoolItem(SID_CTLFONT_STATE, FALSE);
1717 SfxVoidItem* pInvalidItems[STATE_COUNT];
1718 pInvalidItems[0] = new SfxVoidItem(SID_CTLFONT_STATE);
1719 lcl_UpdateAndDelete(pInvalidItems, pBoolItems, STATE_COUNT);
1724 if ( pLangConfig->aSysLocaleOptions.IsModified() )
1725 pLangConfig->aSysLocaleOptions.Commit();
1726 pLangConfig->aSysLocaleOptions.BlockBroadcasts( FALSE );
1728 return FALSE;
1730 //-----------------------------------------------------------------------------
1731 void OfaLanguagesTabPage::Reset( const SfxItemSet& rSet )
1733 OUString sLang = pLangConfig->aSysLocaleOptions.GetLocaleConfigString();
1734 if ( sLang.getLength() )
1735 aLocaleSettingLB.SelectLanguage(lcl_LangStringToLangType(sLang));
1736 else
1737 aLocaleSettingLB.SelectLanguage( LANGUAGE_SYSTEM );
1738 sal_Bool bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_LOCALE);
1739 aLocaleSettingLB.Enable(!bReadonly);
1740 aLocaleSettingFT.Enable(!bReadonly);
1741 aLocaleSettingFI.Show(bReadonly);
1744 aDecimalSeparatorCB.Check( pLangConfig->aSysLocaleOptions.IsDecimalSeparatorAsLocale());
1745 aDecimalSeparatorCB.SaveValue();
1747 // let LocaleSettingHdl enable/disable checkboxes for CJK/CTL support
1748 // #i15812# must be done *before* the configured currency is set
1749 // and update the decimal separator used for the given locale
1750 LocaleSettingHdl(&aLocaleSettingLB);
1752 // configured currency, for example, USD-en-US or EUR-de-DE, or empty for locale default
1753 String aAbbrev;
1754 LanguageType eLang;
1755 const NfCurrencyEntry* pCurr = NULL;
1756 sLang = pLangConfig->aSysLocaleOptions.GetCurrencyConfigString();
1757 if ( sLang.getLength() )
1759 SvtSysLocaleOptions::GetCurrencyAbbrevAndLanguage( aAbbrev, eLang, sLang );
1760 pCurr = SvNumberFormatter::GetCurrencyEntry( aAbbrev, eLang );
1762 // if pCurr==NULL the SYSTEM entry is selected
1763 USHORT nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
1764 aCurrencyLB.SelectEntryPos( nPos );
1765 bReadonly = pLangConfig->aSysLocaleOptions.IsReadOnly(SvtSysLocaleOptions::E_CURRENCY);
1766 aCurrencyLB.Enable(!bReadonly);
1767 aCurrencyFT.Enable(!bReadonly);
1768 aCurrencyFI.Show(bReadonly);
1770 //western/CJK/CLK language
1771 LanguageType eCurLang = LANGUAGE_NONE;
1772 LanguageType eCurLangCJK = LANGUAGE_NONE;
1773 LanguageType eCurLangCTL = LANGUAGE_NONE;
1774 SfxObjectShell* pCurrentDocShell = SfxObjectShell::Current();
1775 //collect the configuration values first
1776 aCurrentDocCB.Enable(FALSE);
1778 Any aWestLang;
1779 Any aCJKLang;
1780 Any aCTLLang;
1783 aWestLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale"));
1784 Locale aLocale;
1785 aWestLang >>= aLocale;
1787 eCurLang = MsLangId::convertLocaleToLanguage( aLocale );
1789 aCJKLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CJK"));
1790 aLocale = Locale();
1791 aCJKLang >>= aLocale;
1792 eCurLangCJK = MsLangId::convertLocaleToLanguage( aLocale );
1794 aCTLLang = pLangConfig->aLinguConfig.GetProperty(C2U("DefaultLocale_CTL"));
1795 aLocale = Locale();
1796 aCTLLang >>= aLocale;
1797 eCurLangCTL = MsLangId::convertLocaleToLanguage( aLocale );
1799 catch(Exception&)
1802 //overwrite them by the values provided by the DocShell
1803 if(pCurrentDocShell)
1805 aCurrentDocCB.Enable(TRUE);
1806 aCurrentDocCB.Check(bLanguageCurrentDoc_Impl);
1807 const SfxPoolItem* pLang;
1808 if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_LANGUAGE, FALSE, &pLang))
1810 LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1811 if (MsLangId::resolveSystemLanguageByScriptType(eCurLang, ::com::sun::star::i18n::ScriptType::LATIN) != eTempCurLang)
1812 eCurLang = eTempCurLang;
1815 if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CJK_LANGUAGE, FALSE, &pLang))
1817 LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1818 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCJK, ::com::sun::star::i18n::ScriptType::ASIAN) != eTempCurLang)
1819 eCurLangCJK = eTempCurLang;
1822 if( SFX_ITEM_SET == rSet.GetItemState(SID_ATTR_CHAR_CTL_LANGUAGE, FALSE, &pLang))
1824 LanguageType eTempCurLang = ((const SvxLanguageItem*)pLang)->GetValue();
1825 if (MsLangId::resolveSystemLanguageByScriptType(eCurLangCTL, ::com::sun::star::i18n::ScriptType::COMPLEX) != eTempCurLang)
1826 eCurLangCTL = eTempCurLang;
1829 if(LANGUAGE_NONE == eCurLang || LANGUAGE_DONTKNOW == eCurLang)
1830 aWesternLanguageLB.SelectLanguage(LANGUAGE_NONE);
1831 else
1832 aWesternLanguageLB.SelectLanguage(eCurLang);
1834 if(LANGUAGE_NONE == eCurLangCJK || LANGUAGE_DONTKNOW == eCurLangCJK)
1835 aAsianLanguageLB.SelectLanguage(LANGUAGE_NONE);
1836 else
1837 aAsianLanguageLB.SelectLanguage(eCurLangCJK);
1839 if(LANGUAGE_NONE == eCurLangCTL || LANGUAGE_DONTKNOW == eCurLangCTL)
1840 aComplexLanguageLB.SelectLanguage(LANGUAGE_NONE);
1841 else
1842 aComplexLanguageLB.SelectLanguage(eCurLangCTL);
1844 aWesternLanguageLB.SaveValue();
1845 aAsianLanguageLB.SaveValue();
1846 aComplexLanguageLB.SaveValue();
1847 aCurrentDocCB.SaveValue();
1849 sal_Bool bEnable = !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale") );
1850 aWesternLanguageFT.Enable( bEnable );
1851 aWesternLanguageLB.Enable( bEnable );
1854 aWesternLanguageFI.Show(!bEnable);
1856 // #i15812# controls for CJK/CTL already enabled/disabled from LocaleSettingHdl
1857 #if 0
1858 bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK") ) && aAsianSupportCB.IsChecked() );
1859 aAsianLanguageFT.Enable( bEnable );
1860 aAsianLanguageLB.Enable( bEnable );
1862 bEnable = ( !pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL") ) && aCTLSupportCB.IsChecked() );
1863 aComplexLanguageFT.Enable( bEnable );
1864 aComplexLanguageLB.Enable( bEnable );
1865 #endif
1866 /*---------------------07-05-07--------------------------
1867 check the box "For the current document only"
1868 set the focus to the Western Language box
1869 --------------------------------------------------------*/
1870 const SfxPoolItem* pLang = 0;
1871 if ( SFX_ITEM_SET == rSet.GetItemState(SID_SET_DOCUMENT_LANGUAGE, FALSE, &pLang ) &&( (const SfxBoolItem*)pLang)->GetValue() == TRUE )
1873 aWesternLanguageLB.GrabFocus();
1874 aCurrentDocCB.Enable(TRUE);
1875 aCurrentDocCB.Check(TRUE);
1878 /* -----------------------------20.04.01 15:09--------------------------------
1880 ---------------------------------------------------------------------------*/
1881 IMPL_LINK( OfaLanguagesTabPage, SupportHdl, CheckBox*, pBox )
1883 DBG_ASSERT( pBox, "OfaLanguagesTabPage::SupportHdl(): pBox invalid" );
1885 sal_Bool bCheck = pBox->IsChecked();
1886 if ( &aAsianSupportCB == pBox )
1888 sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CJK"));
1889 bCheck = ( bCheck && !bReadonly );
1890 aAsianLanguageFT.Enable( bCheck );
1891 aAsianLanguageLB.Enable( bCheck );
1892 aAsianLanguageFI.Show(bReadonly);
1893 if( pBox->IsEnabled() )
1894 m_bOldAsian = bCheck;
1896 else if ( &aCTLSupportCB == pBox )
1898 sal_Bool bReadonly = pLangConfig->aLinguConfig.IsReadOnly( C2U("DefaultLocale_CTL"));
1899 bCheck = ( bCheck && !bReadonly );
1900 aComplexLanguageFT.Enable( bCheck );
1901 aComplexLanguageLB.Enable( bCheck );
1902 aComplexLanguageFI.Show(bReadonly);
1903 if( pBox->IsEnabled() )
1904 m_bOldCtl = bCheck;
1906 else
1908 DBG_ERRORFILE( "OfaLanguagesTabPage::SupportHdl(): wrong pBox" );
1911 return 0;
1914 namespace
1916 void lcl_checkLanguageCheckBox(CheckBox& _rCB,sal_Bool _bNewValue,sal_Bool _bOldValue)
1918 if ( _bNewValue )
1919 _rCB.Check(TRUE);
1920 else
1921 _rCB.Check( _bOldValue );
1922 // #i15082# do not call SaveValue() in running dialog...
1923 // _rCB.SaveValue();
1924 _rCB.Enable( !_bNewValue );
1927 /* -----------------08.06.01 17:56-------------------
1929 --------------------------------------------------*/
1930 IMPL_LINK( OfaLanguagesTabPage, LocaleSettingHdl, SvxLanguageBox*, pBox )
1932 LanguageType eLang = pBox->GetSelectLanguage();
1933 sal_uInt16 nType = SvtLanguageOptions::GetScriptTypeOfLanguage(eLang);
1934 // first check if CTL must be enabled
1935 // #103299# - if CTL font setting is not readonly
1936 if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_CTLFONT))
1938 bool bIsCTLFixed = (nType & SCRIPTTYPE_COMPLEX) != 0;
1939 lcl_checkLanguageCheckBox(aCTLSupportCB, bIsCTLFixed, m_bOldCtl);
1940 SupportHdl( &aCTLSupportCB );
1942 // second check if CJK must be enabled
1943 // #103299# - if CJK support is not readonly
1944 if(!pLangConfig->aLanguageOptions.IsReadOnly(SvtLanguageOptions::E_ALLCJK))
1946 bool bIsCJKFixed = (nType & SCRIPTTYPE_ASIAN) != 0;
1947 lcl_checkLanguageCheckBox(aAsianSupportCB, bIsCJKFixed, m_bOldAsian);
1948 SupportHdl( &aAsianSupportCB );
1951 USHORT nPos;
1952 if ( eLang == LANGUAGE_SYSTEM )
1953 nPos = aCurrencyLB.GetEntryPos( (void*) NULL );
1954 else
1956 const NfCurrencyEntry* pCurr = &SvNumberFormatter::GetCurrencyEntry( eLang );
1957 nPos = aCurrencyLB.GetEntryPos( (void*) pCurr );
1959 aCurrencyLB.SelectEntryPos( nPos );
1961 //update the decimal separator key of the related CheckBox
1962 Locale aTempLocale;
1963 SvxLanguageToLocale( aTempLocale, eLang );
1964 LocaleDataWrapper aLocaleWrapper( ::comphelper::getProcessServiceFactory(), aTempLocale );
1965 String sTempLabel(sDecimalSeparatorLabel);
1966 sTempLabel.SearchAndReplaceAscii("%1", aLocaleWrapper.getNumDecimalSep() );
1967 aDecimalSeparatorCB.SetText(sTempLabel);
1969 return 0;