diff options
author | Release Engineers <releng@openoffice.org> | 2008-12-01 12:31:27 +0000 |
---|---|---|
committer | Release Engineers <releng@openoffice.org> | 2008-12-01 12:31:27 +0000 |
commit | 3e33ac2ea6f2c78e86faab4acbf6c47e87a695ee (patch) | |
tree | 5acb00b118789ccdd61d5147474100c8a0094a7d | |
parent | 4f6b7ef2931e5527c31b650b3815e36378e5010c (diff) |
CWS-TOOLING: integrate CWS dba31e
2008-11-19 12:36:23 +0100 msc r263980 : i96104
2008-11-19 12:31:19 +0100 msc r263979 : i96104
2008-11-19 12:21:55 +0100 msc r263977 : i96104
2008-11-19 12:18:53 +0100 msc r263976 : i96104
2008-11-18 09:09:45 +0100 oj r263746 : disable color entry when area is set
2008-11-18 08:37:52 +0100 oj r263741 : #remove sub report entry
2008-11-17 11:20:25 +0100 fs r263708 : #i10000#
2008-11-17 11:06:52 +0100 fs r263706 : minimal version now is 3.1
2008-11-12 22:25:59 +0100 fs r263621 : #i96150#
2008-11-12 22:20:02 +0100 fs r263620 : rebased to m34
2008-11-12 21:39:41 +0100 fs r263618 : MANUAL REBASE: rebase CWS dba31d to DEV300_m34
2008-11-12 13:54:58 +0100 fs r263597 : #i96134# MediaDescriptor.URL is to be preferred over MediaDescriptor.FileName. Nonetheless, ensure both are handled
2008-11-12 13:53:40 +0100 fs r263596 : #i96134# re-enabled the code for #i41897#, a better fix is to come
2008-11-12 12:48:21 +0100 fs r263585 : #i96134# disable saving URLs of file-base databases relatively
2008-11-11 16:11:11 +0100 msc r263566 : #i96104#
2008-11-05 09:09:47 +0100 oj r263342 : #i88727# color noe added
2008-11-05 08:41:43 +0100 oj r263341 : #i77916# zoom added
2008-11-04 21:24:15 +0100 fs r263339 : disposing: call disposeAndClear without own mutex locked - some of our listeners insist on locking the SolarMutex, which sometimes led to deadlocks on the complex test cases
2008-11-04 21:23:15 +0100 fs r263338 : remove SolarMutex locking - this happned in CWS dba31c (in the CVS version), which this CWS was created from, but seems to got lost during resync
2008-11-04 20:49:50 +0100 fs r263335 : docu formatting
2008-11-04 20:06:39 +0100 fs r263334 : #i95826# use m_aMutex, not a DocumentGuard (wrongly resolved merge conflicts)
2008-11-04 17:36:29 +0100 fs r263332 : #i92688# properly revoke as XEventListener from m_xActiveController when disposing
2008-11-04 14:49:34 +0100 fs r263324 : #i92322# enable Input Required if EmptyIsNULL does not exist at the control
2008-10-31 11:10:04 +0100 oj r262857 : merge from cvs to svn
2008-10-31 09:46:45 +0100 oj r262853 : merge from cvs to svn
2008-10-31 08:46:37 +0100 oj r262849 : merge from cvs to svn
2008-10-31 08:44:24 +0100 oj r262848 : merge from cvs to svn
2008-10-31 08:43:33 +0100 oj r262847 : merge from cvs to svn
2008-10-31 08:42:28 +0100 oj r262846 : merge from cvs to svn
2008-10-31 08:41:58 +0100 oj r262845 : merge from cvs to svn
2008-10-31 08:41:32 +0100 oj r262844 : merge from cvs to svn
2008-10-28 12:19:50 +0100 oj r262733 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:42 +0100 oj r262732 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:36 +0100 oj r262731 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:31 +0100 oj r262730 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:22 +0100 oj r262729 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:18 +0100 oj r262728 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:10 +0100 oj r262727 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:06 +0100 oj r262726 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:05 +0100 oj r262725 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:19:01 +0100 oj r262724 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:18:50 +0100 oj r262723 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:18:41 +0100 oj r262722 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:18:40 +0100 oj r262721 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:18:27 +0100 oj r262720 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:18:10 +0100 oj r262719 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:18:01 +0100 oj r262718 : #iXXXXX#: migrate CWS dba31e to SVN
2008-10-28 12:17:39 +0100 oj r262717 : #iXXXXX#: migrate CWS dba31e to SVN
39 files changed, 754 insertions, 240 deletions
diff --git a/comphelper/inc/comphelper/sharedmutex.hxx b/comphelper/inc/comphelper/sharedmutex.hxx new file mode 100644 index 000000000000..50a643455e85 --- /dev/null +++ b/comphelper/inc/comphelper/sharedmutex.hxx @@ -0,0 +1,94 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2008 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: sharedmutex.hxx,v $ +* +* $Revision: 1.1.2.3 $ +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +#ifndef COMPHELPER_SHAREDMUTEX_HXX +#define COMPHELPER_SHAREDMUTEX_HXX + +#include "comphelper/comphelperdllapi.h" + +#include <osl/mutex.hxx> + +#include <boost/shared_ptr.hpp> + +//........................................................................ +namespace comphelper +{ +//........................................................................ + + //============================================================ + //= SharedMutex + //============================================================ + class COMPHELPER_DLLPUBLIC SharedMutex + { + public: + SharedMutex(); + SharedMutex( const SharedMutex& ); + SharedMutex& operator=( const SharedMutex& ); + ~SharedMutex() + { + } + + inline ::osl::Mutex& getMutex() { return *m_pMutexImpl; } + inline operator ::osl::Mutex& () { return *m_pMutexImpl; } + + private: + ::boost::shared_ptr< ::osl::Mutex > m_pMutexImpl; + }; + + //============================================================ + //= SharedMutexBase + //============================================================ + /** sometimes, it's necessary to have an initialized ::osl::Mutex to pass + to some ctor call of your base class. In this case, you can't hold the + SharedMutex as member, but you need to move it into another base class, + which is initialized before the mutex-requiring class is. + */ + class COMPHELPER_DLLPUBLIC SharedMutexBase + { + protected: + SharedMutexBase() + { + } + ~SharedMutexBase() + { + } + + protected: + ::osl::Mutex& getMutex() const { return m_aMutex; } + SharedMutex& getSharedMutex() const { return m_aMutex; } + + private: + mutable SharedMutex m_aMutex; + }; + +//........................................................................ +} // namespace comphelper +//........................................................................ + +#endif // COMPHELPER_SHAREDMUTEX_HXX diff --git a/comphelper/source/misc/makefile.mk b/comphelper/source/misc/makefile.mk index fd6afba00a80..78f79c806511 100644 --- a/comphelper/source/misc/makefile.mk +++ b/comphelper/source/misc/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.48 $ +# $Revision: 1.48.16.3 $ # # This file is part of OpenOffice.org. # @@ -81,6 +81,7 @@ SLOFILES= \ $(SLO)$/sequenceashashmap.obj \ $(SLO)$/sequence.obj \ $(SLO)$/servicedecl.obj \ + $(SLO)$/sharedmutex.obj \ $(SLO)$/synchronousdispatch.obj \ $(SLO)$/storagehelper.obj \ $(SLO)$/string.obj \ diff --git a/comphelper/source/misc/sharedmutex.cxx b/comphelper/source/misc/sharedmutex.cxx new file mode 100644 index 000000000000..a3ede5b71821 --- /dev/null +++ b/comphelper/source/misc/sharedmutex.cxx @@ -0,0 +1,65 @@ +/************************************************************************* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2008 by Sun Microsystems, Inc. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* $RCSfile: sharedmutex.cxx,v $ +* +* $Revision: 1.1.2.4 $ +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org 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 version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_comphelper.hxx" + +#include "comphelper/sharedmutex.hxx" + +//........................................................................ +namespace comphelper +{ +//........................................................................ + + //======================================================================== + //= SharedMutex + //======================================================================== + //------------------------------------------------------------------------ + SharedMutex::SharedMutex() + :m_pMutexImpl( new ::osl::Mutex ) + { + } + + //------------------------------------------------------------------------ + SharedMutex::SharedMutex( const SharedMutex& _rhs ) + :m_pMutexImpl() + { + *this = _rhs; + } + + //------------------------------------------------------------------------ + SharedMutex& SharedMutex::operator=( const SharedMutex& _rhs ) + { + m_pMutexImpl = _rhs.m_pMutexImpl; + return *this; + } + +//........................................................................ +} // namespace comphelper +//........................................................................ diff --git a/comphelper/source/property/ChainablePropertySet.cxx b/comphelper/source/property/ChainablePropertySet.cxx index a5c207d25018..567db83d1626 100644 --- a/comphelper/source/property/ChainablePropertySet.cxx +++ b/comphelper/source/property/ChainablePropertySet.cxx @@ -88,7 +88,7 @@ void SAL_CALL ChainablePropertySet::setPropertyValue( const ::rtl::OUString& rPr PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); _preSetValues(); _setSingleValue( *((*aIter).second), rValue ); @@ -106,7 +106,7 @@ Any SAL_CALL ChainablePropertySet::getPropertyValue( const ::rtl::OUString& rPro PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); Any aAny; _preGetValues (); @@ -166,7 +166,7 @@ void SAL_CALL ChainablePropertySet::setPropertyValues( const Sequence< ::rtl::OU { aIter = mpInfo->maMap.find ( *pString ); if ( aIter == aEnd ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); _setSingleValue ( *((*aIter).second), *pAny ); } @@ -199,7 +199,7 @@ Sequence< Any > SAL_CALL ChainablePropertySet::getPropertyValues( const Sequence { aIter = mpInfo->maMap.find ( *pString ); if ( aIter == aEnd ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); _getSingleValue ( *((*aIter).second), *pAny ); } @@ -233,7 +233,7 @@ PropertyState SAL_CALL ChainablePropertySet::getPropertyState( const ::rtl::OUSt { PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find( PropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) ); PropertyState aState; @@ -261,7 +261,7 @@ Sequence< PropertyState > SAL_CALL ChainablePropertySet::getPropertyStates( cons { aIter = mpInfo->maMap.find ( *pString ); if ( aIter == aEnd ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); _getPropertyState ( *((*aIter).second), *pState ); } @@ -276,7 +276,7 @@ void SAL_CALL ChainablePropertySet::setPropertyToDefault( const ::rtl::OUString& PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); _setPropertyToDefault( *((*aIter).second) ); } @@ -286,7 +286,7 @@ Any SAL_CALL ChainablePropertySet::getPropertyDefault( const ::rtl::OUString& rP PropertyInfoHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); return _getPropertyDefault( *((*aIter).second) ); } diff --git a/comphelper/source/property/ChainablePropertySetInfo.cxx b/comphelper/source/property/ChainablePropertySetInfo.cxx index dd7c18532e85..b27cef88319c 100644 --- a/comphelper/source/property/ChainablePropertySetInfo.cxx +++ b/comphelper/source/property/ChainablePropertySetInfo.cxx @@ -125,7 +125,7 @@ Property SAL_CALL ChainablePropertySetInfo::getPropertyByName( const ::rtl::OUSt PropertyInfoHash::iterator aIter = maMap.find( rName ); if ( maMap.end() == aIter ) - throw UnknownPropertyException(); + throw UnknownPropertyException( rName, *this ); PropertyInfo *pInfo = (*aIter).second; Property aProperty; diff --git a/comphelper/source/property/MasterPropertySet.cxx b/comphelper/source/property/MasterPropertySet.cxx index b93025556d81..884f3d635628 100644 --- a/comphelper/source/property/MasterPropertySet.cxx +++ b/comphelper/source/property/MasterPropertySet.cxx @@ -141,7 +141,7 @@ void SAL_CALL MasterPropertySet::setPropertyValue( const ::rtl::OUString& rPrope PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! { @@ -175,7 +175,7 @@ Any SAL_CALL MasterPropertySet::getPropertyValue( const ::rtl::OUString& rProper PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); Any aAny; if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! @@ -257,7 +257,7 @@ void SAL_CALL MasterPropertySet::setPropertyValues( const Sequence< ::rtl::OUStr { aIter = mpInfo->maMap.find ( *pString ); if ( aIter == aEnd ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! _setSingleValue( *((*aIter).second->mpInfo), *pAny ); @@ -322,7 +322,7 @@ Sequence< Any > SAL_CALL MasterPropertySet::getPropertyValues( const Sequence< : { aIter = mpInfo->maMap.find ( *pString ); if ( aIter == aEnd ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! _getSingleValue( *((*aIter).second->mpInfo), *pAny ); @@ -381,7 +381,7 @@ PropertyState SAL_CALL MasterPropertySet::getPropertyState( const ::rtl::OUStrin { PropertyDataHash::const_iterator aIter = mpInfo->maMap.find( PropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) ); PropertyState aState; @@ -425,7 +425,7 @@ Sequence< PropertyState > SAL_CALL MasterPropertySet::getPropertyStates( const S { aIter = mpInfo->maMap.find ( *pString ); if ( aIter == aEnd ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pString, static_cast< XPropertySet* >( this ) ); if ( (*aIter).second->mnMapId == 0 ) // 0 means it's one of ours ! _getPropertyState( *((*aIter).second->mpInfo), *pState ); @@ -461,7 +461,7 @@ void SAL_CALL MasterPropertySet::setPropertyToDefault( const ::rtl::OUString& rP PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); _setPropertyToDefault( *((*aIter).second->mpInfo) ); } @@ -471,7 +471,7 @@ Any SAL_CALL MasterPropertySet::getPropertyDefault( const ::rtl::OUString& rProp PropertyDataHash::const_iterator aIter = mpInfo->maMap.find ( rPropertyName ); if( aIter == mpInfo->maMap.end()) - throw UnknownPropertyException(); + throw UnknownPropertyException( rPropertyName, static_cast< XPropertySet* >( this ) ); return _getPropertyDefault( *((*aIter).second->mpInfo) ); } diff --git a/comphelper/source/property/MasterPropertySetInfo.cxx b/comphelper/source/property/MasterPropertySetInfo.cxx index ac9f553270f7..e74d21b2d755 100644 --- a/comphelper/source/property/MasterPropertySetInfo.cxx +++ b/comphelper/source/property/MasterPropertySetInfo.cxx @@ -152,7 +152,7 @@ Property SAL_CALL MasterPropertySetInfo::getPropertyByName( const ::rtl::OUStrin PropertyDataHash::iterator aIter = maMap.find( rName ); if ( maMap.end() == aIter ) - throw UnknownPropertyException(); + throw UnknownPropertyException( rName, *this ); PropertyInfo *pInfo = (*aIter).second->mpInfo; Property aProperty; diff --git a/comphelper/source/property/composedprops.cxx b/comphelper/source/property/composedprops.cxx index 1d7fd18e2818..fe41319ebccc 100644 --- a/comphelper/source/property/composedprops.cxx +++ b/comphelper/source/property/composedprops.cxx @@ -225,7 +225,7 @@ namespace comphelper } else { - throw UnknownPropertyException(::rtl::OUString(), static_cast< XPropertySet* >(this)); + throw UnknownPropertyException( _rPropertyName, *this ); } return eState; @@ -335,7 +335,7 @@ namespace comphelper return *pProps; } - throw UnknownPropertyException(::rtl::OUString(), static_cast< XPropertySetInfo* >(this)); + throw UnknownPropertyException( _rName, *this ); } //------------------------------------------------------------------------------ diff --git a/comphelper/source/property/genericpropertyset.cxx b/comphelper/source/property/genericpropertyset.cxx index be9b898f30b4..08dd26dcf0ec 100644 --- a/comphelper/source/property/genericpropertyset.cxx +++ b/comphelper/source/property/genericpropertyset.cxx @@ -134,7 +134,7 @@ void SAL_CALL GenericPropertySet::addPropertyChangeListener( const ::rtl::OUStri else if ( xInfo->hasPropertyByName(aPropertyName) ) m_aListener.addInterface(aPropertyName,xListener); else - throw UnknownPropertyException(); + throw UnknownPropertyException( aPropertyName, *this ); } } @@ -158,7 +158,7 @@ void SAL_CALL GenericPropertySet::removePropertyChangeListener( const ::rtl::OUS else if ( xInfo->hasPropertyByName(aPropertyName) ) m_aListener.removeInterface(aPropertyName,xListener); else - throw UnknownPropertyException(); + throw UnknownPropertyException( aPropertyName, *this ); } } diff --git a/comphelper/source/property/propertycontainerhelper.cxx b/comphelper/source/property/propertycontainerhelper.cxx index e0c87545e33f..9d1662d1ecf2 100644 --- a/comphelper/source/property/propertycontainerhelper.cxx +++ b/comphelper/source/property/propertycontainerhelper.cxx @@ -492,7 +492,7 @@ const Property& OPropertyContainerHelper::getProperty( const ::rtl::OUString& _r PropertyDescriptionNameMatch( _rName ) ); if ( pos == m_aProperties.end() ) - throw UnknownPropertyException(); + throw UnknownPropertyException( _rName, NULL ); return pos->aProperty; } diff --git a/comphelper/source/property/propertysethelper.cxx b/comphelper/source/property/propertysethelper.cxx index 7b186beef2fe..7996585eb915 100644 --- a/comphelper/source/property/propertysethelper.cxx +++ b/comphelper/source/property/propertysethelper.cxx @@ -118,7 +118,7 @@ void SAL_CALL PropertySetHelper::setPropertyValue( const ::rtl::OUString& aPrope aEntries[0] = mp->find( aPropertyName ); if( NULL == aEntries[0] ) - throw UnknownPropertyException(); + throw UnknownPropertyException( aPropertyName, static_cast< XPropertySet* >( this ) ); aEntries[1] = NULL; @@ -131,7 +131,7 @@ Any SAL_CALL PropertySetHelper::getPropertyValue( const ::rtl::OUString& Propert aEntries[0] = mp->find( PropertyName ); if( NULL == aEntries[0] ) - throw UnknownPropertyException(); + throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) ); aEntries[1] = NULL; @@ -189,7 +189,7 @@ void SAL_CALL PropertySetHelper::setPropertyValues( const Sequence< ::rtl::OUStr delete[] pEntries; if( bUnknown ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pNames, static_cast< XPropertySet* >( this ) ); } } @@ -221,7 +221,7 @@ Sequence< Any > SAL_CALL PropertySetHelper::getPropertyValues( const Sequence< : delete[] pEntries; if( bUnknown ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pNames, static_cast< XPropertySet* >( this ) ); } return aValues; @@ -249,7 +249,7 @@ PropertyState SAL_CALL PropertySetHelper::getPropertyState( const ::rtl::OUStrin aEntries[0] = mp->find( PropertyName ); if( aEntries[0] == NULL ) - throw UnknownPropertyException(); + throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) ); aEntries[1] = NULL; @@ -288,7 +288,7 @@ Sequence< PropertyState > SAL_CALL PropertySetHelper::getPropertyStates( const S delete[] pEntries; if( bUnknown ) - throw UnknownPropertyException(); + throw UnknownPropertyException( *pNames, static_cast< XPropertySet* >( this ) ); } return aStates; @@ -298,7 +298,7 @@ void SAL_CALL PropertySetHelper::setPropertyToDefault( const ::rtl::OUString& Pr { PropertyMapEntry *pEntry = mp->find( PropertyName ); if( NULL == pEntry ) - throw UnknownPropertyException(); + throw UnknownPropertyException( PropertyName, static_cast< XPropertySet* >( this ) ); _setPropertyToDefault( pEntry ); } @@ -307,7 +307,7 @@ Any SAL_CALL PropertySetHelper::getPropertyDefault( const ::rtl::OUString& aProp { PropertyMapEntry* pEntry = mp->find( aPropertyName ); if( NULL == pEntry ) - throw UnknownPropertyException(); + throw UnknownPropertyException( aPropertyName, static_cast< XPropertySet* >( this ) ); return _getPropertyDefault( pEntry ); } diff --git a/comphelper/source/property/propertysetinfo.cxx b/comphelper/source/property/propertysetinfo.cxx index 11900fa71190..e155d695e2c9 100644 --- a/comphelper/source/property/propertysetinfo.cxx +++ b/comphelper/source/property/propertysetinfo.cxx @@ -151,7 +151,7 @@ Property PropertyMapImpl::getPropertyByName( const OUString& aName ) throw( Unkn PropertyMap::iterator aIter = maPropertyMap.find( aName ); if( maPropertyMap.end() == aIter ) - throw UnknownPropertyException(); + throw UnknownPropertyException( aName, NULL ); PropertyMapEntry* pEntry = (*aIter).second; diff --git a/goodies/source/unographic/graphicuno.cxx b/goodies/source/unographic/graphicuno.cxx index 6f096b6d204e..b47f04034336 100755 --- a/goodies/source/unographic/graphicuno.cxx +++ b/goodies/source/unographic/graphicuno.cxx @@ -38,11 +38,13 @@ #include "renderer.hxx" #include <com/sun/star/registry/XRegistryKey.hpp> +#include "comphelper/servicedecl.hxx" using namespace com::sun::star; +namespace sdecl = comphelper::service_decl; namespace unographic { - +extern sdecl::ServiceDecl const serviceDecl; // -------------------- // - *_createInstance - // -------------------- @@ -72,7 +74,7 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( const sal_Char* // - component_writeInfo - // ----------------------- -extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, void* pRegistryKey ) +extern "C" sal_Bool SAL_CALL component_writeInfo( void* pServiceManager, void* pRegistryKey ) { sal_Bool bRet = sal_False; @@ -106,6 +108,9 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, voi for( i = 0; i < aServices.getLength(); i++ ) xNewKey->createKey( aServices.getConstArray()[ i ] ); + if ( !component_writeInfoHelper( reinterpret_cast< lang::XMultiServiceFactory* >( pServiceManager ), reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ), serviceDecl ) ) + return false; + bRet = true; } catch (registry::InvalidRegistryException &) @@ -121,7 +126,7 @@ extern "C" sal_Bool SAL_CALL component_writeInfo( void* /*pServiceManager*/, voi // - component_getFactory - // ------------------------ -extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* /*pRegistryKey*/ ) +extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pServiceManager, void* pRegistryKey ) { void * pRet = 0; @@ -153,7 +158,11 @@ extern "C" void* SAL_CALL component_getFactory( const sal_Char* pImplName, void* pRet = xFactory.get(); } } + else + { + pRet = component_getFactoryHelper( pImplName, reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ),reinterpret_cast< registry::XRegistryKey* >( pRegistryKey ), serviceDecl ); + } return pRet; } diff --git a/goodies/source/unographic/graphicunofactory.cxx b/goodies/source/unographic/graphicunofactory.cxx new file mode 100644 index 000000000000..cdf9c51bf601 --- /dev/null +++ b/goodies/source/unographic/graphicunofactory.cxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: graphicunofactory.cxx,v $ + * $Revision: 1.1.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org 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 version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_goodies.hxx" +#include <comphelper/servicedecl.hxx> +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/graphic/XGraphicObject.hpp> +#include <com/sun/star/lang/IllegalArgumentException.hpp> +#include "grfmgr.hxx" + +using namespace com::sun::star; + +namespace unographic { + +typedef ::cppu::WeakImplHelper1< graphic::XGraphicObject > GObjectAccess_BASE; + // Simple uno wrapper around the GraphicObject class to allow basic + // access. ( and solves a horrible cyclic link problem between + // goodies/toolkit/extensions ) +class GObjectImpl : public GObjectAccess_BASE +{ + ::osl::Mutex m_aMutex; + std::auto_ptr< GraphicObject > mpGObject; +public: + GObjectImpl( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & xComponentContext ) throw (uno::RuntimeException); + + // XGraphicObject + virtual uno::Reference< graphic::XGraphic > SAL_CALL getGraphic() throw (uno::RuntimeException); + virtual void SAL_CALL setGraphic( const uno::Reference< graphic::XGraphic >& _graphic ) throw (uno::RuntimeException); + ::rtl::OUString SAL_CALL getUniqueID() throw (uno::RuntimeException); +}; + +GObjectImpl::GObjectImpl( uno::Sequence< uno::Any > const & args, uno::Reference< uno::XComponentContext > const & /*xComponentContext*/ ) throw (uno::RuntimeException) +{ + if ( args.getLength() == 1 ) + { + rtl::OUString sId; + if ( !( args[ 0 ] >>= sId ) || sId.getLength() == 0 ) + throw lang::IllegalArgumentException(); + ByteString bsId( sId.getStr(), RTL_TEXTENCODING_UTF8 ); + mpGObject.reset( new GraphicObject( bsId ) ); + } + else + mpGObject.reset( new GraphicObject() ); +} + +uno::Reference< graphic::XGraphic > SAL_CALL GObjectImpl::getGraphic() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !mpGObject.get() ) + throw uno::RuntimeException(); + return mpGObject->GetGraphic().GetXGraphic(); +} + +void SAL_CALL GObjectImpl::setGraphic( const uno::Reference< graphic::XGraphic >& _graphic ) throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + if ( !mpGObject.get() ) + throw uno::RuntimeException(); + Graphic aGraphic( _graphic ); + mpGObject->SetGraphic( aGraphic ); +} + +::rtl::OUString SAL_CALL GObjectImpl::getUniqueID() throw (uno::RuntimeException) +{ + ::osl::MutexGuard aGuard( m_aMutex ); + rtl::OUString sId; + if ( mpGObject.get() ) + sId = String( mpGObject->GetUniqueID().GetBuffer(), RTL_TEXTENCODING_ASCII_US ); + return sId; +} + + +namespace sdecl = comphelper::service_decl; +sdecl::class_<GObjectImpl, sdecl::with_args<true> > serviceBI; +extern sdecl::ServiceDecl const serviceDecl( serviceBI, "com.sun.star.graphic.GraphicObject", "com.sun.star.graphic.GraphicObject" ); + +} diff --git a/goodies/source/unographic/makefile.mk b/goodies/source/unographic/makefile.mk index 95e4e9025f20..59196031f089 100755 --- a/goodies/source/unographic/makefile.mk +++ b/goodies/source/unographic/makefile.mk @@ -8,7 +8,7 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.6 $ +# $Revision: 1.6.40.1 $ # # This file is part of OpenOffice.org. # @@ -47,6 +47,7 @@ CXXFILES= \ provider.cxx \ graphic.cxx \ renderer.cxx \ + graphicunofactory.cxx \ transformer.cxx SLOFILES= \ @@ -55,6 +56,7 @@ SLOFILES= \ $(SLO)$/provider.obj \ $(SLO)$/graphic.obj \ $(SLO)$/renderer.obj \ + $(SLO)$/graphicunofactory.obj \ $(SLO)$/transformer.obj # --- Target ------------------------------------------------------- diff --git a/goodies/source/unographic/provider.cxx b/goodies/source/unographic/provider.cxx index f59471628e3f..2eb0aede9bdf 100644 --- a/goodies/source/unographic/provider.cxx +++ b/goodies/source/unographic/provider.cxx @@ -54,12 +54,15 @@ #include "descriptor.hxx" #include "graphic.hxx" +#include "grfmgr.hxx" #include "provider.hxx" using namespace com::sun::star; namespace unographic { +#define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" + // ------------------- // - GraphicProvider - // ------------------- @@ -159,6 +162,24 @@ uno::Sequence< sal_Int8 > SAL_CALL GraphicProvider::getImplementationId() // ------------------------------------------------------------------------------ +uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadGraphicObject( const ::rtl::OUString& rResourceURL ) const +{ + uno::Reference< ::graphic::XGraphic > xRet; + if( rResourceURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) + { + // graphic manager url + String aTmpStr( rResourceURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ) ); + ByteString aUniqueID( aTmpStr, RTL_TEXTENCODING_UTF8 ); + GraphicObject aGrafObj( aUniqueID ); + // I don't call aGrafObj.GetXGraphic because it will call us back + // into implLoadMemory ( with "private:memorygraphic" test ) + ::unographic::Graphic* pUnoGraphic = new ::unographic::Graphic; + pUnoGraphic->init( aGrafObj.GetGraphic() ); + xRet = pUnoGraphic; + } + return xRet; +} + uno::Reference< ::graphic::XGraphic > GraphicProvider::implLoadMemory( const ::rtl::OUString& rResourceURL ) const { uno::Reference< ::graphic::XGraphic > xRet; @@ -382,9 +403,10 @@ uno::Reference< beans::XPropertySet > SAL_CALL GraphicProvider::queryGraphicDesc else if( aURL.getLength() ) { uno::Reference< ::graphic::XGraphic > xGraphic( implLoadMemory( aURL ) ); - if( !xGraphic.is() ) xGraphic = implLoadResource( aURL ); + if( !xGraphic.is() ) + xGraphic = implLoadGraphicObject( aURL ); if ( !xGraphic.is() ) xGraphic = implLoadRepositoryImage( aURL ); @@ -455,6 +477,9 @@ uno::Reference< ::graphic::XGraphic > SAL_CALL GraphicProvider::queryGraphic( co xRet = implLoadMemory( aPath ); if( !xRet.is() ) + xRet = implLoadGraphicObject( aPath ); + + if( !xRet.is() ) xRet = implLoadResource( aPath ); if ( !xRet.is() ) diff --git a/goodies/source/unographic/provider.hxx b/goodies/source/unographic/provider.hxx index 1b8ce1366b6b..d92866d1ed09 100644 --- a/goodies/source/unographic/provider.hxx +++ b/goodies/source/unographic/provider.hxx @@ -73,6 +73,7 @@ protected: private: ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > implLoadMemory( const ::rtl::OUString& rResourceURL ) const; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > implLoadGraphicObject( const ::rtl::OUString& rResourceURL ) const; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > implLoadResource( const ::rtl::OUString& rResourceURL ) const; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > implLoadRepositoryImage( const ::rtl::OUString& rResourceURL ) const; ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > implLoadBitmap( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XBitmap >& rBitmap ) const; diff --git a/svtools/inc/imageresourceaccess.hxx b/svtools/inc/imageresourceaccess.hxx index 80c34599c7a3..5b6767c5f7c9 100644 --- a/svtools/inc/imageresourceaccess.hxx +++ b/svtools/inc/imageresourceaccess.hxx @@ -45,22 +45,23 @@ namespace svt //........................................................................ //==================================================================== - //= ImageResourceAccess + //= GraphicAccess //==================================================================== /** helper class for obtaining streams (which also can be used with the ImageProducer) from a resource */ - class ImageResourceAccess + class GraphicAccess { private: - ImageResourceAccess(); // never implemented + GraphicAccess(); // never implemented public: /** determines whether the given URL denotes an image within a resource + ( or an image specified by a vnd.sun.star.GraphicObject scheme URL ) */ - SVT_DLLPUBLIC static bool isImageResourceURL( const ::rtl::OUString& _rURL ); + SVT_DLLPUBLIC static bool isSupportedURL( const ::rtl::OUString& _rURL ); - /** for a given URL of an image within a resource, this method retrieves + /** for a given URL of an image within a resource ( or an image specified by a vnd.sun.star.GraphicObject scheme URL ), this method retrieves an SvStream for this image. This method works for arbitrary URLs denoting an image, since the @@ -74,7 +75,7 @@ namespace svt const ::rtl::OUString& _rImageResourceURL ); - /** for a given URL of an image within a resource, this method retrieves + /** for a given URL of an image within a resource ( or an image specified by a vnd.sun.star.GraphicObject scheme URL ), this method retrieves an <type scope="com::sun::star::io">XInputStream</type> for this image. */ SVT_DLLPUBLIC static ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream > diff --git a/svtools/inc/numuno.hxx b/svtools/inc/numuno.hxx index 060e4bbc67d8..c31829dec020 100644 --- a/svtools/inc/numuno.hxx +++ b/svtools/inc/numuno.hxx @@ -38,6 +38,11 @@ class SvNumberFormatter; class SvNumFmtSuppl_Impl; +namespace comphelper +{ + class SharedMutex; +} + //------------------------------------------------------------------ // SvNumberFormatterServiceObj must be registered as service somewhere @@ -88,6 +93,8 @@ public: static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); static SvNumberFormatsSupplierObj* getImplementation( const com::sun::star::uno::Reference< com::sun::star::util::XNumberFormatsSupplier> xObj ); + + ::comphelper::SharedMutex& getSharedMutex() const; }; #endif // #ifndef _NUMUNO_HXX diff --git a/svtools/inc/svtools/inettbc.hxx b/svtools/inc/svtools/inettbc.hxx index 821c102d046a..338e3adb5a1a 100644 --- a/svtools/inc/svtools/inettbc.hxx +++ b/svtools/inc/svtools/inettbc.hxx @@ -50,6 +50,7 @@ friend class SvtMatchContext_Impl; friend class SvtURLBox_Impl; Link aOpenHdl; String aBaseURL; + String aPlaceHolder; SvtMatchContext_Impl* pCtx; SvtURLBox_Impl* pImp; INetProtocol eSmartProtocol; @@ -104,6 +105,9 @@ public: inline void EnableAutocompletion( BOOL _bEnable = TRUE ) { bIsAutoCompleteEnabled = _bEnable; } + void SetPlaceHolder( const String& sPlaceHolder ) { aPlaceHolder = sPlaceHolder; } + String GetPlaceHolder() { return aPlaceHolder; } + bool MatchesPlaceHolder( const String& sToMatch ) { return ( ( aPlaceHolder.Len() > 0 ) && ( aPlaceHolder == sToMatch ) ); } }; #endif diff --git a/svtools/source/config/extcolorcfg.cxx b/svtools/source/config/extcolorcfg.cxx index bc37a06a59b4..61ae3d1d0ca0 100644 --- a/svtools/source/config/extcolorcfg.cxx +++ b/svtools/source/config/extcolorcfg.cxx @@ -343,9 +343,13 @@ void ExtendedColorConfig_Impl::Load(const rtl::OUString& rScheme) if ( !sScheme.equalsAscii("default") ) { - ::rtl::OUString sBaseDefault(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/default")); - aComponentNames = GetPropertyNames(sBaseDefault); - FillComponentColors(aComponentNames,aDisplayNameMap); + ::rtl::OUString sDefault(RTL_CONSTASCII_USTRINGPARAM("default")); + if ( ExistsScheme(sDefault) ) + { + ::rtl::OUString sBaseDefault(RTL_CONSTASCII_USTRINGPARAM("ExtendedColorScheme/ColorSchemes/default")); + aComponentNames = GetPropertyNames(sBaseDefault); + FillComponentColors(aComponentNames,aDisplayNameMap); + } } // if ( !sScheme.equalsAscii("default") ) if ( !bFound && sScheme.getLength() ) { diff --git a/svtools/source/control/inettbc.cxx b/svtools/source/control/inettbc.cxx index c5f1d9ce7189..697ac5c10a38 100644 --- a/svtools/source/control/inettbc.cxx +++ b/svtools/source/control/inettbc.cxx @@ -1079,6 +1079,13 @@ long SvtURLBox::PreNotify( NotifyEvent& rNEvt ) SetSelection( Selection( nLen, GetText().Len() ) ); return TRUE; } + + if ( MatchesPlaceHolder( GetText() ) ) + { + // set the selection so a key stroke will overwrite + // the placeholder rather than edit it + SetSelection( Selection( 0, GetText().Len() ) ); + } } return ComboBox::PreNotify( rNEvt ); @@ -1148,6 +1155,8 @@ String SvtURLBox::GetURL() ::vos::OGuard aGuard( SvtMatchContext_Impl::GetMutex() ); String aText( GetText() ); + if ( MatchesPlaceHolder( aText ) ) + return aPlaceHolder; // try to get the right case preserving URL from the list of URLs if ( pImp->pCompletions && pImp->pURLs ) { diff --git a/svtools/source/misc/imageresourceaccess.cxx b/svtools/source/misc/imageresourceaccess.cxx index 62bb73890a72..b27bf6fa0174 100644 --- a/svtools/source/misc/imageresourceaccess.cxx +++ b/svtools/source/misc/imageresourceaccess.cxx @@ -51,6 +51,8 @@ namespace svt { //........................................................................ +#define GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" + using namespace ::utl; using namespace ::comphelper; using namespace ::com::sun::star::io; @@ -137,17 +139,17 @@ namespace svt } //==================================================================== - //= ImageResourceAccess + //= GraphicAccess //==================================================================== //-------------------------------------------------------------------- - bool ImageResourceAccess::isImageResourceURL( const ::rtl::OUString& _rURL ) + bool GraphicAccess::isSupportedURL( const ::rtl::OUString& _rURL ) { ::rtl::OUString sIndicator( RTL_CONSTASCII_USTRINGPARAM( "private:resource/" ) ); - return _rURL.indexOf( sIndicator ) == 0; + return ( ( _rURL.indexOf( sIndicator ) == 0 ) || ( _rURL.compareToAscii( GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( GRAPHOBJ_URLPREFIX ) ) == 0 ) ); } //-------------------------------------------------------------------- - SvStream* ImageResourceAccess::getImageStream( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rImageResourceURL ) + SvStream* GraphicAccess::getImageStream( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rImageResourceURL ) { SvStream* pReturn = NULL; @@ -157,7 +159,7 @@ namespace svt Reference< XGraphicProvider > xProvider; if ( _rxORB.is() ) xProvider = xProvider.query( _rxORB->createInstance( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.graphic.GraphicProvider" ) ) ) ); - OSL_ENSURE( xProvider.is(), "ImageResourceAccess::getImageStream: could not create a graphic provider!" ); + OSL_ENSURE( xProvider.is(), "GraphicAccess::getImageStream: could not create a graphic provider!" ); if ( !xProvider.is() ) return pReturn; @@ -167,7 +169,7 @@ namespace svt aMediaProperties[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "URL" ) ); aMediaProperties[0].Value <<= _rImageResourceURL; Reference< XGraphic > xGraphic( xProvider->queryGraphic( aMediaProperties ) ); - OSL_ENSURE( xGraphic.is(), "ImageResourceAccess::getImageStream: the provider did not give us a graphic object!" ); + OSL_ENSURE( xGraphic.is(), "GraphicAccess::getImageStream: the provider did not give us a graphic object!" ); if ( !xGraphic.is() ) return pReturn; @@ -190,14 +192,14 @@ namespace svt } catch( const Exception& ) { - OSL_ENSURE( sal_False, "ImageResourceAccess::getImageStream: caught an exception!" ); + OSL_ENSURE( sal_False, "GraphicAccess::getImageStream: caught an exception!" ); } return pReturn; } //-------------------------------------------------------------------- - Reference< XInputStream > ImageResourceAccess::getImageXStream( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rImageResourceURL ) + Reference< XInputStream > GraphicAccess::getImageXStream( const Reference< XMultiServiceFactory >& _rxORB, const ::rtl::OUString& _rImageResourceURL ) { return new OSeekableInputStreamWrapper( getImageStream( _rxORB, _rImageResourceURL ), sal_True ); // take ownership } diff --git a/svtools/source/numbers/numfmuno.cxx b/svtools/source/numbers/numfmuno.cxx index eba3cdf07540..5d9c88ec8760 100644 --- a/svtools/source/numbers/numfmuno.cxx +++ b/svtools/source/numbers/numfmuno.cxx @@ -135,15 +135,13 @@ LanguageType lcl_GetLanguage( const lang::Locale& rLocale ) //---------------------------------------------------------------------------------------- -SvNumberFormatterServiceObj::SvNumberFormatterServiceObj() : - pSupplier(NULL) +SvNumberFormatterServiceObj::SvNumberFormatterServiceObj() + :m_aMutex() { } SvNumberFormatterServiceObj::~SvNumberFormatterServiceObj() { - if (pSupplier) - pSupplier->release(); } com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvNumberFormatterServiceObj_CreateInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& ) @@ -154,38 +152,43 @@ com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL SvN // XNumberFormatter void SAL_CALL SvNumberFormatterServiceObj::attachNumberFormatsSupplier( - const uno::Reference<util::XNumberFormatsSupplier>& xSupplier ) + const uno::Reference<util::XNumberFormatsSupplier>& _xSupplier ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::rtl::Reference< SvNumberFormatsSupplierObj > xAutoReleaseOld; - SvNumberFormatsSupplierObj* pNew = SvNumberFormatsSupplierObj::getImplementation( xSupplier ); - if (!pNew) - throw uno::RuntimeException(); // wrong object + // SYNCHRONIZED -> + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + + SvNumberFormatsSupplierObj* pNew = SvNumberFormatsSupplierObj::getImplementation( _xSupplier ); + if (!pNew) + throw uno::RuntimeException(); // wrong object - if (pNew) - pNew->acquire(); - if (pSupplier) - pSupplier->release(); - pSupplier = pNew; + xAutoReleaseOld = xSupplier; + + xSupplier = pNew; + m_aMutex = xSupplier->getSharedMutex(); + } + // <- SYNCHRONIZED } uno::Reference<util::XNumberFormatsSupplier> SAL_CALL SvNumberFormatterServiceObj::getNumberFormatsSupplier() throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - return pSupplier; + ::osl::MutexGuard aGuard( m_aMutex ); + return xSupplier.get(); } sal_Int32 SAL_CALL SvNumberFormatterServiceObj::detectNumberFormat( sal_Int32 nKey, const rtl::OUString& aString ) throw(util::NotNumericException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aTemp = aString; @@ -206,10 +209,10 @@ double SAL_CALL SvNumberFormatterServiceObj::convertStringToNumber( sal_Int32 nKey, const rtl::OUString& aString ) throw(util::NotNumericException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); double fRet = 0.0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aTemp = aString; @@ -229,10 +232,10 @@ double SAL_CALL SvNumberFormatterServiceObj::convertStringToNumber( rtl::OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToString( sal_Int32 nKey, double fValue ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); String aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { Color* pColor = NULL; @@ -248,10 +251,10 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 double fValue, util::Color aDefaultColor ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); util::Color nRet = aDefaultColor; // color = INT32 - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aStr; @@ -270,10 +273,10 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForNumber( sal_Int32 rtl::OUString SAL_CALL SvNumberFormatterServiceObj::formatString( sal_Int32 nKey, const rtl::OUString& aString ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); String aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aTemp = aString; @@ -290,10 +293,10 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 const rtl::OUString& aString,util::Color aDefaultColor ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); util::Color nRet = aDefaultColor; // color = INT32 - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aTemp = aString; @@ -313,10 +316,10 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryColorForString( sal_Int32 rtl::OUString SAL_CALL SvNumberFormatterServiceObj::getInputString( sal_Int32 nKey, double fValue ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); String aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) pFormatter->GetInputLineString(fValue, nKey, aRet); else @@ -332,10 +335,10 @@ rtl::OUString SAL_CALL SvNumberFormatterServiceObj::convertNumberToPreviewString const lang::Locale& nLocale, sal_Bool bAllowEnglish ) throw(util::MalformedNumberFormatException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); String aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aOutString; @@ -368,10 +371,10 @@ util::Color SAL_CALL SvNumberFormatterServiceObj::queryPreviewColorForNumber( util::Color aDefaultColor ) throw(util::MalformedNumberFormatException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); util::Color nRet = aDefaultColor; // color = INT32 - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = xSupplier.is() ? xSupplier->GetNumberFormatter() : NULL; if (pFormatter) { String aOutString; @@ -427,17 +430,16 @@ uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatterServiceObj::getSupportedS //------------------------------------------------------------------------ -SvNumberFormatsObj::SvNumberFormatsObj(SvNumberFormatsSupplierObj* pParent) : - pSupplier(pParent) +SvNumberFormatsObj::SvNumberFormatsObj( SvNumberFormatsSupplierObj& _rParent, ::comphelper::SharedMutex& _rMutex ) + :rSupplier( _rParent ) + ,m_aMutex( _rMutex ) { - if (pSupplier) - pSupplier->acquire(); + rSupplier.acquire(); } SvNumberFormatsObj::~SvNumberFormatsObj() { - if (pSupplier) - pSupplier->release(); + rSupplier.release(); } // XNumberFormats @@ -445,12 +447,12 @@ SvNumberFormatsObj::~SvNumberFormatsObj() uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsObj::getByKey( sal_Int32 nKey ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL; if (pFormat) - return new SvNumberFormatObj( pSupplier, nKey ); + return new SvNumberFormatObj( rSupplier, nKey, m_aMutex ); else throw uno::RuntimeException(); } @@ -459,9 +461,9 @@ uno::Sequence<sal_Int32> SAL_CALL SvNumberFormatsObj::queryKeys( sal_Int16 nType const lang::Locale& nLocale, sal_Bool bCreate ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if ( pFormatter ) { sal_uInt32 nIndex = 0; @@ -485,10 +487,10 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::queryKey( const rtl::OUString& aFormat, const lang::Locale& nLocale, sal_Bool bScan ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { String aFormStr = aFormat; @@ -509,10 +511,10 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::addNew( const rtl::OUString& aFormat, const lang::Locale& nLocale ) throw(util::MalformedNumberFormatException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { String aFormStr = aFormat; @@ -540,10 +542,10 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const rtl::OUString& aFo const lang::Locale& nLocale, const lang::Locale& nNewLocale ) throw(util::MalformedNumberFormatException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { String aFormStr = aFormat; @@ -570,13 +572,13 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::addNewConverted( const rtl::OUString& aFo void SAL_CALL SvNumberFormatsObj::removeByKey( sal_Int32 nKey ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + ::osl::MutexGuard aGuard( m_aMutex ); + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { pFormatter->DeleteEntry(nKey); - pSupplier->NumberFormatDeleted(nKey); // Benachrichtigung fuers Dokument + rSupplier.NumberFormatDeleted(nKey); // Benachrichtigung fuers Dokument } } @@ -585,10 +587,10 @@ rtl::OUString SAL_CALL SvNumberFormatsObj::generateFormat( sal_Int32 nBaseKey, sal_Bool bRed, sal_Int16 nDecimals, sal_Int16 nLeading ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); String aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { LanguageType eLang = lcl_GetLanguage( nLocale ); @@ -605,10 +607,10 @@ rtl::OUString SAL_CALL SvNumberFormatsObj::generateFormat( sal_Int32 nBaseKey, sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardIndex( const lang::Locale& nLocale ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { LanguageType eLang = lcl_GetLanguage( nLocale ); @@ -623,10 +625,10 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardIndex( const lang::Locale& nLo sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardFormat( sal_Int16 nType, const lang::Locale& nLocale ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { LanguageType eLang = lcl_GetLanguage( nLocale ); @@ -644,10 +646,10 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::getStandardFormat( sal_Int16 nType, const sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatIndex( sal_Int16 nIndex, const lang::Locale& nLocale ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { LanguageType eLang = lcl_GetLanguage( nLocale ); @@ -662,10 +664,10 @@ sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatIndex( sal_Int16 nIndex, const l sal_Bool SAL_CALL SvNumberFormatsObj::isTypeCompatible( sal_Int16 nOldType, sal_Int16 nNewType ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); BOOL bRet = FALSE; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) bRet = pFormatter->IsCompatible( nOldType, nNewType ); else @@ -677,10 +679,10 @@ sal_Bool SAL_CALL SvNumberFormatsObj::isTypeCompatible( sal_Int16 nOldType, sal_ sal_Int32 SAL_CALL SvNumberFormatsObj::getFormatForLocale( sal_Int32 nKey, const lang::Locale& nLocale ) throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); INT32 nRet = 0; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { LanguageType eLang = lcl_GetLanguage( nLocale ); @@ -717,18 +719,17 @@ uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatsObj::getSupportedServiceNam //------------------------------------------------------------------------ -SvNumberFormatObj::SvNumberFormatObj(SvNumberFormatsSupplierObj* pParent, ULONG nK) : - pSupplier(pParent), - nKey(nK) +SvNumberFormatObj::SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, ULONG nK, const ::comphelper::SharedMutex& _rMutex ) + :rSupplier( rParent ) + ,nKey( nK ) + ,m_aMutex( _rMutex ) { - if (pSupplier) - pSupplier->acquire(); + rSupplier.acquire(); } SvNumberFormatObj::~SvNumberFormatObj() { - if (pSupplier) - pSupplier->release(); + rSupplier.release(); } // XPropertySet @@ -736,7 +737,7 @@ SvNumberFormatObj::~SvNumberFormatObj() uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatObj::getPropertySetInfo() throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); static uno::Reference<beans::XPropertySetInfo> aRef = new SfxItemPropertySetInfo( lcl_GetNumberFormatPropertyMap() ); return aRef; @@ -755,10 +756,10 @@ uno::Any SAL_CALL SvNumberFormatObj::getPropertyValue( const rtl::OUString& aPro throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); uno::Any aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL; if (pFormat) { @@ -885,9 +886,9 @@ void SAL_CALL SvNumberFormatObj::removeVetoableChangeListener( const rtl::OUStri uno::Sequence<beans::PropertyValue> SAL_CALL SvNumberFormatObj::getPropertyValues() throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); const SvNumberformat* pFormat = pFormatter ? pFormatter->GetEntry(nKey) : NULL; if (pFormat) { @@ -979,17 +980,16 @@ uno::Sequence<rtl::OUString> SAL_CALL SvNumberFormatObj::getSupportedServiceName //------------------------------------------------------------------------ -SvNumberFormatSettingsObj::SvNumberFormatSettingsObj(SvNumberFormatsSupplierObj* pParent) : - pSupplier(pParent) +SvNumberFormatSettingsObj::SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex ) + :rSupplier( rParent ) + ,m_aMutex( _rMutex ) { - if (pSupplier) - pSupplier->acquire(); + rSupplier.acquire(); } SvNumberFormatSettingsObj::~SvNumberFormatSettingsObj() { - if (pSupplier) - pSupplier->release(); + rSupplier.release(); } // XPropertySet @@ -997,7 +997,7 @@ SvNumberFormatSettingsObj::~SvNumberFormatSettingsObj() uno::Reference<beans::XPropertySetInfo> SAL_CALL SvNumberFormatSettingsObj::getPropertySetInfo() throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); static uno::Reference<beans::XPropertySetInfo> aRef = new SfxItemPropertySetInfo( lcl_GetNumberSettingsPropertyMap() ); return aRef; @@ -1009,9 +1009,9 @@ void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const rtl::OUString& lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { String aString = aPropertyName; @@ -1042,7 +1042,7 @@ void SAL_CALL SvNumberFormatSettingsObj::setPropertyValue( const rtl::OUString& else throw beans::UnknownPropertyException(); - pSupplier->SettingsChanged(); + rSupplier.SettingsChanged(); } else throw uno::RuntimeException(); @@ -1052,10 +1052,10 @@ uno::Any SAL_CALL SvNumberFormatSettingsObj::getPropertyValue( const rtl::OUStri throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( m_aMutex ); uno::Any aRet; - SvNumberFormatter* pFormatter = pSupplier ? pSupplier->GetNumberFormatter() : NULL; + SvNumberFormatter* pFormatter = rSupplier.GetNumberFormatter(); if (pFormatter) { String aString = aPropertyName; diff --git a/svtools/source/numbers/numfmuno.hxx b/svtools/source/numbers/numfmuno.hxx index d7ec25bf09b9..4148069fb37e 100644 --- a/svtools/source/numbers/numfmuno.hxx +++ b/svtools/source/numbers/numfmuno.hxx @@ -39,6 +39,8 @@ #include <com/sun/star/beans/XPropertyAccess.hpp> #include <cppuhelper/implbase2.hxx> #include <cppuhelper/implbase3.hxx> +#include <comphelper/sharedmutex.hxx> +#include <rtl/ref.hxx> class SvNumberformat; class SvNumberFormatter; @@ -53,7 +55,8 @@ class SvNumberFormatterServiceObj : public cppu::WeakImplHelper3< com::sun::star::lang::XServiceInfo> { private: - SvNumberFormatsSupplierObj* pSupplier; + ::rtl::Reference< SvNumberFormatsSupplierObj > xSupplier; + mutable ::comphelper::SharedMutex m_aMutex; public: SvNumberFormatterServiceObj(); @@ -116,11 +119,11 @@ class SvNumberFormatsObj : public cppu::WeakImplHelper3< com::sun::star::lang::XServiceInfo> { private: - SvNumberFormatsSupplierObj* pSupplier; + SvNumberFormatsSupplierObj& rSupplier; + mutable ::comphelper::SharedMutex m_aMutex; public: - SvNumberFormatsObj(); - SvNumberFormatsObj(SvNumberFormatsSupplierObj* pParent); + SvNumberFormatsObj(SvNumberFormatsSupplierObj& pParent, ::comphelper::SharedMutex& _rMutex); virtual ~SvNumberFormatsObj(); @@ -170,6 +173,9 @@ public: throw(::com::sun::star::uno::RuntimeException); virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + +private: + SvNumberFormatsObj(); // never implemented }; @@ -179,11 +185,12 @@ class SvNumberFormatObj : public cppu::WeakImplHelper3< com::sun::star::lang::XServiceInfo> { private: - SvNumberFormatsSupplierObj* pSupplier; - ULONG nKey; + SvNumberFormatsSupplierObj& rSupplier; + ULONG nKey; + mutable ::comphelper::SharedMutex m_aMutex; public: - SvNumberFormatObj(SvNumberFormatsSupplierObj* pParent, ULONG nK); + SvNumberFormatObj( SvNumberFormatsSupplierObj& rParent, ULONG nK, const ::comphelper::SharedMutex& _rMutex ); virtual ~SvNumberFormatObj(); // XPropertySet @@ -253,10 +260,11 @@ class SvNumberFormatSettingsObj : public cppu::WeakImplHelper2< com::sun::star::lang::XServiceInfo> { private: - SvNumberFormatsSupplierObj* pSupplier; + SvNumberFormatsSupplierObj& rSupplier; + mutable ::comphelper::SharedMutex m_aMutex; public: - SvNumberFormatSettingsObj(SvNumberFormatsSupplierObj* pParent); + SvNumberFormatSettingsObj( SvNumberFormatsSupplierObj& rParent, const ::comphelper::SharedMutex& _rMutex); virtual ~SvNumberFormatSettingsObj(); diff --git a/svtools/source/numbers/numuno.cxx b/svtools/source/numbers/numuno.cxx index f7746a000a17..f91bf82b4e60 100644 --- a/svtools/source/numbers/numuno.cxx +++ b/svtools/source/numbers/numuno.cxx @@ -53,7 +53,8 @@ using namespace com::sun::star; class SvNumFmtSuppl_Impl { public: - SvNumberFormatter* pFormatter; + SvNumberFormatter* pFormatter; + mutable ::comphelper::SharedMutex aMutex; SvNumFmtSuppl_Impl(SvNumberFormatter* p) : pFormatter(p) {} @@ -77,6 +78,11 @@ SvNumberFormatsSupplierObj::~SvNumberFormatsSupplierObj() delete pImpl; } +::comphelper::SharedMutex& SvNumberFormatsSupplierObj::getSharedMutex() const +{ + return pImpl->aMutex; +} + SvNumberFormatter* SvNumberFormatsSupplierObj::GetNumberFormatter() const { return pImpl->pFormatter; @@ -103,17 +109,17 @@ void SvNumberFormatsSupplierObj::SettingsChanged() uno::Reference<beans::XPropertySet> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormatSettings() throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( pImpl->aMutex ); - return new SvNumberFormatSettingsObj( this ); + return new SvNumberFormatSettingsObj( *this, pImpl->aMutex ); } uno::Reference<util::XNumberFormats> SAL_CALL SvNumberFormatsSupplierObj::getNumberFormats() throw(uno::RuntimeException) { - NAMESPACE_VOS(OGuard) aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( pImpl->aMutex ); - return new SvNumberFormatsObj( this ); + return new SvNumberFormatsObj( *this, pImpl->aMutex ); } // XUnoTunnel diff --git a/svtools/source/numbers/supservs.cxx b/svtools/source/numbers/supservs.cxx index bcdbf86d7754..1035cd056406 100644 --- a/svtools/source/numbers/supservs.cxx +++ b/svtools/source/numbers/supservs.cxx @@ -32,6 +32,7 @@ #include "precompiled_svtools.hxx" #include "supservs.hxx" #include <com/sun/star/lang/Locale.hpp> +#include <comphelper/sharedmutex.hxx> #include <i18npool/mslangid.hxx> #include <tools/debug.hxx> #include <vos/mutex.hxx> @@ -91,8 +92,7 @@ Any SAL_CALL SvNumberFormatsSupplierServiceObject::queryAggregation( const Type& //------------------------------------------------------------------------- void SAL_CALL SvNumberFormatsSupplierServiceObject::initialize( const Sequence< Any >& _rArguments ) throw(Exception, RuntimeException) { - OGuard aGuard(Application::GetSolarMutex()); - // the mutex of the base class .... hope we have a real (i.e. own) mutex sometimes + ::osl::MutexGuard aGuard( getSharedMutex() ); DBG_ASSERT(m_pOwnFormatter == NULL, "SvNumberFormatsSupplierServiceObject::initialize : already initialized !"); @@ -166,7 +166,7 @@ Sequence< ::rtl::OUString > SAL_CALL SvNumberFormatsSupplierServiceObject::getSu //------------------------------------------------------------------------- void SAL_CALL SvNumberFormatsSupplierServiceObject::write( const Reference< XObjectOutputStream >& _rxOutStream ) throw(IOException, RuntimeException) { - OGuard aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( getSharedMutex() ); implEnsureFormatter(); Reference< XOutputStream > xStream(_rxOutStream.get()); @@ -179,7 +179,7 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::write( const Reference< XObj //------------------------------------------------------------------------- void SAL_CALL SvNumberFormatsSupplierServiceObject::read( const Reference< XObjectInputStream >& _rxInStream ) throw(IOException, RuntimeException) { - OGuard aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( getSharedMutex() ); implEnsureFormatter(); Reference< XInputStream > xStream(_rxInStream.get()); @@ -191,7 +191,7 @@ void SAL_CALL SvNumberFormatsSupplierServiceObject::read( const Reference< XObje //------------------------------------------------------------------------- Reference< XPropertySet > SAL_CALL SvNumberFormatsSupplierServiceObject::getNumberFormatSettings() throw(RuntimeException) { - OGuard aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( getSharedMutex() ); implEnsureFormatter(); return SvNumberFormatsSupplierObj::getNumberFormatSettings(); } @@ -199,7 +199,7 @@ Reference< XPropertySet > SAL_CALL SvNumberFormatsSupplierServiceObject::getNumb //------------------------------------------------------------------------- Reference< XNumberFormats > SAL_CALL SvNumberFormatsSupplierServiceObject::getNumberFormats() throw(RuntimeException) { - OGuard aGuard(Application::GetSolarMutex()); + ::osl::MutexGuard aGuard( getSharedMutex() ); implEnsureFormatter(); return SvNumberFormatsSupplierObj::getNumberFormats(); } diff --git a/toolkit/inc/toolkit/controls/unocontrols.hxx b/toolkit/inc/toolkit/controls/unocontrols.hxx index 0c4f2e6962a6..97ba5fb045b6 100644 --- a/toolkit/inc/toolkit/controls/unocontrols.hxx +++ b/toolkit/inc/toolkit/controls/unocontrols.hxx @@ -54,6 +54,7 @@ #include <com/sun/star/awt/XCurrencyField.hpp> #include <com/sun/star/awt/XPatternField.hpp> #include <com/sun/star/awt/XProgressBar.hpp> +#include <com/sun/star/graphic/XGraphicObject.hpp> #include <toolkit/controls/unocontrolmodel.hxx> #include <toolkit/controls/unocontrolbase.hxx> #include <toolkit/helper/macros.hxx> @@ -67,6 +68,9 @@ #include <list> +#define UNO_NAME_GRAPHOBJ_URLPREFIX "vnd.sun.star.GraphicObject:" +#define UNO_NAME_GRAPHOBJ_URLPKGPREFIX "vnd.sun.star.Package:" + // ---------------------------------------------------- // class UnoControlEditModel @@ -220,6 +224,8 @@ private: bool mbAdjustingImagePosition; bool mbAdjustingGraphic; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphicObject > mxGrfObj; + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ); protected: ImageProducerControlModel() : mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { } ImageProducerControlModel( const ImageProducerControlModel& _rSource ) : com::sun::star::awt::XImageProducer(), UnoControlModel( _rSource ), mbAdjustingImagePosition( false ), mbAdjustingGraphic( false ) { } @@ -346,6 +352,8 @@ public: // ---------------------------------------------------- class UnoControlImageControlModel : public ImageProducerControlModel { +private: + bool mbAdjustingImageScaleMode; protected: ::com::sun::star::uno::Any ImplGetDefaultValue( sal_uInt16 nPropId ) const; @@ -353,7 +361,7 @@ protected: public: UnoControlImageControlModel(); - UnoControlImageControlModel( const UnoControlImageControlModel& rModel ) : ImageProducerControlModel( rModel ) {;} + UnoControlImageControlModel( const UnoControlImageControlModel& rModel ) : ImageProducerControlModel( rModel ), mbAdjustingImageScaleMode( false ) { } UnoControlModel* Clone() const { return new UnoControlImageControlModel( *this ); } @@ -365,6 +373,9 @@ public: // ::com::sun::star::lang::XServiceInfo DECLIMPL_SERVICEINFO_DERIVED( UnoControlImageControlModel, ImageProducerControlModel, szServiceName2_UnoControlImageControlModel ) + + // ::cppu::OPropertySetHelper + void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception); }; // ---------------------------------------------------- diff --git a/toolkit/inc/toolkit/helper/property.hxx b/toolkit/inc/toolkit/helper/property.hxx index 5e30558a3ee6..ef2f06ba12af 100644 --- a/toolkit/inc/toolkit/helper/property.hxx +++ b/toolkit/inc/toolkit/helper/property.hxx @@ -188,6 +188,7 @@ namespace rtl { #define BASEPROPERTY_URL 134 // ::rtl::OUString #define BASEPROPERTY_UNIT 135 // ::awt::FieldUnit #define BASEPROPERTY_CUSTOMUNITTEXT 136 // ::rtl::OUString +#define BASEPROPERTY_IMAGE_SCALE_MODE 137 // Keine gebundenen Properties, werden immer aus der Property BASEPROPERTY_FONTDESCRIPTOR entnommen. #define BASEPROPERTY_FONTDESCRIPTORPART_START 1000 diff --git a/toolkit/source/awt/vclxtoolkit.cxx b/toolkit/source/awt/vclxtoolkit.cxx index 80937076a5ea..8cb7ed60f2a4 100644 --- a/toolkit/source/awt/vclxtoolkit.cxx +++ b/toolkit/source/awt/vclxtoolkit.cxx @@ -146,6 +146,27 @@ TOOLKIT_DLLPUBLIC WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt bMessBox = sal_True; } + bool bDecoratedWindow = false; + if ( bMessBox + || ( nCompType == WINDOW_DIALOG ) + || ( nCompType == WINDOW_MODELESSDIALOG ) + || ( nCompType == WINDOW_MODALDIALOG ) + || ( nCompType == WINDOW_SYSTEMDIALOG ) + || ( nCompType == WINDOW_PATHDIALOG ) + || ( nCompType == WINDOW_FILEDIALOG ) + || ( nCompType == WINDOW_PRINTERSETUPDIALOG ) + || ( nCompType == WINDOW_PRINTDIALOG ) + || ( nCompType == WINDOW_COLORDIALOG ) + || ( nCompType == WINDOW_FONTDIALOG ) + || ( nCompType == WINDOW_DOCKINGWINDOW ) + || ( nCompType == WINDOW_TABDIALOG ) + || ( nCompType == WINDOW_BUTTONDIALOG ) + || ( nCompType == WINDOW_SYSTEMCHILDWINDOW ) + ) + { + bDecoratedWindow = true; + } + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::BORDER ) nWinBits |= WB_BORDER; if( nComponentAttribs & ::com::sun::star::awt::VclWindowPeerAttribute::NOBORDER ) @@ -216,15 +237,18 @@ TOOLKIT_DLLPUBLIC WinBits ImplGetWinBits( sal_uInt32 nComponentAttribs, sal_uInt } - if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::NODECORATION ) + if ( bDecoratedWindow ) { - // No decoration removes several window attributes and must - // set WB_NOBODER! - nWinBits &= ~WB_BORDER; - nWinBits &= ~WB_SIZEABLE; - nWinBits &= ~WB_MOVEABLE; - nWinBits &= ~WB_CLOSEABLE; - nWinBits |= WB_NOBORDER; + if( nComponentAttribs & ::com::sun::star::awt::WindowAttribute::NODECORATION ) + { + // No decoration removes several window attributes and must + // set WB_NOBORDER! + nWinBits &= ~WB_BORDER; + nWinBits &= ~WB_SIZEABLE; + nWinBits &= ~WB_MOVEABLE; + nWinBits &= ~WB_CLOSEABLE; + nWinBits |= WB_NOBORDER; + } } return nWinBits; diff --git a/toolkit/source/awt/vclxwindows.cxx b/toolkit/source/awt/vclxwindows.cxx index 06e41611f793..23b59f37f56f 100644 --- a/toolkit/source/awt/vclxwindows.cxx +++ b/toolkit/source/awt/vclxwindows.cxx @@ -45,6 +45,7 @@ #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/system/XSystemShellExecute.hpp> #include <com/sun/star/system/SystemShellExecuteFlags.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> #include <comphelper/processfactory.hxx> #ifndef _SV_BUTTON_HXX @@ -69,6 +70,7 @@ using ::com::sun::star::graphic::XGraphic; using namespace ::com::sun::star; using namespace ::com::sun::star::awt::VisualEffect; +namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; static double ImplCalcLongValue( double nValue, sal_uInt16 nDigits ) { @@ -663,6 +665,7 @@ void VCLXImageControl::ImplGetPropertyIds( std::list< sal_uInt16 > &rIds ) BASEPROPERTY_IMAGEURL, BASEPROPERTY_PRINTABLE, BASEPROPERTY_SCALEIMAGE, + BASEPROPERTY_IMAGE_SCALE_MODE, BASEPROPERTY_TABSTOP, 0); VCLXImageConsumer::ImplGetPropertyIds( rIds ); @@ -716,22 +719,34 @@ void VCLXImageControl::setProperty( const ::rtl::OUString& PropertyName, const : ::vos::OGuard aGuard( GetMutex() ); ImageControl* pImageControl = (ImageControl*)GetWindow(); - if ( pImageControl ) + + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) + case BASEPROPERTY_IMAGE_SCALE_MODE: { - case BASEPROPERTY_SCALEIMAGE: + sal_Int16 nScaleMode( ImageScaleMode::Anisotropic ); + if ( pImageControl && ( Value >>= nScaleMode ) ) { - sal_Bool b = sal_Bool(); - if ( Value >>= b ) - pImageControl->SetScaleImage( b ); + pImageControl->SetScaleMode( nScaleMode ); } - break; - default: - VCLXImageConsumer::setProperty( PropertyName, Value ); - break; } + break; + + case BASEPROPERTY_SCALEIMAGE: + { + // this is for compatibility only, nowadays, the ImageScaleMode property should be used + sal_Bool bScaleImage = sal_False; + if ( pImageControl && ( Value >>= bScaleImage ) ) + { + pImageControl->SetScaleMode( bScaleImage ? ImageScaleMode::Anisotropic : ImageScaleMode::None ); + } + } + break; + + default: + VCLXImageConsumer::setProperty( PropertyName, Value ); + break; } } @@ -741,18 +756,21 @@ void VCLXImageControl::setProperty( const ::rtl::OUString& PropertyName, const : ::com::sun::star::uno::Any aProp; ImageControl* pImageControl = (ImageControl*)GetWindow(); - if ( pImageControl ) + sal_uInt16 nPropType = GetPropertyId( PropertyName ); + + switch ( nPropType ) { - sal_uInt16 nPropType = GetPropertyId( PropertyName ); - switch ( nPropType ) - { - case BASEPROPERTY_SCALEIMAGE: - aProp <<= (sal_Bool)pImageControl->IsScaleImage(); - break; - default: - aProp = VCLXImageConsumer::getProperty( PropertyName ); - break; - } + case BASEPROPERTY_IMAGE_SCALE_MODE: + aProp <<= ( pImageControl ? pImageControl->GetScaleMode() : ImageScaleMode::Anisotropic ); + break; + + case BASEPROPERTY_SCALEIMAGE: + aProp <<= ( pImageControl && pImageControl->GetScaleMode() != ImageScaleMode::None ) ? sal_True : sal_False; + break; + + default: + aProp = VCLXImageConsumer::getProperty( PropertyName ); + break; } return aProp; } diff --git a/toolkit/source/controls/unocontrolmodel.cxx b/toolkit/source/controls/unocontrolmodel.cxx index e9327d82a7b0..74846ed7071d 100644 --- a/toolkit/source/controls/unocontrolmodel.cxx +++ b/toolkit/source/controls/unocontrolmodel.cxx @@ -308,7 +308,6 @@ void UnoControlModel::ImplPropertyChanged( sal_uInt16 ) case BASEPROPERTY_REPEAT_DELAY: aDefault <<= (sal_Int32) 50; break; // 50 milliseconds case BASEPROPERTY_DEFAULTCONTROL: aDefault <<= ((UnoControlModel*)this)->getServiceName(); break; - case BASEPROPERTY_AUTOHSCROLL: case BASEPROPERTY_AUTOVSCROLL: case BASEPROPERTY_MOVEABLE: diff --git a/toolkit/source/controls/unocontrols.cxx b/toolkit/source/controls/unocontrols.cxx index a269b6183ea1..40536a66d124 100644 --- a/toolkit/source/controls/unocontrols.cxx +++ b/toolkit/source/controls/unocontrols.cxx @@ -37,7 +37,9 @@ #include <com/sun/star/awt/VisualEffect.hpp> #include <com/sun/star/awt/LineEndFormat.hpp> #include <com/sun/star/graphic/XGraphicProvider.hpp> +#include <com/sun/star/graphic/GraphicObject.hpp> #include <com/sun/star/util/Date.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> #include <toolkit/controls/formattedcontrol.hxx> @@ -576,11 +578,21 @@ uno::Any ImageProducerControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) co return UnoControlModel::ImplGetDefaultValue( nPropId ); } -namespace -{ - uno::Reference< graphic::XGraphic > lcl_getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ) + uno::Reference< graphic::XGraphic > ImageProducerControlModel::getGraphicFromURL_nothrow( const ::rtl::OUString& _rURL ) { uno::Reference< graphic::XGraphic > xGraphic; + + if( ( _rURL.compareToAscii( UNO_NAME_GRAPHOBJ_URLPREFIX, RTL_CONSTASCII_LENGTH( UNO_NAME_GRAPHOBJ_URLPREFIX ) ) == 0 ) ) + { + // graphic manager uniqueid + rtl::OUString sID = _rURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 ); + // get the DefaultContext + ::comphelper::ComponentContext aContext( ::comphelper::getProcessServiceFactory() ); + mxGrfObj = graphic::GraphicObject::createWithId( aContext.getUNOContext(), sID ); + } + else // linked + mxGrfObj = NULL; // release the GraphicObject + if ( !_rURL.getLength() ) return xGraphic; @@ -603,7 +615,6 @@ namespace return xGraphic; } -} void SAL_CALL ImageProducerControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) throw (::com::sun::star::uno::Exception) { @@ -621,7 +632,7 @@ void SAL_CALL ImageProducerControlModel::setFastPropertyValue_NoBroadcast( sal_I mbAdjustingGraphic = true; ::rtl::OUString sImageURL; OSL_VERIFY( rValue >>= sImageURL ); - setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( lcl_getGraphicFromURL_nothrow( sImageURL ) ) ); + setPropertyValue( GetPropertyName( BASEPROPERTY_GRAPHIC ), uno::makeAny( getGraphicFromURL_nothrow( sImageURL ) ) ); mbAdjustingGraphic = false; } break; @@ -942,6 +953,7 @@ awt::Size UnoButtonControl::calcAdjustedSize( const awt::Size& rNewSize ) throw( // class UnoControlImageControlModel // ---------------------------------------------------- UnoControlImageControlModel::UnoControlImageControlModel() + :mbAdjustingImageScaleMode( false ) { UNO_CONTROL_MODEL_REGISTER_PROPERTIES( VCLXImageControl ); } @@ -956,6 +968,9 @@ uno::Any UnoControlImageControlModel::ImplGetDefaultValue( sal_uInt16 nPropId ) if ( nPropId == BASEPROPERTY_DEFAULTCONTROL ) return uno::makeAny( ::rtl::OUString::createFromAscii( szServiceName_UnoControlImageControl ) ); + if ( nPropId == BASEPROPERTY_IMAGE_SCALE_MODE ) + return makeAny( awt::ImageScaleMode::Anisotropic ); + return ImageProducerControlModel::ImplGetDefaultValue( nPropId ); } @@ -977,6 +992,44 @@ uno::Reference< beans::XPropertySetInfo > UnoControlImageControlModel::getProper return xInfo; } +void SAL_CALL UnoControlImageControlModel::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const ::com::sun::star::uno::Any& _rValue ) throw (::com::sun::star::uno::Exception) +{ + ImageProducerControlModel::setFastPropertyValue_NoBroadcast( _nHandle, _rValue ); + + // ScaleImage is an older (and less powerful) version of ScaleMode, but keep both in sync as far as possible + try + { + switch ( _nHandle ) + { + case BASEPROPERTY_IMAGE_SCALE_MODE: + if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_SCALEIMAGE ) ) + { + mbAdjustingImageScaleMode = true; + sal_Int16 nScaleMode( awt::ImageScaleMode::Anisotropic ); + OSL_VERIFY( _rValue >>= nScaleMode ); + setPropertyValue( GetPropertyName( BASEPROPERTY_SCALEIMAGE ), uno::makeAny( sal_Bool( nScaleMode != awt::ImageScaleMode::None ) ) ); + mbAdjustingImageScaleMode = false; + } + break; + case BASEPROPERTY_SCALEIMAGE: + if ( !mbAdjustingImageScaleMode && ImplHasProperty( BASEPROPERTY_IMAGE_SCALE_MODE ) ) + { + mbAdjustingImageScaleMode = true; + sal_Bool bScale = sal_True; + OSL_VERIFY( _rValue >>= bScale ); + setPropertyValue( GetPropertyName( BASEPROPERTY_IMAGE_SCALE_MODE ), uno::makeAny( bScale ? awt::ImageScaleMode::Anisotropic : awt::ImageScaleMode::None ) ); + mbAdjustingImageScaleMode = false; + } + break; + } + } + catch( const Exception& ) + { + mbAdjustingImageScaleMode = false; + throw; + } +} + // ---------------------------------------------------- // class UnoImageControlControl // ---------------------------------------------------- diff --git a/toolkit/source/helper/formpdfexport.cxx b/toolkit/source/helper/formpdfexport.cxx index e57d238b8982..2b5fe908bedf 100644 --- a/toolkit/source/helper/formpdfexport.cxx +++ b/toolkit/source/helper/formpdfexport.cxx @@ -8,7 +8,7 @@ * * $RCSfile: formpdfexport.cxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.2.6.1 $ * * This file is part of OpenOffice.org. * @@ -374,8 +374,10 @@ namespace toolkitform if ( xPSI->hasPropertyByName( sBorderColorPropertyName ) ) { sal_Int32 nBoderColor = COL_TRANSPARENT; - xModelProps->getPropertyValue( sBorderColorPropertyName ) >>= nBoderColor; - _rpDescriptor->BorderColor = Color( nBoderColor ); + if ( xModelProps->getPropertyValue( sBorderColorPropertyName ) >>= nBoderColor ) + _rpDescriptor->BorderColor = Color( nBoderColor ); + else + _rpDescriptor->BorderColor = Color( COL_BLACK ); } } } diff --git a/toolkit/source/helper/property.cxx b/toolkit/source/helper/property.cxx index 17122badfe1d..16181629c9d4 100644 --- a/toolkit/source/helper/property.cxx +++ b/toolkit/source/helper/property.cxx @@ -215,6 +215,7 @@ ImplPropertyInfo* ImplGetPropertyInfos( sal_uInt16& rElementCount ) DECL_PROP_2 ( "RepeatDelay", REPEAT_DELAY, sal_Int32, BOUND, MAYBEDEFAULT ), // DECL_PROP_3 ( "ResourceResolver", RESOURCERESOLVER, Reference< ::com::sun::star::resource::XStringResourceResolver >, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "ScaleImage", SCALEIMAGE, bool, BOUND, MAYBEDEFAULT ), + DECL_PROP_2 ( "ScaleMode", IMAGE_SCALE_MODE, sal_Int16, BOUND, MAYBEDEFAULT ), DECL_DEP_PROP_3 ( "ScrollValue", SCROLLVALUE, sal_Int32, BOUND, MAYBEDEFAULT, MAYBEVOID ), DECL_PROP_2 ( "ScrollValueMax", SCROLLVALUE_MAX, sal_Int32, BOUND, MAYBEDEFAULT ), DECL_PROP_2 ( "ScrollValueMin", SCROLLVALUE_MIN, sal_Int32, BOUND, MAYBEDEFAULT ), diff --git a/vcl/inc/vcl/imgctrl.hxx b/vcl/inc/vcl/imgctrl.hxx index 2a9486f3e3cb..04d74799bdda 100644 --- a/vcl/inc/vcl/imgctrl.hxx +++ b/vcl/inc/vcl/imgctrl.hxx @@ -45,13 +45,14 @@ class VCL_DLLPUBLIC ImageControl : public FixedImage private: BitmapEx maBmp; BitmapEx maBmpHC; - BOOL mbScaleImage; + ::sal_Int16 mnScaleMode; public: ImageControl( Window* pParent, WinBits nStyle = 0 ); - void SetScaleImage( BOOL bScale ); - BOOL IsScaleImage() const; + // set/get the scale mode. This is one of the css.awt.ImageScaleMode constants + void SetScaleMode( const ::sal_Int16 _nMode ); + ::sal_Int16 GetScaleMode() const { return mnScaleMode; } virtual void Resize(); virtual void UserDraw( const UserDrawEvent& rUDEvt ); diff --git a/vcl/source/control/fixed.cxx b/vcl/source/control/fixed.cxx index a3b26de8314d..530e928532e1 100644 --- a/vcl/source/control/fixed.cxx +++ b/vcl/source/control/fixed.cxx @@ -230,7 +230,7 @@ USHORT FixedText::ImplGetTextStyle( WinBits nWinStyle ) if ( nWinStyle & WB_WORDBREAK ) { nTextStyle |= TEXT_DRAW_WORDBREAK; - if ( nWinStyle & WB_HYPHENATION ) + if ( (nWinStyle & WB_HYPHENATION ) == WB_HYPHENATION ) nTextStyle |= TEXT_DRAW_WORDBREAK_HYPHENATION; } if ( nWinStyle & WB_NOLABEL ) diff --git a/vcl/source/control/imgctrl.cxx b/vcl/source/control/imgctrl.cxx index 5287653bd367..e6930edeba95 100644 --- a/vcl/source/control/imgctrl.cxx +++ b/vcl/source/control/imgctrl.cxx @@ -30,42 +30,61 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_vcl.hxx" + #include <vcl/event.hxx> #include <vcl/imgctrl.hxx> +#include <com/sun/star/awt/ImageScaleMode.hdl> + +namespace ImageScaleMode = ::com::sun::star::awt::ImageScaleMode; + // ----------------------------------------------------------------------- ImageControl::ImageControl( Window* pParent, WinBits nStyle ) : FixedImage( pParent, nStyle ) { - mbScaleImage = TRUE; + mnScaleMode = ImageScaleMode::Anisotropic; } // ----------------------------------------------------------------------- -void ImageControl::SetScaleImage( BOOL bScale ) +void ImageControl::SetScaleMode( const ::sal_Int16 _nMode ) { - if ( bScale != mbScaleImage ) + if ( _nMode != mnScaleMode ) { - mbScaleImage = bScale; + mnScaleMode = _nMode; Invalidate(); } } // ----------------------------------------------------------------------- -BOOL ImageControl::IsScaleImage() const +void ImageControl::Resize() { - // Make inline when changing member from dummy... - return mbScaleImage; + Invalidate(); } - // ----------------------------------------------------------------------- - -void ImageControl::Resize() +namespace { - Invalidate(); + static Size lcl_calcPaintSize( const Rectangle& _rPaintRect, const Size& _rBitmapSize ) + { + const Size aPaintSize = _rPaintRect.GetSize(); + + const double nRatioX = 1.0 * aPaintSize.Width() / _rBitmapSize.Width(); + const double nRatioY = 1.0 * aPaintSize.Height() / _rBitmapSize.Height(); + const double nRatioMin = ::std::min( nRatioX, nRatioY ); + + return Size( long( _rBitmapSize.Width() * nRatioMin ), long( _rBitmapSize.Height() * nRatioMin ) ); + } + + static Point lcl_centerWithin( const Rectangle& _rArea, const Size& _rObjectSize ) + { + Point aPos( _rArea.TopLeft() ); + aPos.X() += ( _rArea.GetWidth() - _rObjectSize.Width() ) / 2; + aPos.Y() += ( _rArea.GetHeight() - _rObjectSize.Height() ) / 2; + return aPos; + } } // ----------------------------------------------------------------------- @@ -84,42 +103,82 @@ void ImageControl::UserDraw( const UserDrawEvent& rUDEvt ) // nStyle |= IMAGE_DRAW_COLORTRANSFORM; } + const Rectangle& rPaintRect = rUDEvt.GetRect(); + const Size& rBitmapSize = maBmp.GetSizePixel(); + if( nStyle & IMAGE_DRAW_COLORTRANSFORM ) { // only images support IMAGE_DRAW_COLORTRANSFORM Image aImage( maBmp ); if ( !!aImage ) { - if ( mbScaleImage ) - rUDEvt.GetDevice()->DrawImage( rUDEvt.GetRect().TopLeft(), - rUDEvt.GetRect().GetSize(), - aImage, nStyle ); - else + switch ( mnScaleMode ) { - // Center... - Point aPos( rUDEvt.GetRect().TopLeft() ); - aPos.X() += ( rUDEvt.GetRect().GetWidth() - maBmp.GetSizePixel().Width() ) / 2; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - maBmp.GetSizePixel().Height() ) / 2; - rUDEvt.GetDevice()->DrawImage( aPos, aImage, nStyle ); + case ImageScaleMode::None: + { + rUDEvt.GetDevice()->DrawImage( + lcl_centerWithin( rPaintRect, rBitmapSize ), aImage, nStyle ); } + break; + + case ImageScaleMode::Isotropic: + { + const Size aPaintSize = lcl_calcPaintSize( rPaintRect, rBitmapSize ); + rUDEvt.GetDevice()->DrawImage( + lcl_centerWithin( rPaintRect, aPaintSize ), + aPaintSize, + aImage, nStyle ); + } + break; + + case ImageScaleMode::Anisotropic: + { + rUDEvt.GetDevice()->DrawImage( + rPaintRect.TopLeft(), + rPaintRect.GetSize(), + aImage, nStyle ); + } + break; + + default: + OSL_ENSURE( false, "ImageControl::UserDraw: unhandled scale mode!" ); + break; + + } // switch ( mnScaleMode ) } } else { - if ( mbScaleImage ) + switch ( mnScaleMode ) { + case ImageScaleMode::None: + { + maBmp.Draw( rUDEvt.GetDevice(), lcl_centerWithin( rPaintRect, rBitmapSize ) ); + } + break; + + case ImageScaleMode::Isotropic: + { + const Size aPaintSize = lcl_calcPaintSize( rPaintRect, rBitmapSize ); maBmp.Draw( rUDEvt.GetDevice(), - rUDEvt.GetRect().TopLeft(), - rUDEvt.GetRect().GetSize() ); + lcl_centerWithin( rPaintRect, aPaintSize ), + aPaintSize ); } - else + break; + + case ImageScaleMode::Anisotropic: { - // Center... - Point aPos( rUDEvt.GetRect().TopLeft() ); - aPos.X() += ( rUDEvt.GetRect().GetWidth() - maBmp.GetSizePixel().Width() ) / 2; - aPos.Y() += ( rUDEvt.GetRect().GetHeight() - maBmp.GetSizePixel().Height() ) / 2; - maBmp.Draw( rUDEvt.GetDevice(), aPos ); + maBmp.Draw( rUDEvt.GetDevice(), + rPaintRect.TopLeft(), + rPaintRect.GetSize() ); } + break; + + default: + OSL_ENSURE( false, "ImageControl::UserDraw: unhandled scale mode!" ); + break; + + } // switch ( mnScaleMode ) } } diff --git a/vcl/workben/svpclient.cxx b/vcl/workben/svpclient.cxx index 5b735430f8f9..cf64d58110e8 100644 --- a/vcl/workben/svpclient.cxx +++ b/vcl/workben/svpclient.cxx @@ -30,6 +30,7 @@ #include <sal/main.h> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/awt/ImageScaleMode.hpp> #include <vcl/event.hxx> #include <vcl/svapp.hxx> @@ -141,7 +142,7 @@ MyWin::MyWin( Window* pParent, WinBits nWinStyle ) : m_aSvpBitmaps.Show(); m_aImage.SetPosSizePixel( Point( 170, 10 ), Size( 400, 400 ) ); - m_aImage.SetScaleImage( FALSE ); + m_aImage.SetScaleMode( com::sun::star::awt::ImageScaleMode::None ); m_aImage.Show(); m_aQuitButton.SetPosSizePixel( Point( 10, 300 ), Size( 120,25 ) ); |