merge the formfield patch from ooo-build
[ooovba.git] / svtools / source / config / useroptions.cxx
blob64273c957379e00b85a8f47e8ecdfa3b70696f4a
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: useroptions.cxx,v $
10 * $Revision: 1.24.238.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_svtools.hxx"
33 #ifdef SVL_DLLIMPLEMENTATION
34 #undef SVL_DLLIMPLEMENTATION
35 #endif
36 #define SVT_DLLIMPLEMENTATION
38 #include <svtools/useroptions.hxx>
39 #include "configitems/useroptions_const.hxx"
41 #include <unotools/configmgr.hxx>
42 #include <tools/debug.hxx>
43 #include <com/sun/star/uno/Any.hxx>
44 #include <com/sun/star/uno/Sequence.hxx>
45 #include <svtools/smplhint.hxx>
46 #include <vos/mutex.hxx>
47 #include <vcl/svapp.hxx>
48 #include <rtl/instance.hxx>
49 #include <rtl/logfile.hxx>
50 #include "itemholder2.hxx"
52 #include <com/sun/star/beans/Property.hpp>
53 #include <com/sun/star/beans/XPropertySet.hpp>
54 #include <com/sun/star/beans/PropertyAttribute.hpp>
55 #include <com/sun/star/container/XNameAccess.hpp>
56 #include <com/sun/star/container/XNameContainer.hpp>
57 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
58 #include <com/sun/star/util/XChangesListener.hpp>
59 #include <com/sun/star/util/XChangesNotifier.hpp>
60 #include <com/sun/star/util/ChangesEvent.hpp>
61 #include <comphelper/configurationhelper.hxx>
62 #include <unotools/processfactory.hxx>
63 #include <loghelper.hxx>
65 using namespace utl;
66 using namespace rtl;
67 using namespace com::sun::star;
68 using namespace com::sun::star::uno;
70 namespace css = ::com::sun::star;
72 // class SvtUserOptions_Impl ---------------------------------------------
73 class SvtUserOptions_Impl;
74 class SvtUserConfigChangeListener_Impl : public cppu::WeakImplHelper1
76 com::sun::star::util::XChangesListener
79 SvtUserOptions_Impl& m_rParent;
80 public:
81 SvtUserConfigChangeListener_Impl(SvtUserOptions_Impl& rParent);
82 ~SvtUserConfigChangeListener_Impl();
84 //XChangesListener
85 virtual void SAL_CALL changesOccurred( const util::ChangesEvent& Event ) throw(RuntimeException);
86 //XEventListener
87 virtual void SAL_CALL disposing( const lang::EventObject& Source ) throw(RuntimeException);
90 class SvtUserOptions_Impl : public SfxBroadcaster
92 public:
93 SvtUserOptions_Impl();
94 ~SvtUserOptions_Impl();
96 // get the user token
97 ::rtl::OUString GetCompany() const;
98 ::rtl::OUString GetFirstName() const;
99 ::rtl::OUString GetLastName() const;
100 ::rtl::OUString GetID() const;
101 ::rtl::OUString GetStreet() const;
102 ::rtl::OUString GetCity() const;
103 ::rtl::OUString GetState() const;
104 ::rtl::OUString GetZip() const;
105 ::rtl::OUString GetCountry() const;
106 ::rtl::OUString GetPosition() const;
107 ::rtl::OUString GetTitle() const;
108 ::rtl::OUString GetTelephoneHome() const;
109 ::rtl::OUString GetTelephoneWork() const;
110 ::rtl::OUString GetFax() const;
111 ::rtl::OUString GetEmail() const;
112 ::rtl::OUString GetCustomerNumber() const;
113 ::rtl::OUString GetFathersName() const;
114 ::rtl::OUString GetApartment() const;
116 ::rtl::OUString GetFullName() const;
117 ::rtl::OUString GetLocale() const { return m_aLocale; }
119 // set the address token
120 void SetCompany( const ::rtl::OUString& rNewToken );
121 void SetFirstName( const ::rtl::OUString& rNewToken );
122 void SetLastName( const ::rtl::OUString& rNewToken );
123 void SetID( const ::rtl::OUString& rNewToken );
124 void SetStreet( const ::rtl::OUString& rNewToken );
125 void SetCity( const ::rtl::OUString& rNewToken );
126 void SetState( const ::rtl::OUString& rNewToken );
127 void SetZip( const ::rtl::OUString& rNewToken );
128 void SetCountry( const ::rtl::OUString& rNewToken );
129 void SetPosition( const ::rtl::OUString& rNewToken );
130 void SetTitle( const ::rtl::OUString& rNewToken );
131 void SetTelephoneHome( const ::rtl::OUString& rNewToken );
132 void SetTelephoneWork( const ::rtl::OUString& rNewToken );
133 void SetFax( const ::rtl::OUString& rNewToken );
134 void SetEmail( const ::rtl::OUString& rNewToken );
135 void SetCustomerNumber( const ::rtl::OUString& rNewToken );
136 void SetFathersName( const ::rtl::OUString& rNewToken );
137 void SetApartment( const ::rtl::OUString& rNewToken );
139 sal_Bool IsTokenReadonly( USHORT nToken ) const;
140 ::rtl::OUString GetToken(USHORT nToken) const;
141 void Notify();
143 private:
144 uno::Reference< util::XChangesListener > m_xChangeListener;
145 css::uno::Reference< css::container::XNameAccess > m_xCfg;
146 css::uno::Reference< css::beans::XPropertySet > m_xData;
147 ::rtl::OUString m_aLocale;
150 // global ----------------------------------------------------------------
152 static SvtUserOptions_Impl* pOptions = NULL;
153 static sal_Int32 nRefCount = 0;
155 #define READONLY_DEFAULT sal_False
157 /*-- 16.06.2009 14:22:56---------------------------------------------------
159 -----------------------------------------------------------------------*/
160 SvtUserConfigChangeListener_Impl::SvtUserConfigChangeListener_Impl(SvtUserOptions_Impl& rParent) :
161 m_rParent( rParent )
164 /*-- 16.06.2009 14:22:56---------------------------------------------------
166 -----------------------------------------------------------------------*/
167 SvtUserConfigChangeListener_Impl::~SvtUserConfigChangeListener_Impl()
170 /*-- 16.06.2009 14:22:56---------------------------------------------------
172 -----------------------------------------------------------------------*/
173 void SvtUserConfigChangeListener_Impl::changesOccurred( const util::ChangesEvent& rEvent ) throw(RuntimeException)
175 if(rEvent.Changes.getLength())
176 m_rParent.Notify();
178 /*-- 16.06.2009 14:22:56---------------------------------------------------
180 -----------------------------------------------------------------------*/
181 void SvtUserConfigChangeListener_Impl::disposing( const lang::EventObject& rSource ) throw(RuntimeException)
185 uno::Reference< util::XChangesNotifier > xChgNot( rSource.Source, UNO_QUERY_THROW);
186 xChgNot->removeChangesListener(this);
188 catch(Exception& )
193 // class SvtUserOptions_Impl ---------------------------------------------
195 // -----------------------------------------------------------------------
196 SvtUserOptions_Impl::SvtUserOptions_Impl() :
197 m_xChangeListener( new SvtUserConfigChangeListener_Impl(*this) )
201 m_xCfg = Reference< css::container::XNameAccess > (
202 ::comphelper::ConfigurationHelper::openConfig(
203 utl::getProcessServiceFactory(),
204 s_sData,
205 ::comphelper::ConfigurationHelper::E_STANDARD),
206 css::uno::UNO_QUERY );
208 m_xData = css::uno::Reference< css::beans::XPropertySet >(m_xCfg, css::uno::UNO_QUERY);
209 uno::Reference< util::XChangesNotifier > xChgNot( m_xCfg, UNO_QUERY);
212 xChgNot->addChangesListener( m_xChangeListener );
214 catch(RuntimeException& )
218 catch(const css::uno::Exception& ex)
220 m_xCfg.clear();
221 LogHelper::logIt(ex);
224 Any aAny = ConfigManager::GetConfigManager()->GetDirectConfigProperty( ConfigManager::LOCALE );
225 ::rtl::OUString aLocale;
226 if ( aAny >>= aLocale )
227 m_aLocale = aLocale;
228 else
230 DBG_ERRORFILE( "SvtUserOptions_Impl::SvtUserOptions_Impl(): no locale found" );
234 // -----------------------------------------------------------------------
236 SvtUserOptions_Impl::~SvtUserOptions_Impl()
240 ::rtl::OUString SvtUserOptions_Impl::GetCompany() const
242 ::rtl::OUString sCompany;
246 m_xData->getPropertyValue(s_so) >>= sCompany;
248 catch ( const css::uno::Exception& ex )
250 LogHelper::logIt(ex);
253 return sCompany;
256 ::rtl::OUString SvtUserOptions_Impl::GetFirstName() const
258 ::rtl::OUString sFirstName;
262 m_xData->getPropertyValue(s_sgivenname) >>= sFirstName;
264 catch ( const css::uno::Exception& ex )
266 LogHelper::logIt(ex);
269 return sFirstName;
272 ::rtl::OUString SvtUserOptions_Impl::GetLastName() const
274 ::rtl::OUString sLastName;
278 m_xData->getPropertyValue(s_ssn) >>= sLastName;
280 catch ( const css::uno::Exception& ex )
282 LogHelper::logIt(ex);
285 return sLastName;
288 ::rtl::OUString SvtUserOptions_Impl::GetID() const
290 ::rtl::OUString sID;
294 m_xData->getPropertyValue(s_sinitials) >>= sID;
296 catch ( const css::uno::Exception& ex )
298 LogHelper::logIt(ex);
301 return sID;
304 ::rtl::OUString SvtUserOptions_Impl::GetStreet() const
306 ::rtl::OUString sStreet;
310 m_xData->getPropertyValue(s_sstreet) >>= sStreet;
312 catch ( const css::uno::Exception& ex )
314 LogHelper::logIt(ex);
317 return sStreet;
320 ::rtl::OUString SvtUserOptions_Impl::GetCity() const
322 ::rtl::OUString sCity;
326 m_xData->getPropertyValue(s_sl) >>= sCity;
328 catch ( const css::uno::Exception& ex )
330 LogHelper::logIt(ex);
333 return sCity;
336 ::rtl::OUString SvtUserOptions_Impl::GetState() const
338 ::rtl::OUString sState;
342 m_xData->getPropertyValue(s_sst) >>= sState;
344 catch ( const css::uno::Exception& ex )
346 LogHelper::logIt(ex);
349 return sState;
352 ::rtl::OUString SvtUserOptions_Impl::GetZip() const
354 ::rtl::OUString sZip;
358 m_xData->getPropertyValue(s_spostalcode) >>= sZip;
360 catch ( const css::uno::Exception& ex )
362 LogHelper::logIt(ex);
365 return sZip;
368 ::rtl::OUString SvtUserOptions_Impl::GetCountry() const
370 ::rtl::OUString sCountry;
374 m_xData->getPropertyValue(s_sc) >>= sCountry;
376 catch ( const css::uno::Exception& ex )
378 LogHelper::logIt(ex);
381 return sCountry;
384 ::rtl::OUString SvtUserOptions_Impl::GetPosition() const
386 ::rtl::OUString sPosition;
390 m_xData->getPropertyValue(s_sposition) >>= sPosition;
392 catch ( const css::uno::Exception& ex )
394 LogHelper::logIt(ex);
397 return sPosition;
400 ::rtl::OUString SvtUserOptions_Impl::GetTitle() const
402 ::rtl::OUString sTitle;
406 m_xData->getPropertyValue(s_stitle) >>= sTitle;
408 catch ( const css::uno::Exception& ex )
410 LogHelper::logIt(ex);
413 return sTitle;
416 ::rtl::OUString SvtUserOptions_Impl::GetTelephoneHome() const
418 ::rtl::OUString sTelephoneHome;
422 m_xData->getPropertyValue(s_shomephone) >>= sTelephoneHome;
424 catch ( const css::uno::Exception& ex )
426 LogHelper::logIt(ex);
429 return sTelephoneHome;
432 ::rtl::OUString SvtUserOptions_Impl::GetTelephoneWork() const
434 ::rtl::OUString sTelephoneWork;
438 m_xData->getPropertyValue(s_stelephonenumber) >>= sTelephoneWork;
440 catch ( const css::uno::Exception& ex )
442 LogHelper::logIt(ex);
445 return sTelephoneWork;
448 ::rtl::OUString SvtUserOptions_Impl::GetFax() const
450 ::rtl::OUString sFax;
454 m_xData->getPropertyValue(s_sfacsimiletelephonenumber) >>= sFax;
456 catch ( const css::uno::Exception& ex )
458 LogHelper::logIt(ex);
461 return sFax;
464 ::rtl::OUString SvtUserOptions_Impl::GetEmail() const
466 ::rtl::OUString sEmail;
470 m_xData->getPropertyValue(s_smail) >>= sEmail;
472 catch ( const css::uno::Exception& ex )
474 LogHelper::logIt(ex);
477 return sEmail;
480 ::rtl::OUString SvtUserOptions_Impl::GetCustomerNumber() const
482 ::rtl::OUString sCustomerNumber;
486 m_xData->getPropertyValue(s_scustomernumber) >>= sCustomerNumber;
488 catch ( const css::uno::Exception& ex )
490 LogHelper::logIt(ex);
493 return sCustomerNumber;
496 ::rtl::OUString SvtUserOptions_Impl::GetFathersName() const
498 ::rtl::OUString sFathersName;
502 m_xData->getPropertyValue(s_sfathersname) >>= sFathersName;
504 catch ( const css::uno::Exception& ex )
506 LogHelper::logIt(ex);
509 return sFathersName;
512 ::rtl::OUString SvtUserOptions_Impl::GetApartment() const
514 ::rtl::OUString sApartment;
518 m_xData->getPropertyValue(s_sapartment) >>= sApartment;
520 catch ( const css::uno::Exception& ex )
522 LogHelper::logIt(ex);
525 return sApartment;
528 void SvtUserOptions_Impl::SetCompany( const ::rtl::OUString& sCompany )
532 m_xData->setPropertyValue(s_so, css::uno::makeAny(::rtl::OUString(sCompany)));
533 ::comphelper::ConfigurationHelper::flush(m_xCfg);
535 catch ( const css::uno::Exception& ex)
537 LogHelper::logIt(ex);
541 void SvtUserOptions_Impl::SetFirstName( const ::rtl::OUString& sFirstName )
545 m_xData->setPropertyValue(s_sgivenname, css::uno::makeAny(::rtl::OUString(sFirstName)));
546 ::comphelper::ConfigurationHelper::flush(m_xCfg);
548 catch ( const css::uno::Exception& ex)
550 LogHelper::logIt(ex);
554 void SvtUserOptions_Impl::SetLastName( const ::rtl::OUString& sLastName )
558 m_xData->setPropertyValue(s_ssn, css::uno::makeAny(::rtl::OUString(sLastName)));
559 ::comphelper::ConfigurationHelper::flush(m_xCfg);
561 catch ( const css::uno::Exception& ex)
563 LogHelper::logIt(ex);
566 void SvtUserOptions_Impl::SetID( const ::rtl::OUString& sID )
570 m_xData->setPropertyValue(s_sinitials, css::uno::makeAny(::rtl::OUString(sID)));
571 ::comphelper::ConfigurationHelper::flush(m_xCfg);
573 catch ( const css::uno::Exception& ex)
575 LogHelper::logIt(ex);
579 void SvtUserOptions_Impl::SetStreet( const ::rtl::OUString& sStreet )
583 m_xData->setPropertyValue(s_sstreet, css::uno::makeAny(::rtl::OUString(sStreet)));
584 ::comphelper::ConfigurationHelper::flush(m_xCfg);
586 catch ( const css::uno::Exception& ex)
588 LogHelper::logIt(ex);
592 void SvtUserOptions_Impl::SetCity( const ::rtl::OUString& sCity )
596 m_xData->setPropertyValue(s_sl, css::uno::makeAny(::rtl::OUString(sCity)));
597 ::comphelper::ConfigurationHelper::flush(m_xCfg);
599 catch ( const css::uno::Exception& ex)
601 LogHelper::logIt(ex);
605 void SvtUserOptions_Impl::SetState( const ::rtl::OUString& sState )
609 m_xData->setPropertyValue(s_sst, css::uno::makeAny(::rtl::OUString(sState)));
610 ::comphelper::ConfigurationHelper::flush(m_xCfg);
612 catch ( const css::uno::Exception& ex)
614 LogHelper::logIt(ex);
618 void SvtUserOptions_Impl::SetZip( const ::rtl::OUString& sZip )
622 m_xData->setPropertyValue(s_spostalcode, css::uno::makeAny(::rtl::OUString(sZip)));
623 ::comphelper::ConfigurationHelper::flush(m_xCfg);
625 catch ( const css::uno::Exception& ex)
627 LogHelper::logIt(ex);
631 void SvtUserOptions_Impl::SetCountry( const ::rtl::OUString& sCountry )
635 m_xData->setPropertyValue(s_sc, css::uno::makeAny(::rtl::OUString(sCountry)));
636 ::comphelper::ConfigurationHelper::flush(m_xCfg);
638 catch ( const css::uno::Exception& ex)
640 LogHelper::logIt(ex);
644 void SvtUserOptions_Impl::SetPosition( const ::rtl::OUString& sPosition )
648 m_xData->setPropertyValue(s_sposition, css::uno::makeAny(::rtl::OUString(sPosition)));
649 ::comphelper::ConfigurationHelper::flush(m_xCfg);
651 catch ( const css::uno::Exception& ex)
653 LogHelper::logIt(ex);
657 void SvtUserOptions_Impl::SetTitle( const ::rtl::OUString& sTitle )
661 m_xData->setPropertyValue(s_stitle, css::uno::makeAny(::rtl::OUString(sTitle)));
662 ::comphelper::ConfigurationHelper::flush(m_xCfg);
664 catch ( const css::uno::Exception& ex)
666 LogHelper::logIt(ex);
670 void SvtUserOptions_Impl::SetTelephoneHome( const ::rtl::OUString& sTelephoneHome )
674 m_xData->setPropertyValue(s_shomephone, css::uno::makeAny(::rtl::OUString(sTelephoneHome)));
675 ::comphelper::ConfigurationHelper::flush(m_xCfg);
677 catch ( const css::uno::Exception& ex)
679 LogHelper::logIt(ex);
683 void SvtUserOptions_Impl::SetTelephoneWork( const ::rtl::OUString& sTelephoneWork )
687 m_xData->setPropertyValue(s_stelephonenumber, css::uno::makeAny(::rtl::OUString(sTelephoneWork)));
688 ::comphelper::ConfigurationHelper::flush(m_xCfg);
690 catch ( const css::uno::Exception& ex)
692 LogHelper::logIt(ex);
696 void SvtUserOptions_Impl::SetFax( const ::rtl::OUString& sFax )
700 m_xData->setPropertyValue(s_sfacsimiletelephonenumber, css::uno::makeAny(::rtl::OUString(sFax)));
701 ::comphelper::ConfigurationHelper::flush(m_xCfg);
703 catch ( const css::uno::Exception& ex)
705 LogHelper::logIt(ex);
709 void SvtUserOptions_Impl::SetEmail( const ::rtl::OUString& sEmail )
713 m_xData->setPropertyValue(s_smail, css::uno::makeAny(::rtl::OUString(sEmail)));
714 ::comphelper::ConfigurationHelper::flush(m_xCfg);
716 catch ( const css::uno::Exception& ex)
718 LogHelper::logIt(ex);
722 void SvtUserOptions_Impl::SetCustomerNumber( const ::rtl::OUString& sCustomerNumber )
726 m_xData->setPropertyValue(s_scustomernumber, css::uno::makeAny(::rtl::OUString(sCustomerNumber)));
727 ::comphelper::ConfigurationHelper::flush(m_xCfg);
729 catch ( const css::uno::Exception& ex)
731 LogHelper::logIt(ex);
735 void SvtUserOptions_Impl::SetFathersName( const ::rtl::OUString& sFathersName )
739 m_xData->setPropertyValue(s_sfathersname, css::uno::makeAny(::rtl::OUString(sFathersName)));
740 ::comphelper::ConfigurationHelper::flush(m_xCfg);
742 catch ( const css::uno::Exception& ex)
744 LogHelper::logIt(ex);
748 void SvtUserOptions_Impl::SetApartment( const ::rtl::OUString& sApartment )
752 m_xData->setPropertyValue(s_sapartment, css::uno::makeAny(::rtl::OUString(sApartment)));
753 ::comphelper::ConfigurationHelper::flush(m_xCfg);
755 catch ( const css::uno::Exception& ex)
757 LogHelper::logIt(ex);
761 // -----------------------------------------------------------------------
763 ::rtl::OUString SvtUserOptions_Impl::GetFullName() const
765 ::rtl::OUString sFullName;
767 sFullName = GetFirstName();
768 sFullName.trim();
769 if ( sFullName.getLength() )
770 sFullName += ::rtl::OUString::createFromAscii(" ");
771 sFullName += GetLastName();
772 sFullName.trim();
774 return sFullName;
777 // -----------------------------------------------------------------------
779 void SvtUserOptions_Impl::Notify()
781 Broadcast( SfxSimpleHint( SFX_HINT_USER_OPTIONS_CHANGED ) );
783 // -----------------------------------------------------------------------
785 sal_Bool SvtUserOptions_Impl::IsTokenReadonly( USHORT nToken ) const
787 css::uno::Reference< css::beans::XPropertySet > xData(m_xCfg, css::uno::UNO_QUERY);
788 css::uno::Reference< css::beans::XPropertySetInfo > xInfo = xData->getPropertySetInfo();
789 css::beans::Property aProp;
790 sal_Bool bRet = sal_False;
792 switch ( nToken )
794 case USER_OPT_COMPANY:
796 aProp = xInfo->getPropertyByName(s_so);
797 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
798 break;
800 case USER_OPT_FIRSTNAME:
802 aProp = xInfo->getPropertyByName(s_sgivenname);
803 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
804 break;
806 case USER_OPT_LASTNAME:
808 aProp = xInfo->getPropertyByName(s_ssn);
809 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
810 break;
812 case USER_OPT_ID:
814 aProp = xInfo->getPropertyByName(s_sinitials);
815 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
816 break;
818 case USER_OPT_STREET:
820 aProp = xInfo->getPropertyByName(s_sstreet);
821 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
822 break;
824 case USER_OPT_CITY:
826 aProp = xInfo->getPropertyByName(s_sl);
827 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
828 break;
830 case USER_OPT_STATE:
832 aProp = xInfo->getPropertyByName(s_sst);
833 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
834 break;
836 case USER_OPT_ZIP:
838 aProp = xInfo->getPropertyByName(s_spostalcode);
839 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
840 break;
842 case USER_OPT_COUNTRY:
844 aProp = xInfo->getPropertyByName(s_sc);
845 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
846 break;
848 case USER_OPT_POSITION:
850 aProp = xInfo->getPropertyByName(s_sposition);
851 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
852 break;
854 case USER_OPT_TITLE:
856 aProp = xInfo->getPropertyByName(s_stitle);
857 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
858 break;
860 case USER_OPT_TELEPHONEHOME:
862 aProp = xInfo->getPropertyByName(s_shomephone);
863 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
864 break;
866 case USER_OPT_TELEPHONEWORK:
868 aProp = xInfo->getPropertyByName(s_stelephonenumber);
869 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
870 break;
872 case USER_OPT_FAX:
874 aProp = xInfo->getPropertyByName(s_sfacsimiletelephonenumber);
875 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
876 break;
878 case USER_OPT_EMAIL:
880 aProp = xInfo->getPropertyByName(s_smail);
881 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
882 break;
884 case USER_OPT_FATHERSNAME:
886 aProp = xInfo->getPropertyByName(s_sfathersname);
887 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
888 break;
890 case USER_OPT_APARTMENT:
892 aProp = xInfo->getPropertyByName(s_sapartment);
893 bRet = ((aProp.Attributes & css::beans::PropertyAttribute::READONLY) == css::beans::PropertyAttribute::READONLY);
894 break;
896 default:
897 DBG_ERRORFILE( "SvtUserOptions_Impl::IsTokenReadonly(): invalid token" );
900 return bRet;
903 //------------------------------------------------------------------------
904 ::rtl::OUString SvtUserOptions_Impl::GetToken(USHORT nToken) const
906 ::rtl::OUString pRet;
907 switch(nToken)
909 case USER_OPT_COMPANY: pRet = GetCompany(); break;
910 case USER_OPT_FIRSTNAME: pRet = GetFirstName(); break;
911 case USER_OPT_LASTNAME: pRet = GetLastName(); break;
912 case USER_OPT_ID: pRet = GetID(); break;
913 case USER_OPT_STREET: pRet = GetStreet(); break;
914 case USER_OPT_CITY: pRet = GetCity(); break;
915 case USER_OPT_STATE: pRet = GetState(); break;
916 case USER_OPT_ZIP: pRet = GetZip(); break;
917 case USER_OPT_COUNTRY: pRet = GetCountry(); break;
918 case USER_OPT_POSITION: pRet = GetPosition(); break;
919 case USER_OPT_TITLE: pRet = GetTitle(); break;
920 case USER_OPT_TELEPHONEHOME: pRet = GetTelephoneHome(); break;
921 case USER_OPT_TELEPHONEWORK: pRet = GetTelephoneWork(); break;
922 case USER_OPT_FAX: pRet = GetFax(); break;
923 case USER_OPT_EMAIL: pRet = GetEmail(); break;
924 case USER_OPT_FATHERSNAME: pRet = GetFathersName(); break;
925 case USER_OPT_APARTMENT: pRet = GetApartment(); break;
926 default:
927 DBG_ERRORFILE( "SvtUserOptions_Impl::GetToken(): invalid token" );
929 return pRet;
932 // class SvtUserOptions --------------------------------------------------
934 SvtUserOptions::SvtUserOptions()
936 // Global access, must be guarded (multithreading)
937 ::osl::MutexGuard aGuard( GetInitMutex() );
939 if ( !pOptions )
941 RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) ::SvtUserOptions_Impl::ctor()");
942 pOptions = new SvtUserOptions_Impl;
944 ItemHolder2::holdConfigItem(E_USEROPTIONS);
946 ++nRefCount;
947 pImp = pOptions;
948 StartListening( *pImp);
951 // -----------------------------------------------------------------------
953 SvtUserOptions::~SvtUserOptions()
955 // Global access, must be guarded (multithreading)
956 ::osl::MutexGuard aGuard( GetInitMutex() );
958 if ( !--nRefCount )
960 //if ( pOptions->IsModified() )
961 // pOptions->Commit();
962 DELETEZ( pOptions );
966 // -----------------------------------------------------------------------
968 ::osl::Mutex& SvtUserOptions::GetInitMutex()
970 // Initialize static mutex only for one time!
971 static ::osl::Mutex* pMutex = NULL;
972 // If these method first called (Mutex not already exist!) ...
973 if ( pMutex == NULL )
975 // ... we must create a new one. Protect follow code with the global mutex -
976 // It must be - we create a static variable!
977 ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
978 // We must check our pointer again -
979 // because another instance of our class will be faster then this instance!
980 if ( pMutex == NULL )
982 // Create the new mutex and set it for return on static variable.
983 static ::osl::Mutex aMutex;
984 pMutex = &aMutex;
987 // Return new created or already existing mutex object.
988 return *pMutex;
991 // -----------------------------------------------------------------------
993 ::rtl::OUString SvtUserOptions::GetCompany() const
995 ::osl::MutexGuard aGuard( GetInitMutex() );
996 return pImp->GetCompany();
999 // -----------------------------------------------------------------------
1001 ::rtl::OUString SvtUserOptions::GetFirstName() const
1003 ::osl::MutexGuard aGuard( GetInitMutex() );
1004 return pImp->GetFirstName();
1007 // -----------------------------------------------------------------------
1009 ::rtl::OUString SvtUserOptions::GetLastName() const
1011 ::osl::MutexGuard aGuard( GetInitMutex() );
1012 return pImp->GetLastName();
1015 // -----------------------------------------------------------------------
1017 ::rtl::OUString SvtUserOptions::GetID() const
1019 ::osl::MutexGuard aGuard( GetInitMutex() );
1020 return pImp->GetID();
1023 // -----------------------------------------------------------------------
1025 ::rtl::OUString SvtUserOptions::GetStreet() const
1027 ::osl::MutexGuard aGuard( GetInitMutex() );
1028 return pImp->GetStreet();
1031 // -----------------------------------------------------------------------
1033 ::rtl::OUString SvtUserOptions::GetCity() const
1035 ::osl::MutexGuard aGuard( GetInitMutex() );
1036 return pImp->GetCity();
1039 // -----------------------------------------------------------------------
1041 ::rtl::OUString SvtUserOptions::GetState() const
1043 ::osl::MutexGuard aGuard( GetInitMutex() );
1044 return pImp->GetState();
1047 // -----------------------------------------------------------------------
1049 ::rtl::OUString SvtUserOptions::GetZip() const
1051 ::osl::MutexGuard aGuard( GetInitMutex() );
1052 return pImp->GetZip();
1055 // -----------------------------------------------------------------------
1057 ::rtl::OUString SvtUserOptions::GetCountry() const
1059 ::osl::MutexGuard aGuard( GetInitMutex() );
1060 return pImp->GetCountry();
1063 // -----------------------------------------------------------------------
1065 ::rtl::OUString SvtUserOptions::GetPosition() const
1067 ::osl::MutexGuard aGuard( GetInitMutex() );
1068 return pImp->GetPosition();
1071 // -----------------------------------------------------------------------
1073 ::rtl::OUString SvtUserOptions::GetTitle() const
1075 ::osl::MutexGuard aGuard( GetInitMutex() );
1076 return pImp->GetTitle();
1079 // -----------------------------------------------------------------------
1081 ::rtl::OUString SvtUserOptions::GetTelephoneHome() const
1083 ::osl::MutexGuard aGuard( GetInitMutex() );
1084 return pImp->GetTelephoneHome();
1087 // -----------------------------------------------------------------------
1089 ::rtl::OUString SvtUserOptions::GetTelephoneWork() const
1091 ::osl::MutexGuard aGuard( GetInitMutex() );
1092 return pImp->GetTelephoneWork();
1095 // -----------------------------------------------------------------------
1097 ::rtl::OUString SvtUserOptions::GetFax() const
1099 ::osl::MutexGuard aGuard( GetInitMutex() );
1100 return pImp->GetFax();
1103 // -----------------------------------------------------------------------
1105 ::rtl::OUString SvtUserOptions::GetEmail() const
1107 ::osl::MutexGuard aGuard( GetInitMutex() );
1108 return pImp->GetEmail();
1111 // -----------------------------------------------------------------------
1113 ::rtl::OUString SvtUserOptions::GetCustomerNumber() const
1115 ::osl::MutexGuard aGuard( GetInitMutex() );
1116 return pImp->GetCustomerNumber();
1118 // -----------------------------------------------------------------------
1120 ::rtl::OUString SvtUserOptions::GetFathersName() const
1122 ::osl::MutexGuard aGuard( GetInitMutex() );
1123 return pImp->GetFathersName() ;
1126 // -----------------------------------------------------------------------
1128 ::rtl::OUString SvtUserOptions::GetApartment() const
1130 ::osl::MutexGuard aGuard( GetInitMutex() );
1131 return pImp->GetApartment();
1134 // -----------------------------------------------------------------------
1136 ::rtl::OUString SvtUserOptions::GetFullName() const
1138 ::osl::MutexGuard aGuard( GetInitMutex() );
1139 return pImp->GetFullName();
1142 // -----------------------------------------------------------------------
1144 ::rtl::OUString SvtUserOptions::GetLocale() const
1146 ::osl::MutexGuard aGuard( GetInitMutex() );
1147 return pImp->GetLocale();
1150 // -----------------------------------------------------------------------
1152 void SvtUserOptions::SetCompany( const ::rtl::OUString& rNewToken )
1154 ::osl::MutexGuard aGuard( GetInitMutex() );
1155 pImp->SetCompany( rNewToken );
1158 // -----------------------------------------------------------------------
1160 void SvtUserOptions::SetFirstName( const ::rtl::OUString& rNewToken )
1162 ::osl::MutexGuard aGuard( GetInitMutex() );
1163 pImp->SetFirstName( rNewToken );
1166 // -----------------------------------------------------------------------
1168 void SvtUserOptions::SetLastName( const ::rtl::OUString& rNewToken )
1170 ::osl::MutexGuard aGuard( GetInitMutex() );
1171 pImp->SetLastName( rNewToken );
1174 // -----------------------------------------------------------------------
1176 void SvtUserOptions::SetID( const ::rtl::OUString& rNewToken )
1178 ::osl::MutexGuard aGuard( GetInitMutex() );
1179 pImp->SetID( rNewToken );
1182 // -----------------------------------------------------------------------
1184 void SvtUserOptions::SetStreet( const ::rtl::OUString& rNewToken )
1186 ::osl::MutexGuard aGuard( GetInitMutex() );
1187 pImp->SetStreet( rNewToken );
1190 // -----------------------------------------------------------------------
1192 void SvtUserOptions::SetCity( const ::rtl::OUString& rNewToken )
1194 ::osl::MutexGuard aGuard( GetInitMutex() );
1195 pImp->SetCity( rNewToken );
1198 // -----------------------------------------------------------------------
1200 void SvtUserOptions::SetState( const ::rtl::OUString& rNewToken )
1202 ::osl::MutexGuard aGuard( GetInitMutex() );
1203 pImp->SetState( rNewToken );
1206 // -----------------------------------------------------------------------
1208 void SvtUserOptions::SetZip( const ::rtl::OUString& rNewToken )
1210 ::osl::MutexGuard aGuard( GetInitMutex() );
1211 pImp->SetZip( rNewToken );
1214 // -----------------------------------------------------------------------
1216 void SvtUserOptions::SetCountry( const ::rtl::OUString& rNewToken )
1218 ::osl::MutexGuard aGuard( GetInitMutex() );
1219 pImp->SetCountry( rNewToken );
1222 // -----------------------------------------------------------------------
1224 void SvtUserOptions::SetPosition( const ::rtl::OUString& rNewToken )
1226 ::osl::MutexGuard aGuard( GetInitMutex() );
1227 pImp->SetPosition( rNewToken );
1230 // -----------------------------------------------------------------------
1232 void SvtUserOptions::SetTitle( const ::rtl::OUString& rNewToken )
1234 ::osl::MutexGuard aGuard( GetInitMutex() );
1235 pImp->SetTitle( rNewToken );
1238 // -----------------------------------------------------------------------
1240 void SvtUserOptions::SetTelephoneHome( const ::rtl::OUString& rNewToken )
1242 ::osl::MutexGuard aGuard( GetInitMutex() );
1243 pImp->SetTelephoneHome( rNewToken );
1246 // -----------------------------------------------------------------------
1248 void SvtUserOptions::SetTelephoneWork( const ::rtl::OUString& rNewToken )
1250 ::osl::MutexGuard aGuard( GetInitMutex() );
1251 pImp->SetTelephoneWork( rNewToken );
1254 // -----------------------------------------------------------------------
1256 void SvtUserOptions::SetFax( const ::rtl::OUString& rNewToken )
1258 ::osl::MutexGuard aGuard( GetInitMutex() );
1259 pImp->SetFax( rNewToken );
1262 // -----------------------------------------------------------------------
1264 void SvtUserOptions::SetEmail( const ::rtl::OUString& rNewToken )
1266 ::osl::MutexGuard aGuard( GetInitMutex() );
1267 pImp->SetEmail( rNewToken );
1270 // -----------------------------------------------------------------------
1272 void SvtUserOptions::SetCustomerNumber( const ::rtl::OUString& rNewToken )
1274 ::osl::MutexGuard aGuard( GetInitMutex() );
1275 pImp->SetCustomerNumber( rNewToken );
1277 // -----------------------------------------------------------------------
1279 void SvtUserOptions::SetFathersName( const ::rtl::OUString& rNewToken )
1281 ::osl::MutexGuard aGuard( GetInitMutex() );
1282 pImp->SetFathersName( rNewToken );
1285 // -----------------------------------------------------------------------
1287 void SvtUserOptions::SetApartment( const ::rtl::OUString& rNewToken )
1289 ::osl::MutexGuard aGuard( GetInitMutex() );
1290 pImp->SetApartment( rNewToken );
1293 // -----------------------------------------------------------------------
1295 sal_Bool SvtUserOptions::IsTokenReadonly( USHORT nToken ) const
1297 ::osl::MutexGuard aGuard( GetInitMutex() );
1298 return pImp->IsTokenReadonly( nToken );
1300 //------------------------------------------------------------------------
1301 ::rtl::OUString SvtUserOptions::GetToken(USHORT nToken) const
1303 ::osl::MutexGuard aGuard( GetInitMutex() );
1304 return pImp->GetToken( nToken );
1306 /* -----------------07.07.2003 09:30-----------------
1308 --------------------------------------------------*/
1309 void SvtUserOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
1311 vos::OGuard aVclGuard( Application::GetSolarMutex() );
1312 Broadcast( rHint );