diff options
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/viewoptions.hxx | 7 | ||||
-rw-r--r-- | unotools/source/config/securityoptions.cxx | 13 | ||||
-rw-r--r-- | unotools/source/config/viewoptions.cxx | 40 |
3 files changed, 51 insertions, 9 deletions
diff --git a/unotools/inc/unotools/viewoptions.hxx b/unotools/inc/unotools/viewoptions.hxx index 34c00590dc0a..faad44186ea3 100644 --- a/unotools/inc/unotools/viewoptions.hxx +++ b/unotools/inc/unotools/viewoptions.hxx @@ -264,6 +264,13 @@ class UNOTOOLS_DLLPUBLIC SvtViewOptions: public utl::detail::Options sal_Bool IsVisible ( ) const; void SetVisible( sal_Bool bState ); + /** Return true if the "Visible" property actually has a non-nil value + + (IsVisible will somewhat arbitrarily return false if the property is + nil.) + */ + bool HasVisible() const; + /*-****************************************************************************************************//** @short use it to set/get the extended user data (consisting of a set of named scalar values) @descr It's supported for ALL types! diff --git a/unotools/source/config/securityoptions.cxx b/unotools/source/config/securityoptions.cxx index 01e1abd3a267..7429e2bde441 100644 --- a/unotools/source/config/securityoptions.cxx +++ b/unotools/source/config/securityoptions.cxx @@ -35,6 +35,7 @@ #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> +#include <comphelper/sequenceasvector.hxx> #include <tools/urlobj.hxx> #include <tools/wldcrd.hxx> @@ -490,7 +491,7 @@ void SvtSecurityOptions_Impl::LoadAuthors( void ) Sequence< Any > lValues = GetProperties( lAllAuthors ); if( lValues.getLength() == c2 ) { - m_seqTrustedAuthors.realloc( c1 ); + comphelper::SequenceAsVector< SvtSecurityOptions::Certificate > v; SvtSecurityOptions::Certificate aCert( 3 ); for( i1 = 0, i2 = 0 ; i1 < c1 ; ++i1 ) { @@ -500,8 +501,16 @@ void SvtSecurityOptions_Impl::LoadAuthors( void ) ++i2; lValues[ i2 ] >>= aCert[ 2 ]; ++i2; - m_seqTrustedAuthors[ i1 ] = aCert; + // Filter out TrustedAuthor entries with empty RawData, which + // would cause an unexpected std::bad_alloc in + // SecurityEnvironment_NssImpl::createCertificateFromAscii and + // have been observed in the wild (fdo#55019): + if( !aCert[ 2 ].isEmpty() ) + { + v.push_back( aCert ); + } } + m_seqTrustedAuthors = v.getAsConstList(); } } } diff --git a/unotools/source/config/viewoptions.cxx b/unotools/source/config/viewoptions.cxx index 112ffbb36b33..a327c77f534a 100644 --- a/unotools/source/config/viewoptions.cxx +++ b/unotools/source/config/viewoptions.cxx @@ -283,6 +283,8 @@ class SvtViewOptionsBase_Impl { //------------------------------------------------------------------------------------------------------------- public: + enum State { STATE_NONE, STATE_FALSE, STATE_TRUE }; + SvtViewOptionsBase_Impl ( const ::rtl::OUString& sList ); virtual ~SvtViewOptionsBase_Impl ( ); sal_Bool Exists ( const ::rtl::OUString& sName ); @@ -296,7 +298,7 @@ class SvtViewOptionsBase_Impl sal_Int32 GetPageID ( const ::rtl::OUString& sName ); void SetPageID ( const ::rtl::OUString& sName , sal_Int32 nID ); - sal_Bool GetVisible ( const ::rtl::OUString& sName ); + State GetVisible ( const ::rtl::OUString& sName ); void SetVisible ( const ::rtl::OUString& sName , sal_Bool bVisible ); css::uno::Any GetUserItem ( const ::rtl::OUString& sName , @@ -703,28 +705,33 @@ void SvtViewOptionsBase_Impl::SetPageID( const ::rtl::OUString& sName , } //***************************************************************************************************************** -sal_Bool SvtViewOptionsBase_Impl::GetVisible( const ::rtl::OUString& sName ) +SvtViewOptionsBase_Impl::State SvtViewOptionsBase_Impl::GetVisible( const ::rtl::OUString& sName ) { #ifdef DEBUG_VIEWOPTIONS ++m_nReadCount; #endif - sal_Bool bVisible = sal_False; + State eState = STATE_NONE; try { css::uno::Reference< css::beans::XPropertySet > xNode( impl_getSetNode(sName, sal_False), css::uno::UNO_QUERY); if (xNode.is()) - xNode->getPropertyValue(PROPERTY_VISIBLE) >>= bVisible; + { + sal_Bool bVisible = sal_False; + if (xNode->getPropertyValue(PROPERTY_VISIBLE) >>= bVisible) + { + eState = bVisible ? STATE_TRUE : STATE_FALSE; + } + } } catch(const css::uno::Exception& ex) { - bVisible = sal_False; SVTVIEWOPTIONS_LOG_UNEXPECTED_EXCEPTION(ex) } - return bVisible; + return eState; } //***************************************************************************************************************** @@ -1082,7 +1089,7 @@ sal_Bool SvtViewOptions::IsVisible() const sal_Bool bState = sal_False; if( m_eViewType == E_WINDOW ) - bState = m_pDataContainer_Windows->GetVisible( m_sViewName ); + bState = m_pDataContainer_Windows->GetVisible( m_sViewName ) == SvtViewOptionsBase_Impl::STATE_TRUE; return bState; } @@ -1104,6 +1111,25 @@ void SvtViewOptions::SetVisible( sal_Bool bState ) } //***************************************************************************************************************** +// public method +//***************************************************************************************************************** +bool SvtViewOptions::HasVisible() const +{ + // Ready for multithreading + ::osl::MutexGuard aGuard( GetOwnStaticMutex() ); + + // Safe impossible cases. + // These call isn't allowed for dialogs, tab-dialogs or tab-pages! + OSL_ENSURE( !(m_eViewType==E_DIALOG||m_eViewType==E_TABDIALOG||m_eViewType==E_TABPAGE), "SvtViewOptions::IsVisible()\nCall not allowed for Dialogs, TabDialogs or TabPages! I do nothing!\n" ); + + bool bState = false; + if( m_eViewType == E_WINDOW ) + bState = m_pDataContainer_Windows->GetVisible( m_sViewName ) != SvtViewOptionsBase_Impl::STATE_NONE; + + return bState; +} + +//***************************************************************************************************************** css::uno::Sequence< css::beans::NamedValue > SvtViewOptions::GetUserData() const { // Ready for multithreading |