Kaydet (Commit) 46ad5472 authored tarafından Tor Lillqvist's avatar Tor Lillqvist

bnc#648251: Avoid crash when attempting to open embedded OLE object as "text"

On non-Windows, when double-clicking an embedded OLE object, our glorious
content type detection logic detects it as "Text". As a side-effect, we start
to calculate text statistics on it. Which surely could produce interesting
numbers (you know what they say about statistics), but sadly causes a crash
involving the ICU RuleBasedBreakIterator, SwScanner,
sw::DocumentStatisticsManager and whatnot.

Avoid this by checking for a detected filter of type "Text" explicitly, and
avoiding the fun code paths in that case.

This leads to double-clicks being just ignored. Maybe it would be more useful
to produce a "General OLE Error" message box?

Change-Id: Iae0726b5e9c511a92bdff7229d2978cbf76cb07b
üst b77bf975
...@@ -191,6 +191,7 @@ class OleEmbeddedObject : public ::cppu::WeakImplHelper5 ...@@ -191,6 +191,7 @@ class OleEmbeddedObject : public ::cppu::WeakImplHelper5
// if the following member is set, the object works in wrapper mode // if the following member is set, the object works in wrapper mode
::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > m_xWrappedObject; ::com::sun::star::uno::Reference< ::com::sun::star::embed::XEmbeddedObject > m_xWrappedObject;
bool m_bTriedConversion; bool m_bTriedConversion;
OUString m_aFilterName; // if m_bTriedConversion, then the filter detected by that
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent; ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xParent;
......
...@@ -265,18 +265,18 @@ bool OleEmbeddedObject::TryToConvertToOOo() ...@@ -265,18 +265,18 @@ bool OleEmbeddedObject::TryToConvertToOOo()
// the stream must be seekable // the stream must be seekable
uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY_THROW ); uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY_THROW );
xSeekable->seek( 0 ); xSeekable->seek( 0 );
OUString aFilterName = OwnView_Impl::GetFilterNameFromExtentionAndInStream( m_xFactory, OUString(), m_xObjectStream->getInputStream() ); m_aFilterName = OwnView_Impl::GetFilterNameFromExtentionAndInStream( m_xFactory, OUString(), m_xObjectStream->getInputStream() );
// use the solution only for OOXML format currently // use the solution only for OOXML format currently
if ( !aFilterName.isEmpty() if ( !m_aFilterName.isEmpty()
&& ( aFilterName == "Calc MS Excel 2007 XML" || aFilterName == "Impress MS PowerPoint 2007 XML" || aFilterName == "MS Word 2007 XML" ) ) && ( m_aFilterName == "Calc MS Excel 2007 XML" || m_aFilterName == "Impress MS PowerPoint 2007 XML" || m_aFilterName == "MS Word 2007 XML" ) )
{ {
uno::Reference< container::XNameAccess > xFilterFactory( uno::Reference< container::XNameAccess > xFilterFactory(
m_xFactory->createInstance("com.sun.star.document.FilterFactory"), m_xFactory->createInstance("com.sun.star.document.FilterFactory"),
uno::UNO_QUERY_THROW ); uno::UNO_QUERY_THROW );
OUString aDocServiceName; OUString aDocServiceName;
uno::Any aFilterAnyData = xFilterFactory->getByName( aFilterName ); uno::Any aFilterAnyData = xFilterFactory->getByName( m_aFilterName );
uno::Sequence< beans::PropertyValue > aFilterData; uno::Sequence< beans::PropertyValue > aFilterData;
if ( aFilterAnyData >>= aFilterData ) if ( aFilterAnyData >>= aFilterData )
{ {
...@@ -309,7 +309,7 @@ bool OleEmbeddedObject::TryToConvertToOOo() ...@@ -309,7 +309,7 @@ bool OleEmbeddedObject::TryToConvertToOOo()
aArgs[1].Name = "ReadOnly"; aArgs[1].Name = "ReadOnly";
aArgs[1].Value <<= sal_True; aArgs[1].Value <<= sal_True;
aArgs[2].Name = "FilterName"; aArgs[2].Name = "FilterName";
aArgs[2].Value <<= aFilterName; aArgs[2].Value <<= m_aFilterName;
aArgs[3].Name = "URL"; aArgs[3].Name = "URL";
aArgs[3].Value <<= OUString( "private:stream" ); aArgs[3].Value <<= OUString( "private:stream" );
aArgs[4].Name = "InputStream"; aArgs[4].Name = "InputStream";
...@@ -838,7 +838,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID ) ...@@ -838,7 +838,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
} }
} }
if ( !m_pOwnView && m_xObjectStream.is() ) if ( !m_pOwnView && m_xObjectStream.is() && m_aFilterName != "Text" )
{ {
try { try {
uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY ); uno::Reference< io::XSeekable > xSeekable( m_xObjectStream, uno::UNO_QUERY );
...@@ -859,7 +859,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID ) ...@@ -859,7 +859,7 @@ void SAL_CALL OleEmbeddedObject::doVerb( sal_Int32 nVerbID )
} }
} }
if ( !m_pOwnView || !m_pOwnView->Open() ) if ( m_aFilterName != "Text" && (!m_pOwnView || !m_pOwnView->Open()) )
{ {
//Make a RO copy and see if the OS can find something to at //Make a RO copy and see if the OS can find something to at
//least display the content for us //least display the content for us
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment