Hello Andreas,


If changes like above, there will be no necessary to change the define of Class SvtUserOptions.
How do you think of above changes comparing the incompatible changes?

No - you shouldnt use "const String&" as return value ever.
It's never a good idea to return a reference to an internal member or variable. You cant make sure that those variable will live for the same time then it's used outside.

BTW: Returning a string by value isnt a performance problem (as you might think) ... because our string classes uses a ref count mechanism. So the internal buffer will be shared between different string variables referring the same content ... till you change one instance. Then a new buffer will be created automaticly.

So please use "String SvtUserOptions::GetXXX() const" for all methods you will find, where "const String& Svt.." was used before. It's no problem doing so ... it's an incompatible change (right) ... but it's an important refactoring to make OOo more stable.


Now I have such two problems when using "String SvtUserOptions::GetXXX()":
1)All the functions of OOo will be disable after OOo starts.(Please see the image in the attachment I captured.) I debugged it but didnt find the cause.

2)I removed the output trees(wntmsci10.pro) of modules desktop,svx and sfx2 then build the three modules. But the compiler would not break during the building process.(svtools has been built/delivered before builing desktop,svx,sfx2.) Should the compiler break?

Regards
Yan Wu




/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: useroptions.cxx,v $
 *
 *  $Revision: 1.24 $
 *
 *  last change: $Author: hr $ $Date: 2007/06/27 21:17:53 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_svtools.hxx"
#ifdef  SVL_DLLIMPLEMENTATION
#undef  SVL_DLLIMPLEMENTATION
#endif
#define SVT_DLLIMPLEMENTATION

#include <svtools/useroptions.hxx>
#include "configitems/useroptions_const.hxx"

#ifndef _UTL_CONFIGMGR_HXX_
#include <unotools/configmgr.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
#include <com/sun/star/uno/Any.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
#endif
#ifndef _SFXSMPLHINT_HXX
#include <svtools/smplhint.hxx>
#endif
#ifndef _VOS_MUTEX_HXX_ 
#include <vos/mutex.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef INCLUDED_RTL_INSTANCE_HXX
#include <rtl/instance.hxx>
#endif
#include <rtl/logfile.hxx>
#include "itemholder2.hxx"

#ifndef _COM_SUN_STAR_BEANS_PROPERTY_HPP_ 
#include <com/sun/star/beans/Property.hpp>
#endif

#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ 
#include <com/sun/star/beans/XPropertySet.hpp> 
#endif

#ifndef _COM_SUN_STAR_BEANS_PROPERTYATTRIBUTE_HPP_
#include <com/sun/star/beans/PropertyAttribute.hpp>
#endif

#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_ 
#include <com/sun/star/container/XNameAccess.hpp> 
#endif

#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_ 
#include <com/sun/star/container/XNameContainer.hpp> 
#endif

#ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_ 
#include <com/sun/star/lang/XSingleServiceFactory.hpp> 
#endif

#ifndef _COMPHELPER_CONFIGURATIONHELPER_HXX_ 
#include <comphelper/configurationhelper.hxx> 
#endif

#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ 
#include <unotools/processfactory.hxx> 
#endif

#ifndef _SVT_LOGHELPER_HXX 
#include "loghelper.hxx" 
#endif

using namespace utl;
using namespace rtl;
using namespace com::sun::star::uno;

namespace css = ::com::sun::star;

// class SvtUserOptions_Impl ---------------------------------------------

class SvtUserOptions_Impl
{
public:
        SvtUserOptions_Impl();
    ~SvtUserOptions_Impl();

        // get the user token
    String   GetCompany() const;
    String   GetFirstName() const;
    String   GetLastName() const;
    String   GetID() const;
    String   GetStreet() const;
    String   GetCity() const;
    String   GetState() const;
    String   GetZip() const;
    String   GetCountry() const;
    String   GetPosition() const;
    String   GetTitle() const;
    String   GetTelephoneHome() const;
    String   GetTelephoneWork() const;
    String   GetFax() const;
    String   GetEmail() const;
    String   GetCustomerNumber() const;
    String   GetFathersName() const;
    String   GetApartment() const;

    String   GetFullName() const;
    String   GetLocale() const { return m_aLocale; }

        // set the address token
        void                    SetCompany( const String& rNewToken );
        void                    SetFirstName( const String& rNewToken );
        void                    SetLastName( const String& rNewToken );
        void                    SetID( const String& rNewToken );
        void                    SetStreet( const String& rNewToken );
        void                    SetCity( const String& rNewToken );
        void                    SetState( const String& rNewToken );
        void                    SetZip( const String& rNewToken );
        void                    SetCountry( const String& rNewToken );
        void                    SetPosition( const String& rNewToken );
        void                    SetTitle( const String& rNewToken );
        void                    SetTelephoneHome( const String& rNewToken );
        void                    SetTelephoneWork( const String& rNewToken );
        void                    SetFax( const String& rNewToken );
        void                    SetEmail( const String& rNewToken );
        void                    SetCustomerNumber( const String& rNewToken );
    void            SetFathersName( const String& rNewToken );
    void            SetApartment( const String& rNewToken );

        sal_Bool                IsTokenReadonly( USHORT nToken ) const;
    String          GetToken(USHORT nToken) const;

private:
        css::uno::Reference< css::container::XNameAccess > m_xCfg;
        css::uno::Reference< css::beans::XPropertySet >    m_xData;
        String                  m_aLocale;
        String                  m_aCustomerNumber;
        String          m_aFathersName;
        String          m_aApartment;

        typedef String SvtUserOptions_Impl:: *StrPtr;
};

// global ----------------------------------------------------------------

static SvtUserOptions_Impl*     pOptions = NULL;
static sal_Int32                        nRefCount = 0;

#define READONLY_DEFAULT        sal_False

// functions -------------------------------------------------------------

namespace 
{
    struct PropertyNames 
        : public rtl::Static< Sequence< rtl::OUString >, PropertyNames> {}; 
}

// class SvtUserOptions_Impl ---------------------------------------------

// -----------------------------------------------------------------------
SvtUserOptions_Impl::SvtUserOptions_Impl()
{
        try
        {
                m_xCfg = Reference< css::container::XNameAccess > ( 
                        ::comphelper::ConfigurationHelper::openConfig( 
                        utl::getProcessServiceFactory(), 
                        s_sData, 
                        ::comphelper::ConfigurationHelper::E_STANDARD), 
                        css::uno::UNO_QUERY ); 

                m_xData = css::uno::Reference< css::beans::XPropertySet 
>(m_xCfg, css::uno::UNO_QUERY);
        }
        catch(const css::uno::Exception& ex) 
        { 
                m_xCfg.clear(); 
                LogHelper::logIt(ex); 
        } 

    Any aAny = ConfigManager::GetConfigManager()->GetDirectConfigProperty( 
ConfigManager::LOCALE );
        OUString aLocale;
        if ( aAny >>= aLocale )
                m_aLocale = String( aLocale );
        else
        {
                DBG_ERRORFILE( "SvtUserOptions_Impl::SvtUserOptions_Impl(): no 
locale found" );
        }
}

// -----------------------------------------------------------------------

SvtUserOptions_Impl::~SvtUserOptions_Impl()
{
}        

String SvtUserOptions_Impl::GetCompany() const
{
        ::rtl::OUString sCompany;
        
        try
        {
                m_xData->getPropertyValue(s_so) >>= sCompany;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return sCompany;
}

String SvtUserOptions_Impl::GetFirstName() const
{
        ::rtl::OUString sFirstName;

        try
        {
                m_xData->getPropertyValue(s_sgivenname) >>= sFirstName;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sFirstName;
}

String SvtUserOptions_Impl::GetLastName() const
{
        ::rtl::OUString sLastName;

        try
        {
                m_xData->getPropertyValue(s_ssn) >>= sLastName;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sLastName;
}

String SvtUserOptions_Impl::GetID() const
{
        ::rtl::OUString sID;

        try
        {
                m_xData->getPropertyValue(s_sinitials) >>= sID;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sID;
}

String SvtUserOptions_Impl::GetStreet() const
{
        ::rtl::OUString sStreet;

        try
        {
                m_xData->getPropertyValue(s_sstreet) >>= sStreet;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sStreet;
}

String SvtUserOptions_Impl::GetCity() const
{
        ::rtl::OUString sCity;

        try
        {
                m_xData->getPropertyValue(s_sl) >>= sCity;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sCity;
}

String SvtUserOptions_Impl::GetState() const
{
        ::rtl::OUString sState;

        try
        {
                m_xData->getPropertyValue(s_sst) >>= sState;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sState;
}

String SvtUserOptions_Impl::GetZip() const
{
        ::rtl::OUString sZip;

        try
        {
                m_xData->getPropertyValue(s_spostalcode) >>= sZip;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sZip;
}

String SvtUserOptions_Impl::GetCountry() const
{
        ::rtl::OUString sCountry;

        try
        {
                m_xData->getPropertyValue(s_sc) >>= sCountry;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sCountry;
}

String SvtUserOptions_Impl::GetPosition() const
{
        ::rtl::OUString sPosition;

        try
        {
                m_xData->getPropertyValue(s_sposition) >>= sPosition;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sPosition;
}

String SvtUserOptions_Impl::GetTitle() const
{
        ::rtl::OUString sTitle;

        try
        {
                m_xData->getPropertyValue(s_stitle) >>= sTitle;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sTitle;
}

String SvtUserOptions_Impl::GetTelephoneHome() const
{
        ::rtl::OUString sTelephoneHome;

        try
        {
                m_xData->getPropertyValue(s_shomephone) >>= sTelephoneHome;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sTelephoneHome;
}

String SvtUserOptions_Impl::GetTelephoneWork() const
{
        ::rtl::OUString sTelephoneWork;

        try
        {
                m_xData->getPropertyValue(s_stelephonenumber) >>= 
sTelephoneWork;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sTelephoneWork;
}

String SvtUserOptions_Impl::GetFax() const
{
        ::rtl::OUString sFax;

        try
        {
                m_xData->getPropertyValue(s_sfacsimiletelephonenumber) >>= sFax;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sFax;
}

String SvtUserOptions_Impl::GetEmail() const
{
        ::rtl::OUString sEmail;

        try
        {
                m_xData->getPropertyValue(s_smail) >>= sEmail;
        }
        catch ( const css::uno::Exception& ex )
        {
                LogHelper::logIt(ex);
        }

        return  sEmail;
}

String SvtUserOptions_Impl::GetCustomerNumber() const
{
        return m_aCustomerNumber;
}
String SvtUserOptions_Impl::GetFathersName() const
{
        return m_aFathersName;
}
String SvtUserOptions_Impl::GetApartment() const
{
        return m_aApartment;
}

void SvtUserOptions_Impl::SetCompany( const String& sCompany )
{
        try
        {
                m_xData->setPropertyValue(s_so, 
css::uno::makeAny(::rtl::OUString(sCompany)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetFirstName( const String& sFirstName )
{
        try
        {
                m_xData->setPropertyValue(s_sgivenname, 
css::uno::makeAny(::rtl::OUString(sFirstName)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetLastName( const String& sLastName )
{
        try
        {
                m_xData->setPropertyValue(s_ssn, 
css::uno::makeAny(::rtl::OUString(sLastName)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}
void SvtUserOptions_Impl::SetID( const String& sID )
{
        try
        {
                m_xData->setPropertyValue(s_sinitials, 
css::uno::makeAny(::rtl::OUString(sID)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetStreet( const String& sStreet )
{
        try
        {
                m_xData->setPropertyValue(s_sstreet, 
css::uno::makeAny(::rtl::OUString(sStreet)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetCity( const String& sCity )
{
        try
        {
                m_xData->setPropertyValue(s_sl, 
css::uno::makeAny(::rtl::OUString(sCity)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetState( const String& sState )
{
        try
        {
                m_xData->setPropertyValue(s_sst, 
css::uno::makeAny(::rtl::OUString(sState)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetZip( const String& sZip )
{
        try
        {
                m_xData->setPropertyValue(s_spostalcode, 
css::uno::makeAny(::rtl::OUString(sZip)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetCountry( const String& sCountry )
{
        try
        {
                m_xData->setPropertyValue(s_sc, 
css::uno::makeAny(::rtl::OUString(sCountry)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetPosition( const String& sPosition )
{
        try
        {
                m_xData->setPropertyValue(s_sposition, 
css::uno::makeAny(::rtl::OUString(sPosition)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetTitle( const String& sTitle )
{
        try
        {
                m_xData->setPropertyValue(s_stitle, 
css::uno::makeAny(::rtl::OUString(sTitle)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetTelephoneHome( const String& sTelephoneHome )
{
        try
        {
                m_xData->setPropertyValue(s_shomephone, 
css::uno::makeAny(::rtl::OUString(sTelephoneHome)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetTelephoneWork( const String& sTelephoneWork )
{
        try
        {
                m_xData->setPropertyValue(s_stelephonenumber, 
css::uno::makeAny(::rtl::OUString(sTelephoneWork)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg);
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetFax( const String& sFax )
{
        try
        {
                m_xData->setPropertyValue(s_sfacsimiletelephonenumber, 
css::uno::makeAny(::rtl::OUString(sFax)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetEmail( const String& sEmail )
{
        try
        {
                m_xData->setPropertyValue(s_smail, 
css::uno::makeAny(::rtl::OUString(sEmail)));
                ::comphelper::ConfigurationHelper::flush(m_xCfg); 
        }
        catch ( const css::uno::Exception& ex)
        {
                LogHelper::logIt(ex);
        }
}

void SvtUserOptions_Impl::SetCustomerNumber( const String& /*sEmail*/ )
{
}
void SvtUserOptions_Impl::SetFathersName( const String& /*sEmail*/ )
{
}
void SvtUserOptions_Impl::SetApartment( const String& /*sEmail*/ )
{
}

// -----------------------------------------------------------------------

String SvtUserOptions_Impl::GetFullName() const
{
        String sFullName;

        sFullName = GetFirstName();
        sFullName.EraseLeadingAndTrailingChars();
        if ( sFullName.Len() )
                sFullName += ' ';
        sFullName += GetLastName();
        sFullName.EraseLeadingAndTrailingChars();

        return sFullName;
}

// -----------------------------------------------------------------------

sal_Bool SvtUserOptions_Impl::IsTokenReadonly( USHORT nToken ) const
{
        css::uno::Reference< css::beans::XPropertySet > m_xData(m_xCfg, 
css::uno::UNO_QUERY);
        css::uno::Reference< css::beans::XPropertySetInfo > xInfo = 
m_xData->getPropertySetInfo();
        css::beans::Property aProp;
        sal_Bool bRet = sal_False;

        switch ( nToken )
        {
                case USER_OPT_COMPANY:
                {
                        aProp = xInfo->getPropertyByName(s_so);
                        bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                        break;
                }
                case USER_OPT_FIRSTNAME:
                {
                                aProp = xInfo->getPropertyByName(s_sgivenname);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_LASTNAME:
                {
                                aProp = xInfo->getPropertyByName(s_ssn);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_ID:
                {
                                aProp = xInfo->getPropertyByName(s_sinitials);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_STREET:
                {
                                aProp = xInfo->getPropertyByName(s_sstreet);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_CITY:
                {
                                aProp = xInfo->getPropertyByName(s_sl);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_STATE:
                {
                                aProp = xInfo->getPropertyByName(s_sst);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_ZIP:
                {
                                aProp = xInfo->getPropertyByName(s_spostalcode);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_COUNTRY:
                {
                                aProp = xInfo->getPropertyByName(s_sc);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_POSITION:
                {
                                aProp = xInfo->getPropertyByName(s_sposition);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_TITLE:
                {
                                aProp = xInfo->getPropertyByName(s_stitle);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_TELEPHONEHOME:
                {
                                aProp = xInfo->getPropertyByName(s_shomephone);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_TELEPHONEWORK:
                {
                                aProp = 
xInfo->getPropertyByName(s_stelephonenumber);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_FAX:
                {
                                aProp = 
xInfo->getPropertyByName(s_sfacsimiletelephonenumber);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                case USER_OPT_EMAIL:
                {
                                aProp = xInfo->getPropertyByName(s_smail);
                                bRet = ((aProp.Attributes & 
css::beans::PropertyAttribute::READONLY) == 
css::beans::PropertyAttribute::READONLY);

                                break;
                }
                default:
                        DBG_ERRORFILE( "SvtUserOptions_Impl::IsTokenReadonly(): 
invalid token" );
        }

        return bRet;
}

//------------------------------------------------------------------------
String SvtUserOptions_Impl::GetToken(USHORT nToken) const
{        
    String pRet;
    switch(nToken)
    {        
        case USER_OPT_COMPANY:        pRet = GetCompany();     break;
        case USER_OPT_FIRSTNAME:      pRet = GetFirstName();   break;
        case USER_OPT_LASTNAME:       pRet = GetLastName();    break;
        case USER_OPT_ID:             pRet = GetID();          break;
        case USER_OPT_STREET:         pRet = GetStreet();      break;
        case USER_OPT_CITY:           pRet = GetCity();        break;
        case USER_OPT_STATE:          pRet = GetState();       break;
        case USER_OPT_ZIP:            pRet = GetZip();         break;
        case USER_OPT_COUNTRY:        pRet = GetCountry();     break;
        case USER_OPT_POSITION:       pRet = GetPosition();    break;
        case USER_OPT_TITLE:          pRet = GetTitle();       break;
        case USER_OPT_TELEPHONEHOME:  pRet = GetTelephoneHome(); break;
        case USER_OPT_TELEPHONEWORK:  pRet = GetTelephoneWork(); break;
        case USER_OPT_FAX:            pRet = GetFax();           break;
        case USER_OPT_EMAIL:          pRet = GetEmail();         break;
        //case USER_OPT_FATHERSNAME:       break;
        //case USER_OPT_APARTMENT:           break;
        default:
            DBG_ERRORFILE( "SvtUserOptions_Impl::GetToken(): invalid token" );
    }    
    return pRet;
}

// class SvtUserOptions --------------------------------------------------

SvtUserOptions::SvtUserOptions()
{
    // Global access, must be guarded (multithreading)
    ::osl::MutexGuard aGuard( GetInitMutex() );

        if ( !pOptions )
    {
        RTL_LOGFILE_CONTEXT(aLog, "svtools ( ??? ) 
::SvtUserOptions_Impl::ctor()");
        pOptions = new SvtUserOptions_Impl;
        
        ItemHolder2::holdConfigItem(E_USEROPTIONS);
    }
    ++nRefCount;
    pImp = pOptions;
    //StartListening( *pImp);
}

// -----------------------------------------------------------------------

SvtUserOptions::~SvtUserOptions()
{
    // Global access, must be guarded (multithreading)
    ::osl::MutexGuard aGuard( GetInitMutex() );

        if ( !--nRefCount )
        {
                //if ( pOptions->IsModified() )
                //      pOptions->Commit();
        DELETEZ( pOptions );
        }
}

// -----------------------------------------------------------------------

::osl::Mutex& SvtUserOptions::GetInitMutex()
{
        // Initialize static mutex only for one time!
    static ::osl::Mutex* pMutex = NULL;
        // If these method first called (Mutex not already exist!) ...
    if ( pMutex == NULL )
    {
                // ... we must create a new one. Protect follow code with the 
global mutex -
                // It must be - we create a static variable!
        ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
                // We must check our pointer again -
                // because another instance of our class will be faster then 
this instance!
        if ( pMutex == NULL )
        {
                        // Create the new mutex and set it for return on static 
variable.
            static ::osl::Mutex aMutex;
            pMutex = &aMutex;
        }
    }
        // Return new created or already existing mutex object.
    return *pMutex;
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetCompany() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetCompany();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetFirstName() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetFirstName();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetLastName() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetLastName();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetID() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetID();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetStreet() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetStreet();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetCity() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetCity();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetState() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetState();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetZip() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetZip();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetCountry() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetCountry();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetPosition() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetPosition();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetTitle() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetTitle();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetTelephoneHome() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetTelephoneHome();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetTelephoneWork() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetTelephoneWork();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetFax() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetFax();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetEmail() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetEmail();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetCustomerNumber() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetCustomerNumber();
}
// -----------------------------------------------------------------------

String SvtUserOptions::GetFathersName() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
    return pImp->GetFathersName() ;
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetApartment() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
    return pImp->GetApartment();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetFullName() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetFullName();
}

// -----------------------------------------------------------------------

String SvtUserOptions::GetLocale() const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->GetLocale();
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetCompany( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetCompany( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetFirstName( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetFirstName( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetLastName( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetLastName( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetID( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetID( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetStreet( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetStreet( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetCity( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetCity( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetState( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetState( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetZip( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetZip( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetCountry( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetCountry( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetPosition( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetPosition( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetTitle( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetTitle( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetTelephoneHome( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetTelephoneHome( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetTelephoneWork( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetTelephoneWork( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetFax( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetFax( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetEmail( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetEmail( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetCustomerNumber( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        pImp->SetCustomerNumber( rNewToken );
}
// -----------------------------------------------------------------------

void SvtUserOptions::SetFathersName( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
    pImp->SetFathersName( rNewToken );
}

// -----------------------------------------------------------------------

void SvtUserOptions::SetApartment( const String& rNewToken )
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
    pImp->SetApartment( rNewToken );
}

// -----------------------------------------------------------------------

sal_Bool SvtUserOptions::IsTokenReadonly( USHORT nToken ) const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
        return pImp->IsTokenReadonly( nToken );
}
//------------------------------------------------------------------------
String   SvtUserOptions::GetToken(USHORT nToken) const
{
    ::osl::MutexGuard aGuard( GetInitMutex() );
    return pImp->GetToken( nToken );
}            
/* -----------------07.07.2003 09:30-----------------

 --------------------------------------------------*/
void SvtUserOptions::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
    vos::OGuard aVclGuard( Application::GetSolarMutex() );
    Broadcast( rHint );
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to